perl5-dbi / DBD-mysql

MySQL driver for the Perl5 Database Interface (DBI)
https://metacpan.org/module/DBD::mysql
Other
62 stars 71 forks source link

mysql_bind_type_guessing fails on single "special" character [rt.cpan.org #97541] #165

Open mbeijen opened 6 years ago

mbeijen commented 6 years ago

Migrated from rt.cpan.org#97541 (status was 'new')

Requestors:

Attachments:

From mail@oliwel.de on 2014-07-27 11:10:54:

Hi,

this is a followup on #48242
(https://rt.cpan.org/Public/Bug/Display.html?id=48242).

mysql_bind_type_guessing detects a value which consists of only a single
character (plus,minus,dot,e) as a number, resulting in an invalid mysql
statement.

Reproduce:

my $sth = $dbh->prepare('insert into test (test) values (?)');
$sth->execute(('+'));
$sth->execute(('.'));
$sth->execute(('-'));
$sth->execute(('e'));

Causes "syntax error near ')'" resp. " Unknown column 'e' in 'field list".

Reason: Parts of the patch to solve 48242 have been reverted later, see
github commits:

6e296abd - introduces "seen_digit"

1474dcb0 - removes the flag by commenting it

+    /* Not sure why this was changed */
+    /* seen_digit= 1; */

+    /* Need to revisit this */
+    /*if (len == 0 || cp - string < (int) len || seen_digit == 0) {*/
+    if (len == 0 || cp - string < (int) len) {

I did not have a full view on the code, but reactivating these lines
SHOULD fix the issue without any side effects.

Oliver

-- 
Protect your environment -  close windows and adopt a penguin!
pali commented 6 years ago

Fixed for DBD::MariaDB (https://github.com/gooddata/DBD-MariaDB) in pull request: https://github.com/gooddata/DBD-MariaDB/pull/57