Skip Menu |

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

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

People
Owner: MICHIELB [...] cpan.org
Requestors: knarf [...] knarf.de
Cc: pali [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: zerofill
Date: Sat, 26 Nov 2016 17:08:26 +0100
To: bug-DBD-mysql [...] rt.cpan.org
From: Frank Bartels <knarf [...] knarf.de>
Hi, I use perl v5.24.1 together with p5-DBD-mysql-4.040. I have a script that used to work for 10 years or more but now broke because of the recent changes: "Fix integer types when server side prepare statements are enabled" I do something like this: my $query = $dbh->prepare("SELECT Albums.Id,Tracks.Id,Albums.Artist,Albums.Title,Albums.Cddb,Albums.Genre,Albums.Year,Tracks.Trackname,Tracks.Tracknum,Tracks.Length,Tracks.VBR,Tracks.Bitrate FROM Tracks,Albums WHERE Tracks.Albumref=Albums.Id ORDER BY Tracks.Id"); $query->execute; while ( ( $AlbumId, $TrackId, $DB{TPE1}, $DB{TALB}, $DB{CDDB}, $DB{TCON}, $DB{TYER}, $DB{TIT2}, $DB{TRCK}, $DB{TLEN}, $DB{VBR}, $DB{BITRATE} ) = $query->fetchrow_array ) { Albums.Id is "smallint(5) unsigned zerofill" in mysql 5.5.53. Before 4.040 $AlbumId was "00001". With 4.040 $AlbumId changed to "1". I know this is not the best design. :) I fixed it doing $AlbumId = sprintf("%05s", $AlbumId); for now. Do you plan to bring back the old behaviour? Thanks, Knarf
Download smime.p7s
application/x-pkcs7-signature 3.8k

Message body not shown because it is not plain text.

On Sob Nov 26 11:08:46 2016, knarf@knarf.de wrote: Show quoted text
> Hi, > > I use perl v5.24.1 together with p5-DBD-mysql-4.040. > > I have a script that used to work for 10 years or more but now broke > because of the recent changes: "Fix integer types when server side > prepare statements are enabled" > > I do something like this: > > my $query = $dbh->prepare("SELECT > Albums.Id,Tracks.Id,Albums.Artist,Albums.Title,Albums.Cddb,Albums.Genre,Albums.Year,Tracks.Trackname,Tracks.Tracknum,Tracks.Length,Tracks.VBR,Tracks.Bitrate > FROM Tracks,Albums WHERE Tracks.Albumref=Albums.Id ORDER BY > Tracks.Id"); > $query->execute; > > while ( ( $AlbumId, $TrackId, $DB{TPE1}, $DB{TALB}, $DB{CDDB}, > $DB{TCON}, > $DB{TYER}, $DB{TIT2}, $DB{TRCK}, $DB{TLEN}, $DB{VBR}, $DB{BITRATE} > ) = $query->fetchrow_array ) { > > Albums.Id is "smallint(5) unsigned zerofill" in mysql 5.5.53. > > Before 4.040 $AlbumId was "00001". With 4.040 $AlbumId changed to > "1". > > I know this is not the best design. :) > > I fixed it doing > > $AlbumId = sprintf("%05s", $AlbumId); > > for now. > > Do you plan to bring back the old behaviour? > > Thanks, > Knarf
Hi! ZEROFILL mysql attribute is not supported by DBD::mysql yet. You had just luck that if worked and probably worked only for non-server-side prepared statements. Anyway, for supporting ZEROFILL in DBD::mysql I see there only one solution: Tell mysql to return column as string, not integer. That can be quite ineffective, but probably only possible solution right now... Here is patch for it: https://github.com/perl5-dbi/DBD-mysql/pull/75 I would be happy if you test it.
RT-Send-CC: pali [...] cpan.org
This is now merged in https://github.com/perl5-dbi/DBD-mysql/commit/dc4d40b1df2f05b9e23105ab6d7b98c77eb318de Thanks Pali for the patch, and thanks Knarf for the report! -- Michiel
Reopening, fix was reverted in 4.043.