From 497ff838ebded72224d50fe4c484e2b48c9aa39b Mon Sep 17 00:00:00 2001 From: "E. Choroba" Date: Fri, 28 Jun 2024 12:24:27 -0700 Subject: [PATCH] Stop parsing a table named "limits" as the LIMIT keyword Fixes #205. --- dbdimp.c | 2 ++ t/35limit.t | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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..b27c68ba 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, 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);