]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_config_mysql: Fix several issues related to recent table changes 80/4080/1
authorGeorge Joseph <gjoseph@digium.com>
Wed, 12 Oct 2016 21:30:40 +0000 (15:30 -0600)
committerGeorge Joseph <gjoseph@digium.com>
Wed, 12 Oct 2016 21:48:52 +0000 (16:48 -0500)
commitbb08fae6a9305d6df4b1d13bc9c3c4ed7a7564b1
tree5f4ee9bc781d5a03ea149f36175f0d9628712a80
parent8ff4d75e9eae039d8f5bac817db45fc43307a6fe
res_config_mysql:  Fix several issues related to recent table changes

Unlike any of the other database drivers, res_config_mysql checks that
the table definition matches the requirements for every insert and
update statement.  Since all requirements are forced to 'char', any
column that isn't a char, like ps_contacts' expiration_time,
qualify_timeout, etc., will throw a warning.  It's kinda harmless but
very misleading.  Since no other driver does those checks on insert
or update, they've been removed from res_config_mysql.  Also, all
the logic that actually attempted to ALTER the table to fix the issue
has been removed.  With the move to alembic, the auto-alter
functionality is not only unnecessary, it's also dangerous.

The other issue is that res_config_mysql calls the mysql_insert_id
function inside store_mysql.  Presumably the intention was to return
the number of rows inserted DESPITE A NOTE IN THE CODE THAT THE VALUE
IS NON_PORTABLE AND MAY CHANGE.  That value is then returned to
config realtime as the number of rows inserted.  Guess what?  The value
changed.  It now only returns the number of rows inserted if there's an
auto increment column on the table, which ps_contacts doesn't have.
Otherwise it returns 0.  So now, the insert worked but we tell config
realtime and sorcery that no rows were inserted.  That call to
mysql_insert_id was removed and we now always return 1 if the insert
succeeded.  We're only inserting 1 row at a time anyway.  If the insert
fails, we still return -1.

ASTERISK-26362 #close
Reported-by: Carlos Chavez
Change-Id: I83ce633efdb477b03c8399946994ee16fefceaf4
addons/res_config_mysql.c