MySQL cmd - syntax error with 1.2 CVS HEAD as of today

I am attempting to use the embedded MySQL command as opposed to invoking via an AGI script. When I do the following:

context macro-lookup-cli { s => { MYSQL(Connect connid localhost my_name my_pass asterisk); MYSQL(Query resultid ${connid} SELECT\ NAME\ FROM\ CLI\ WHERE\ CLI=\'${CALLERIDNUM}\'); if (${fetchid} > 0) { MYSQL(Fetch fetchid ${resultid} cli_name); }; MYSQL(Clear ${resultid}); MYSQL(Disconnect); }; };

I get this error:

[quote=“CLI”] – Executing Macro(“SIP/3004-dd57”, “lookup-cli”) in new stack
– Executing MYSQL(“SIP/3004-dd57”, “Connect connid localhost my_uname my_pass asterisk”) in new stack
– Executing MYSQL(“SIP/3004-dd57”, “Query resultid 1 SELECT NAME FROM CLI WHERE CLI=‘3004’”) in new stack
[b]Nov 9 16:47:27 WARNING[25137]: ast_expr2.fl:176 ast_yyerror: ast_yyerror(): syntax error: syntax error, unexpected TOK_GT, expecting TOK_MINUS or TOK_COMPL or TOK_LP or TOKEN; Input:

0
^
Nov 9 16:47:27 WARNING[25137]: ast_expr2.fl:180 ast_yyerror: If you have questions, please refer to doc/README.variables in the asterisk source.[/b]
– Executing GotoIf(“SIP/3004-dd57”, “0?4:5”) in new stack
– Goto (macro-lookup-cli,s,5)
– Executing NoOp(“SIP/3004-dd57”, “Finish if-s-3”) in new stack
– Executing MYSQL(“SIP/3004-dd57”, "Clear ") in new stack
Nov 9 16:47:27 WARNING[25137]: app_addon_sql_mysql.c:115 find_identifier: Identifier 0, identifier_type 2 not found in identifier list
Nov 9 16:47:27 WARNING[25137]: app_addon_sql_mysql.c:348 aMYSQL_clear: Invalid result identifier 0 passed in aMYSQL_clear
– Executing MYSQL(“SIP/3004-dd57”, “Disconnect”) in new stack
Nov 9 16:47:27 WARNING[25137]: app_addon_sql_mysql.c:115 find_identifier: Identifier -1, identifier_type 1 not found in identifier list
Nov 9 16:47:27 WARNING[25137]: app_addon_sql_mysql.c:365 aMYSQL_disconnect: Invalid connection identifier -1 passed in aMYSQL_disconnect[/quote]

On this table:

[quote=“MySQL”]CREATE TABLE cli (
cli varchar(100) NOT NULL default ‘’,
photo_url varchar(100) default ‘’,
name varchar(100) NOT NULL default ‘’,
PRIMARY KEY (cli)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;[/quote]

Anybody spot what is most likely a simple mistake?

Following the examples here:

voip-info.org/wiki-Asterisk+cmd+MYSQL

This works:

context macro-lookup-cli { s => { MYSQL(Connect connid localhost asterisk jordaan31! asterisk); MYSQL(Query resultid ${connid} SELECT\ NAME\ FROM\ cli\ WHERE\ CLI=\'${CALLERIDNUM}\'); if (${resultid} != NULL) { MYSQL(Fetch fetchid ${resultid} cli_name); }; MYSQL(Clear ${resultid}); MYSQL(Disconnect ${connid}); }; };

The errors:

  • The table names for MySQL are case sensitive, so I was getting an error that the table did not exist
  • I was attempting to do an evaluation (if) on a variable that had not yet been defined

With those changes and evaluating against NULL as opposed to 0, all works fine.