[Asterisk-bugs] [Asterisk 0010205]: Results containing spaces from FETCH cause ast_yyerror()

noreply at bugs.digium.com noreply at bugs.digium.com
Mon Jul 16 02:32:14 CDT 2007


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=10205 
====================================================================== 
Reported By:                jamesb63
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   10205
Category:                   Addons/app_addon_sql_mysql
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     feedback
Asterisk Version:            SVN 
SVN Branch (only for SVN checkouts, not tarball releases):  1.4  
SVN Revision (number only!): 75108M 
Disclaimer on File?:        No 
Request Review:              
====================================================================== 
Date Submitted:             07-15-2007 09:54 CDT
Last Modified:              07-16-2007 02:32 CDT
====================================================================== 
Summary:                    Results containing spaces from FETCH cause
ast_yyerror()
Description: 
When executing a query and getting its result, a field in a mysql table
containing a space causes the following error:

[Jul 15 16:06:13] WARNING[30551]: ast_expr2.fl:398 ast_yyerror:
ast_yyerror():  syntax error: syntax error, unexpected '<token>', expecting
$end; Input:
 James Mobile
       ^

With the ^ under the M

The query is simply:

select cidname from caller_id where cidnum = '${CALLERID(num)}';

If I remoe the space in the table and replace with _ (underscore), the
problem goes away.

This may not be the right category to post the bug but it's a result of
using the MYSQL() command from the addons package that I found the problem.
====================================================================== 

---------------------------------------------------------------------- 
 jamesb63 - 07-16-07 02:32  
---------------------------------------------------------------------- 
Here is the entire macro in question:

---- CUT ----
macro setcidprefix(lineprefix) {
  //LookupCIDName();
  MYSQL(Connect connID ${MYSQLHOST} ${MYSQLUSER} ${MYSQLPASS}
${MYSQLDATA});
  if ("${connID}" != "") {
    MYSQL(Query resultID ${connID} select cidname from caller_id where
cidnum='${CALLERID(num)}');
    if ("${resultID}" != "") {
      MYSQL(Fetch fetchID ${resultID} CID_NAME);
      if ("${CID_NAME}" != "") {
        CALLERID(name) = ${CID_NAME};
      } else {
        CALLERID(name) = ${CALLERID(num)};
      };
      MYSQL(Clear ${resultID});
    };
    MYSQL(Disconnect ${connID});
  } else {
    NoOp(Couldn't connect to database);
  };
  CALLERID(num) = "9${CALLERID(num)}";

  // if the lineprefix is empty we don't prepend anything to the caller ID
name
  if ("${lineprefix}" != "") {
    CALLERID(name) = "${lineprefix}: ${CALLERID(name)}";
  };
};
---- CUT ----

It's the FETCH call that generates the error and seems to be when it
attempts to transfer the result from the returned row into a variable.

The field "cidname" in the table "caller_id" contains spaces.  The value
it was attempting to return was "James Mobile", however, after the error,
only the value "James" was found in the CID_NAME variable.

Hope this helps 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
07-16-07 02:32  jamesb63       Note Added: 0067387                          
======================================================================




More information about the asterisk-bugs mailing list