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:
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user