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 d8fc720
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 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);

Check failure on line 83 in t/35limit.t

View workflow job for this annotation

GitHub Actions / perl-5.12.0/system/same-as-server/dbi-1.608

Usage: $h->last_insert_id($catalog, $schema, $table_name, $field_name [, \%attr ])

Check failure on line 83 in t/35limit.t

View workflow job for this annotation

GitHub Actions / perl-5.12.0/system/same-as-server/dbi-1.608

Issuing rollback() for database handle being DESTROY'd without explicit disconnect()

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


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

ok($dbh->disconnect);

0 comments on commit d8fc720

Please sign in to comment.