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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain
Charset: utf8
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 627
Download (untitled) / with headers
text/plain 627b
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.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-14820-1266268990-269.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1507
Download (untitled) / with headers
text/plain 1.4k
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.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-14820-1266268990-269.50304-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-14820-1266268990-269.50304-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-12691-1267900240-1670.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1761
Download (untitled) / with headers
text/plain 1.7k
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.
> >
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-12691-1267900240-1670.50304-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-14820-1266268990-269.50304-0-0 [...] rt.cpan.org> <rt-3.8.HEAD-12691-1267900240-1670.50304-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-19311-1291910302-1181.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2074
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.
> > > >
> >
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.16-11653-1382957946-1968.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 446
Download (untitled) / with headers
text/plain 446b
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
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-11653-1382957946-1968.50304-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.16-11653-1382957946-1968.50304-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2028-1383061153-1992.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 813
Download (untitled) / with headers
text/plain 813b
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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-20478-1383205998-1748.50304-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 348
Download (untitled) / with headers
text/plain 348b
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


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.