Skip Menu |

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

Report information
The Basics
Id: 76506
Status: resolved
Priority: 0/
Queue: DBD-Firebird

People
Owner: MARIUZ [...] cpan.org
Requestors: XENU [...] cpan.org
Cc:
AdminCc:

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



Subject: Invalid string returned for CHAR columns
Hi! See the attached file. Script should print "10" but instead, it prints "40", 30 spaces are appended to string. Regards, Tomasz
Subject: firebirdtest.pl
# Test table: # # CREATE TABLE TEST # ( # CHAR_TEST CHAR( 10) CHARACTER SET UTF8 # ); # # INSERT INTO TEST (CHAR_TEST) VALUES ('TEST'); # use strict; use warnings; use DBI; my $dbh = DBI->connect( 'dbi:Firebird:db=C:\\sql\\test.fdb;host=localhost;port=3050;ib_charset=UTF8;', 'SYSDBA', 'masterkey', { ib_enable_utf8 => 1 } ) or die $DBI::errstr; my $sth = $dbh->prepare('SELECT CHAR_TEST FROM TEST;') or die $DBI::errstr; $sth->execute or die $DBI::errstr; my $hashref = $sth->fetchrow_hashref; print length $hashref->{CHAR_TEST};
We can't reproduce the issue https://github.com/mariuz/perl-dbd-firebird/issues/32 and see the related test case https://github.com/mariuz/perl-dbd- firebird/commit/33c791da7d26f536be4f44c688565847424db53a
На 12 апр. 2012, чт 16:40:41, XENU написа: Show quoted text
> Hi! > > See the attached file. Script should print "10" but instead, it prints > "40", 30 spaces are appended to string.
This is not a bug in DBD::FIrebird, but a "feature" of the Firebird API. When fetching values after SELECT, the sqllen member of the SQLDA contains the maximum length in bytes. For CHAR(20) column, when using UTF8 connection charset, sqllen is 80, and there is no way for DBD::Firebird to determine that the column is really CHAR(20). My advise would be to use VARCHAR columns when the data is not guaranteed to fill the whole width. For VARCHAR the SQLDA contains the actual data length.
On Sun Jul 22 10:03:47 2012, DAM wrote: Show quoted text
> На 12 апр. 2012, чт 16:40:41, XENU написа:
> > Hi! > > > > See the attached file. Script should print "10" but instead, it
prints Show quoted text
> > "40", 30 spaces are appended to string.
> > This is not a bug in DBD::FIrebird, but a "feature" of the Firebird
API. Show quoted text
> > When fetching values after SELECT, the sqllen member of the SQLDA > contains the maximum length in bytes. For CHAR(20) column, when using > UTF8 connection charset, sqllen is 80, and there is no way for > DBD::Firebird to determine that the column is really CHAR(20). > > My advise would be to use VARCHAR columns when the data is not > guaranteed to fill the whole width. For VARCHAR the SQLDA contains the > actual data length.
From the firebird-devel list Actually, (sqlsubtype & 0xFF) will tell you that this is UTF8, so you can easily find out length in chars dividing sqllen by 4. http://thread.gmane.org/gmane.comp.db.firebird.devel/1862
It is solved in 1.10 just uploaded to cpan