fixes db crash; simplifies the ezic_db proxy module

The db crash happens when calling `ezic_db:get_all(X)` when `X` is not
a valid table name. `ezic_db_ets` crashes, causing the `ezic_db`
server to crash, tossing the database with it. The solution prevents
ezic_db_ets:get_all/1 from crashing, and instead returns an error
value.

The simplification here eliminated some code through
deduplication. The `handle_call` functions could be improved
similarly.
This commit is contained in:
aj heller
2012-12-17 18:02:16 -08:00
parent d98eed7b52
commit aa79af71aa
3 changed files with 37 additions and 39 deletions

View File

@@ -13,13 +13,17 @@
, get_all/1
, insert_all/1
, wipe/1
, implementation/0
]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PUBLIC API
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
implementation() -> ?MODULE.
zones(TzName) ->
ets:select(zone, [{#zone{name=TzName, _='_'}, [], ['$_']}]).
@@ -43,7 +47,11 @@ flatzone(Date, TzName) ->
get_all(Tab) ->
ets:lookup(Tab, Tab).
try ets:lookup(Tab, Tab) of X -> X
catch error:X -> {error, X}
end.
insert_all(Records) ->