Wrong enum value on insert/update if colum name contains string "limit"
aliwink opened this issue · 0 comments
aliwink commented
If an insert/update statement contains a (unquoted) column name which itself contains the string limit
this column and all following columns of type enum within the same query are getting the wrong value: the enum value is interpreted as the enum index (as if the bind type is set to integer).
Code to reproduce:
my $limits = 500;
my $flag = 1;
$dbh->do('CREATE TABLE IF NOT EXISTS table1 ( id INT(10) PRIMARY KEY AUTO_INCREMENT, limits INT(10), flag ENUM("9","0","1") )');
$dbh->do('INSERT INTO table1 SET limits=?, flag=?', undef, $limits, $flag);
my ($set_flag) = $dbh->selectrow_array('SELECT flag FROM table1 WHERE id=?', undef, $dbh->last_insert_id);
print "setting $flag => $set_flag\n";
Instead of $flag
and $set_flag
being equal, $set_flag
has the value 9 (value at index 1).
However, my tests have shown that the enum value is correct if:
- the enum column
flag
comes before the columnlimits
in the query - the column
limits
is quoted:`limits`
- no column whose name contains the string
limit
is selected - no placeholder is used: the value is part of the query string (i.e.
set flag=1
instead ofset flag=?
)
Also, the behavior was apparently introduced with DBD::MariaDB, I could not reproduce it with DBD::mysql (4.050).
MariaDB Server: 10.11.6 (1:10.11.6-0+deb12u1)
DBD::MariaDB: 1.22 (1.22-1+b1)
DBI: 1.643 (1.643-4)