Skip to content

Commit

Permalink
Stop parsing a table named "limits" as the LIMIT keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
choroba committed Jun 28, 2024
1 parent 5096566 commit 497ff83
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dbdimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion t/35limit.t
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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, limit9 INT(10), flag ENUM("9","0","1") )');
my $limits = 500;
my $flag = 1;
my $id = 1;
$dbh->do('INSERT INTO dbd_mysql_t35_1 SET id=?, limit9=?, flag=?', undef, $id, $limits, $flag);
my ($set_flag) = $dbh->selectrow_array('SELECT flag FROM dbd_mysql_t35_1 WHERE id=?', undef, $id);

is($set_flag, $flag, 'limit set');

ok($dbh->do("DROP TABLE dbd_mysql_t35_1"));

ok($dbh->disconnect);

0 comments on commit 497ff83

Please sign in to comment.