diff --git a/dbdimp.c b/dbdimp.c index 6104405d..869a4d21 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -883,6 +883,8 @@ static char *parse_params( /* in case this is a nested LIMIT */ case ')': + /* in case this is table named "limit" */ + case '=': limit_flag = FALSE; *ptr++ = *statement_ptr++; break; diff --git a/t/35limit.t b/t/35limit.t index 35429049..5525f96b 100644 --- a/t/35limit.t +++ b/t/35limit.t @@ -14,7 +14,7 @@ require 'lib.pl'; my $dbh = DbiTestConnect($test_dsn, $test_user, $test_password, { RaiseError => 1, PrintError => 0, AutoCommit => 0 }); -plan tests => 120; +plan tests => 122; ok(defined $dbh, "Connected to database"); @@ -75,4 +75,16 @@ SQL ok($dbh->do("DROP TABLE dbd_mysql_t35")); +# Issue #205: A table named "limits" shouldn't be parsed as LIMIT. +$dbh->do('CREATE TABLE IF NOT EXISTS dbd_mysql_t35_1 ( id INT(10) PRIMARY KEY AUTO_INCREMENT, limits INT(10), flag ENUM("9","0","1") )'); +my $limits = 500; +my $flag = 1; +$dbh->do('INSERT INTO dbd_mysql_t35_1 SET limits=?, flag=?', undef, $limits, $flag); +my ($set_flag) = $dbh->selectrow_array('SELECT flag FROM dbd_mysql_t35_1 WHERE id=?', undef, $dbh->last_insert_id); + +is($set_flag, $flag, 'limit set'); + + +ok($dbh->do("DROP TABLE dbd_mysql_t35_1")); + ok($dbh->disconnect);