Some strange SQL Error in console output

I have Asterisk RealTime configuration with MySQL database. When I call to a number and leave him voicemail it is saved into database table voicemail_users. Right after I leave the message and hangup I got this in the console( CLI ):
[Feb 5 09:33:29] WARNING[5322][C-0000000a]: app_voicemail.c:3925 retrieve_file: SQL Get Data error! coltitle=mailbox [SELECT * FROM voicemessages WHERE dir=? AND msgnum=?]

Note that the message is fully stored into table VOICEMESSAGES and I can listen from the number to which I leave the voicemail.

What can be the problem for this Warning?

edit:
This is my res_config_mysql.conf
[general] dbhost = MY_IP dbname = asterisk dbuser = MY_USER dbpass = MY_PASS ;dbport = 3306 ;dbsock = /tmp/mysql.sock ;dbcharset = latin1 requirements=warn ; or createclose or createchar
this is extconfig.conf
[settings] sipusers => mysql,general,sipfriends sippeers => mysql,general,sipfriends extensions => mysql,general,extensions voicemail => mysql,general,voicemail_users

It’s been one year now and the above warning is still in the log. Any help is appreciated.

Note that I manually added column mailbox to the voicemessages table but is never stored anything in it… it is staying NULL.

Also if I manually add the number in this column the error isn’t appear anymore. So obviously somehow this column should be populated…

When retrieving a voicemail Asterisk attempts to get information regarding each column in the table. It uses an ODBC call, SQLGetData, to do this. That function takes several arguments with the last being a length or indicator parameter that stores the size of the memory required for the data retrieved. If a NULL value is passed in for this parameter, which it is in Asterisk, and if a column retrieved from the database is itself NULL, which in your case it is, then the function returns an error.

This appears to be what is happening in your case since you describe that if you give that column a value (i.e. it is not longer NULL) then the warning goes away.

So you have a few options:

  1. Remove the field from the table as it appears to not be a required column. This only makes sense of course if you are not using the column for anything else.
  2. Make the column contain a non-NULL value as you have already done. Make the default non-NULL.
  3. Leave it as is and the warning will always be logged, but from what I can tell if the column is the last column in the table it’s essentially ignored by the voicemail code. Aside from it printing out the warning message that is.
2 Likes