Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong enum value on insert/update if colum name contains string "limit" #205

Open
aliwink opened this issue Jun 11, 2024 · 0 comments · May be fixed by #208
Open

Wrong enum value on insert/update if colum name contains string "limit" #205

aliwink opened this issue Jun 11, 2024 · 0 comments · May be fixed by #208

Comments

@aliwink
Copy link

aliwink commented Jun 11, 2024

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 column limits 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 of set 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)

choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 28, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 28, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 28, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 28, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 29, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 29, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 29, 2024
choroba added a commit to choroba/DBD-MariaDB that referenced this issue Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant