mnemosyne:string_to_handle() unpleasantness

Dan Gudmundsson dgud@REDACTED
Tue Sep 26 12:52:49 CEST 2000


Hi 

I have looked a little at your problems, since it is an undocumented 
function, we don't support it, or put any effort to keep them working.

It seems that the functionality broke when we optimized mnemosyne a
bit, 

You can try to change it back with the following diff in mnemosyne_lc.erl:  

654,655c658,663
<     {mk_call(?MODULE, the_query, [{Pattern0,Goal0,S#s{mquery=[]}}], Line), 
<      S1};
---
>     MkGetRecDefs = fun() ->
> 			   {call,0,{atom,0,'MNEMOSYNE RULE'},
> 			    [erl_parse:abstract({data,record_defs})]}
> 		   end,
>     S_temp = S#s{mquery=[],options=[],recdefs=MkGetRecDefs},
>     {mk_call(?MODULE, the_query, [{Pattern0,Goal0,S_temp}], Line), S1};

I don't know if it works, but it's one of the changes that happend,
during the time.

/Dan

stephen.wight@REDACTED writes:
 > 
 > I would like to compose a list comprehension query in a non-Erlang
 > environment and pass the query clause as a string to mnemosyne.
 > 
 > I'm unable to use the "undocumented" string_to_handle() function
 > without getting an error from erl_parse:normalize(), which is reported
 > by mnemosyne:setup_query().
 > 
 > I'm testing this with a trivial LC query embedded in a function -
 > note my two alternative query construction methods for debugging;
 > this is to verify that the same LC compiles and runs correctly
 > when used 'normally':
 > 
 > evalq() ->
 >     Q = mnemosyne:string_to_handle("query [X || X <- table(atable)] end."),
 >     %% Q = query [X || X <- table(atable)] end,
 >    
 >     case mnesia:transaction(fun() -> mnemosyne:eval(Q) end) of
 > 	{aborted, Err} ->
 > 	    io:format("transaction aborted ~n", []),
 > 	    Err;
 > 	{atomic, QueryResult} ->
 > 	    io:format("query result ~n", []),
 > 	    QueryResult;
 > 	_ ->
 > 	    false
 >     end.
 > 
 > 
 > The error object being returned looks like this:
 > 
 > 21> mntools:evalq().
 > transaction aborted 
 > {function_clause,[{mnemosyne,setup_query,
 >              [{'EXIT',{function_clause,
 >                           [{erl_parse,
 >                                normalise,
 >                                [{call,
 >                                     0,
 >                                     {atom,0,'MNEMOSYNE RULE'},
 >                                     [{tuple,0,[{...}|...]}]}]},
 >                            {erl_parse,normalise_list,1},
 >                            {erl_parse,normalise,1},
 >                            {erl_parse,normalise_list,1},
 >                            {erl_parse,normalise,1},
 >                            {mnemosyne_lc,
 >                                '-one_lc_to_handle/1-fun-1-',
 >                                2},
 >                            {lists,foldl,3},
 >                            {mnemosyne_lc,one_lc_to_handle,1}|
 >                            more]}}]},
 >   {mnemosyne,cursor,2},
 >   {mnemosyne,eval,1},
 >   {mnesia_tm,apply_fun,2},
 >   {mnesia_tm,execute_transaction,4},
 >   {mntools,evalq,0},
 >   {erl_eval,expr,3},
 >   {erl_eval,exprs,4}|
 >   more]}
 > 
 > 
 > Thanks for any help or suggestions for an alternative route to
 > get this done!!
 > 
 > -steve wight
 > 
 > 
 > 
 > 

-- 
Dan Gudmundsson               Project:    Mnesia, Erlang/OTP
Ericsson Utvecklings AB       Phone:      +46  8 727 5762 
UAB/F/P                       Mobile:     +46 70 519 9469
S-125 25 Stockholm            Visit addr: Armborstv 1 




More information about the erlang-questions mailing list