Skip to content

Commit bb15d9b

Browse files
kebhrdveeden
authored andcommitted
fix some queries with columns beginning with limit would fail
1 parent 684ffee commit bb15d9b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

dbdimp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ static char *parse_params(
475475
it would be good to be able to handle any number of cases and orders
476476
*/
477477
if (((*statement_ptr == ' ') || (*statement_ptr == '\n') || (*statement_ptr == '\t')) &&
478-
(!strncmp(statement_ptr+1, "limit ", 5) ||
479-
!strncmp(statement_ptr+1, "LIMIT ", 5)))
478+
(!strncmp(statement_ptr+1, "limit ", 6) ||
479+
!strncmp(statement_ptr+1, "LIMIT ", 6)))
480480
{
481481
limit_flag = 1;
482482
}

t/35limit.t

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ eval {$dbh= DBI->connect($test_dsn, $test_user, $test_password,
2323
if ($@) {
2424
plan skip_all => "no database connection";
2525
}
26-
plan tests => 115;
26+
plan tests => 117;
2727

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

3030
ok($dbh->do("DROP TABLE IF EXISTS dbd_mysql_t35"), "making slate clean");
3131

32-
ok($dbh->do("CREATE TABLE dbd_mysql_t35 (id INT(4), name VARCHAR(64), name_limit VARCHAR(64))"), "creating table");
32+
ok($dbh->do("CREATE TABLE dbd_mysql_t35 (id INT(4), name VARCHAR(64), name_limit VARCHAR(64), limit_by VARCHAR(64))"), "creating table");
3333

34-
ok(($sth = $dbh->prepare("INSERT INTO dbd_mysql_t35 VALUES (?,?,?)")));
34+
ok(($sth = $dbh->prepare("INSERT INTO dbd_mysql_t35 VALUES (?,?,?,?)")));
3535

3636
for my $i (0..99) {
3737
my @chars = grep !/[0O1Iil]/, 0..9, 'A'..'Z', 'a'..'z';
3838
my $random_chars = join '', map { $chars[rand @chars] } 0 .. 16;
3939

4040
# save these values for later testing
4141
$testInsertVals->{$i} = $random_chars;
42-
ok(($rows = $sth->execute($i, $random_chars, $random_chars)));
42+
ok(($rows = $sth->execute($i, $random_chars, $random_chars, $random_chars)));
4343
}
4444

4545
ok($sth = $dbh->prepare("SELECT * FROM dbd_mysql_t35 LIMIT ?, ?"),
@@ -53,6 +53,11 @@ ok( (defined($array_ref = $sth->fetchall_arrayref) &&
5353

5454
ok(@$array_ref == 50);
5555

56+
ok($sth = $dbh->prepare("SELECT * FROM dbd_mysql_t35 WHERE limit_by > ?"),
57+
"testing prepare of select statement with started by 'limit' column");
58+
59+
ok($sth->execute("foobar"), 'testing exec of bind vars for placeholder');
60+
5661
ok($sth->finish);
5762

5863
ok($dbh->do("UPDATE dbd_mysql_t35 SET name_limit = ? WHERE id = ?", undef, "updated_string", 1));

0 commit comments

Comments
 (0)