K2InformaticsGmbH / imem

Clustered in-memory database based on MNESIA with simple SQL layer
http://www.k2informatics.ch/
Apache License 2.0
21 stars 4 forks source link

009158 Bad param for parameterized SQL crashes FSM #315

Closed c-bik closed 4 years ago

c-bik commented 4 years ago

from imem master branch

select
    to_list(:list_lista)
from
    dual

image

=ERROR REPORT==== 16-Jan-2020::17:44:01 ===
** Generic server <0.23061.2> terminating 
** Last message in was {'$gen_cast',
                           {fetch_recs_async,true,66706819,
                               {<0.18725.2>,
                                {<0.23062.2>,
                                 #Ref<0.1963621565.2391015427.46482>}},
                               []}}
** When Server state == {state,
                         {statement,
                          [{'mpro1@127.0.0.1',mpro,dual}],
                          100,
                          <<"select\r\n    to_list(:list_lista)\r\nfrom\r\n    dual">>,
                          {select,
                           [{fields,
                             [{'fun',<<"to_list">>,
                               [{param,<<":list_lista">>}]}]},
                            {from,[<<"dual">>]},
                            {where,{}},
                            {'hierarchical query',{}},
                            {'group by',[]},
                            {having,{}},
                            {'order by',[]}]},
                          [{<<":list_lista">>,list,0,[<<"1">>]}],
                          "L",
                          [{bind,0,0,undefined,undefined,
                            <<"to_list(:list_lista)">>,undefined,list,0,0,
                            undefined,true,#Fun<imem_sql_funs.56.86715944>,
                            {'fun',<<"to_list">>,[{param,<<":list_lista">>}]},
                            {to_list,
                             {bind,1,3,undefined,<<"_param_">>,<<"_param_">>,
                              <<":list_lista">>,list,0,0,undefined,false,
                              undefined,undefined,undefined,'$13'}},
                            1}],
                          [{bind,1,1,<<"mpro">>,<<"_meta_">>,<<"_meta_">>,
                            <<"rownum">>,integer,10,0,undefined,false,
                            undefined,undefined,undefined,'$11'},
                           {bind,1,2,<<"mpro">>,<<"_meta_">>,<<"_meta_">>,
                            <<"node">>,atom,100,0,undefined,false,undefined,
                            undefined,undefined,'$12'},
                           {bind,1,3,undefined,<<"_param_">>,<<"_param_">>,
                            <<":list_lista">>,list,0,0,undefined,false,
                            undefined,undefined,undefined,'$13'},
                           {bind,2,2,<<"mpro">>,<<"dual">>,<<"dual">>,
                            <<"dummy">>,string,undefined,undefined,"X",false,
                            undefined,undefined,undefined,'$22'},
                           {bind,2,3,<<"mpro">>,<<"dual">>,<<"dual">>,
                            <<"nac">>,atom,undefined,undefined,'$not_a_value',
                            false,undefined,undefined,undefined,'$23'}],
                          [<<"rownum">>,<<"node">>],
                          #Fun<imem_datatype.2.22625868>,
                          #Fun<imem_sql_expr.36.116093332>,[],
                          {scanSpec,
                           [{{'_','$22','$23'},[true],['$_']}],
                           true,true,true,true,200000},
                          []},
                         #Ref<0.1963621565.2390753284.246930>,true,82962846,
                         {fetchCtx,undefined,undefined,undefined,undefined,
                          100,undefined,0,[],undefined,undefined,undefined,
                          undefined,[],false},
                         undefined,[]}
** Reason for termination == 
** {bad_return_value,{'ClientError',{"Data conversion format error",
                                     {<<":list_lista">>,{list,0,<<"1">>}}}}}
17:44:01.861 [info] received unexpected exit for monitored pid <0.23061.2> ref #Ref<0.1963621565.2390753284.246937> reason {bad_return_value,{'ClientError',{"Data conversion format error",{<<":list_lista">>,{list,0,<<"1">>}}}}}

on imem safe_subnet_mask_api branch

select
    to_binstr(mfa('imem_datatype', 'subnet_mask', list(:binstr_ip, :integer_port
    ))) subnet_mask
from
    dual

image

=ERROR REPORT==== 16-Jan-2020::17:50:17 ===
** State machine <0.23460.2> terminating
** Last event = {cast,{rows,{<0.23459.2>,
                             [{{1,'mpro1@127.0.0.1',<<"11:40.0.0">>,17},
                               {dual,"X",'$not_a_value'}}],
                             true}}}
** When server state  = {filling,
                         {state,
                          {ctx,
                           [<0.23459.2>],
                           [],
                           [#Fun<imem_adapter_funs.0.57470052>],
                           [#Fun<imem_adapter_funs.1.57470052>],
                           [#Fun<imem_adapter_funs.2.57470052>],
                           [#Fun<imem_adapter_funs.3.57470052>],
                           [#Fun<imem_adapter_funs.4.57470052>],
                           [#Fun<imem_adapter_funs.5.57470052>],
                           [{rowCol,1,<<"subnet_mask">>,binstr,0,0,true}],
                           #Fun<imem_datatype.2.22625868>,
                           #Fun<imem_sql_expr.36.116093332>,[],undefined,
                           <<"select\r\n    to_binstr(mfa('imem_datatype', 'subnet_mask', list(:binstr_ip, :integer_port\r\n    ))) subnet_mask\r\nfrom\r\n    dual">>,
                           [{<<":integer_port">>,integer,0,[<<"17">>]},
                            {<<":binstr_ip">>,binstr,0,[<<"11:40.0.0">>]}],
                           100,<<>>},
                          #Ref<0.1963621565.2390884356.253165>,
                          #Ref<0.1963621565.2390884356.253166>,100,300,1,
                          #Fun<imem_datatype.2.22625868>,[],
                          #Fun<imem_sql_expr.36.116093332>,
                          {undefined,[]},
                          #Fun<dderl_fsm.42.109201653>,0,99999999,0,0,
                          99999999,0,0,[],{},0,99999999,0,0,undefined,
                          undefined,false,raw,false,1,false,false,
                          {button,<<">">>,#Fun<gen_adapter.57.7758152>},
                          #Fun<gen_adapter.57.7758152>,<<>>,undefined,
                          [1],
                          1579193417210,
                          [ok]}}
** Reason for termination = error:{bad_return_from_state_function,
                                   {'ClientError',
                                    {"Illegal IP address","11:40.0.0",
                                     {throw,
                                      {'ClientError',
                                       {"Bad IPv4 address",nxdomain}}}}}}
** Callback mode = state_functions
** Stacktrace =
**  [{gen_statem,parse_event_result,8,[{file,"gen_statem.erl"},{line,1318}]},
     {gen_statem,loop_event,6,[{file,"gen_statem.erl"},{line,1015}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
17:50:17.211 [error] dderl_session received unknown msg {'EXIT',<0.23460.2>,{{bad_return_from_state_function,{'ClientError',{"Illegal IP address","11:40.0.0",{throw,{'ClientError',{"Bad IPv4 address",nxdomain}}}}}},[{gen_statem,parse_event_result,8,[{file,"gen_statem.erl"},{line,1318}]},{gen_statem,loop_event,6,[{file,"gen_statem.erl"},{line,1015}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}} for <<"system">>

no crash (proper error messages propagated) for non-parameterized counterparts

image image

stoch commented 4 years ago

Please note: