Skip Menu |

This queue is for tickets about the DBD-mysql CPAN distribution.

Report information
The Basics
Id: 50304
Status: resolved
Priority: 0/
Queue: DBD-mysql

People
Owner: MICHIELB [...] cpan.org
Requestors: kevin [...] bosak.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in:
  • 4.005
  • 4.006
  • 4.007
  • 4.008
  • 4.009
  • 4.010
  • 4.011
  • 4.012
  • 4.013
Fixed in: (no value)



Subject: column_info broken for set values that contain parentheses
I ran across a case where I was calling column_info on a table where set values had parentheses. The column_info code was not returning the expected set values. It appeared to have ignored everything in the list of set values after the first closing parenthesis it found. After some digging I found this regex is the culprit: $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; I've not tested thoroughly, but I suspect something like this would work better: $type = substr($type, 0, rindex($type, ')')+1); $type =~ m/^(\w+)(?:\((.*)\))/; I found this bug in version 4.005 but 4.013 also appears to have the same regex.
This bug bit me again so I've looked at this more and did some testing. My previous fix wasn't close, but this seems to work for me in version 4.007 and 4.013. I've also run the test suite win 4.013 with this change and did fail a few tests but I think they're unrelated (40catalog and 80process). If there's anything else I can do to help get this bug in the next release, I'm more than happy to help. @@ -443,10 +443,10 @@ for my $row (@$desc) { my $type = $row->{type}; - $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; + $type =~ m/^(\w+)(\((.+)\))?\s?(.*)?$/; my $basetype = lc($1); - my $typemod = $2; - my $attr = $3; + my $typemod = $3; + my $attr = $4; my $info = $col_info{ $row->{field} }= { TABLE_CAT => $catalog, On Wed Oct 07 14:40:58 2009, KBOSAK wrote: Show quoted text
> I ran across a case where I was calling column_info on a table where set > values had parentheses. The column_info code was not returning the > expected set values. It appeared to have ignored everything in the list > of set values after the first closing parenthesis it found. > > After some digging I found this regex is the culprit: > $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; > > I've not tested thoroughly, but I suspect something like this would work > better: > > $type = substr($type, 0, rindex($type, ')')+1); > $type =~ m/^(\w+)(?:\((.*)\))/; > > I found this bug in version 4.005 but 4.013 also appears to have the > same regex.
Thank you for the patch! I'll test it with the latest DBD::mysql and include it in an upcoming release if all checks out. On Mon Feb 15 16:23:10 2010, KBOSAK wrote: Show quoted text
> This bug bit me again so I've looked at this more and did some testing. > My previous fix wasn't close, but this seems to work for me in version > 4.007 and 4.013. I've also run the test suite win 4.013 with this > change and did fail a few tests but I think they're unrelated (40catalog > and 80process). If there's anything else I can do to help get this bug > in the next release, I'm more than happy to help. > > @@ -443,10 +443,10 @@ > for my $row (@$desc) > { > my $type = $row->{type}; > - $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; > + $type =~ m/^(\w+)(\((.+)\))?\s?(.*)?$/; > my $basetype = lc($1); > - my $typemod = $2; > - my $attr = $3; > + my $typemod = $3; > + my $attr = $4; > > my $info = $col_info{ $row->{field} }= { > TABLE_CAT => $catalog, > > > > On Wed Oct 07 14:40:58 2009, KBOSAK wrote:
> > I ran across a case where I was calling column_info on a table where set > > values had parentheses. The column_info code was not returning the > > expected set values. It appeared to have ignored everything in the list > > of set values after the first closing parenthesis it found. > > > > After some digging I found this regex is the culprit: > > $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; > > > > I've not tested thoroughly, but I suspect something like this would work > > better: > > > > $type = substr($type, 0, rindex($type, ')')+1); > > $type =~ m/^(\w+)(?:\((.*)\))/; > > > > I found this bug in version 4.005 but 4.013 also appears to have the > > same regex.
> >
Just wanting to see if there's anything I can help with to move this bug along. It just bit me again because I'm still having to manually put in my patch. On Sat Mar 06 13:30:40 2010, CAPTTOFU wrote: Show quoted text
> Thank you for the patch! I'll test it with the latest DBD::mysql and > include it in an upcoming release if all checks out. > > On Mon Feb 15 16:23:10 2010, KBOSAK wrote:
> > This bug bit me again so I've looked at this more and did some
testing. Show quoted text
> > My previous fix wasn't close, but this seems to work for me in
version Show quoted text
> > 4.007 and 4.013. I've also run the test suite win 4.013 with this > > change and did fail a few tests but I think they're unrelated
(40catalog Show quoted text
> > and 80process). If there's anything else I can do to help get this
bug Show quoted text
> > in the next release, I'm more than happy to help. > > > > @@ -443,10 +443,10 @@ > > for my $row (@$desc) > > { > > my $type = $row->{type}; > > - $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; > > + $type =~ m/^(\w+)(\((.+)\))?\s?(.*)?$/; > > my $basetype = lc($1); > > - my $typemod = $2; > > - my $attr = $3; > > + my $typemod = $3; > > + my $attr = $4; > > > > my $info = $col_info{ $row->{field} }= { > > TABLE_CAT => $catalog, > > > > > > > > On Wed Oct 07 14:40:58 2009, KBOSAK wrote:
> > > I ran across a case where I was calling column_info on a table
where set Show quoted text
> > > values had parentheses. The column_info code was not returning
the Show quoted text
> > > expected set values. It appeared to have ignored everything in
the list Show quoted text
> > > of set values after the first closing parenthesis it found. > > > > > > After some digging I found this regex is the culprit: > > > $type =~ m/^(\w+)(?:\((.*?)\))?\s*(.*)/; > > > > > > I've not tested thoroughly, but I suspect something like this
would work Show quoted text
> > > better: > > > > > > $type = substr($type, 0, rindex($type, ')')+1); > > > $type =~ m/^(\w+)(?:\((.*)\))/; > > > > > > I found this bug in version 4.005 but 4.013 also appears to have
the Show quoted text
> > > same regex.
> > > >
> >
Hi Kevin, On Wed Oct 07 14:40:58 2009, KBOSAK wrote: Show quoted text
> I ran across a case where I was calling column_info on a table where set > values had parentheses. The column_info code was not returning the > expected set values. It appeared to have ignored everything in the list > of set values after the first closing parenthesis it found.
Can you add an example 'CREATE TABLE' statement for a table where this problem would manifest itself? -- Mike
Here's a short example: CREATE TABLE `mytable` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `problem_column` set('','(Some Text)') DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `id` (`id`) ); The parenthesis in the set values of 'problem_column' aren't being parsed correctly. On Mon Oct 28 06:59:06 2013, MICHIELB wrote: Show quoted text
> Hi Kevin, > > On Wed Oct 07 14:40:58 2009, KBOSAK wrote:
> > I ran across a case where I was calling column_info on a table where > > set > > values had parentheses. The column_info code was not returning the > > expected set values. It appeared to have ignored everything in the > > list > > of set values after the first closing parenthesis it found.
> > Can you add an example 'CREATE TABLE' statement for a table where this > problem would manifest itself? > -- > Mike
Thanks for the test table; I was now able to create a test script for this issue, which I added here: https://github.com/perl5-dbi/DBD-mysql/commit/aa6b66f5ccedcb9b7e01a191921021539029ee56 the fix is also already in DBD::mysql now, so when we release 4.025 you'll no longer have to patch it manually :D Many thanks for your contribution! -- Mike