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

Stop parsing a table named "limits" as the LIMIT keyword #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
22 changes: 21 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 => 124;

ok(defined $dbh, "Connected to database");

Expand Down Expand Up @@ -75,4 +75,24 @@ SQL

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

# Issue #205: A table named "limits" shouldn't be parsed as LIMIT.
my $limits = 500;
my $flag = 1;
my $id = 1;
$dbh->do('CREATE TABLE IF NOT EXISTS dbd_mysql_t35_1 ( id INT(10) PRIMARY KEY, lxmxts INT(10), flag ENUM("9","0","1") )');
$dbh->do('INSERT INTO dbd_mysql_t35_1 SET id=?, lxmxts=?, flag=?', undef, $id, $limits, $flag);
my ($set_flag1) = $dbh->selectrow_array('SELECT flag FROM dbd_mysql_t35_1 WHERE id=?', undef, $id);

is($set_flag1, $flag, 'flag set without limits involved');

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

$dbh->do('CREATE TABLE IF NOT EXISTS dbd_mysql_t35_2 ( id INT(10) PRIMARY KEY, limits INT(10), flag ENUM("9","0","1") )');
$dbh->do('INSERT INTO dbd_mysql_t35_2 SET id=?, limits=?, flag=?', undef, $id, $limits, $flag);
my ($set_flag2) = $dbh->selectrow_array('SELECT flag FROM dbd_mysql_t35_2 WHERE id=?', undef, $id);

is($set_flag2, $flag, 'flag set with limits involved');

ok($dbh->do('DROP TABLE dbd_mysql_t35_2'));

ok($dbh->disconnect);