Skip Menu |
 

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

Report information
The Basics
Id: 114548
Status: rejected
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors:
Cc:
AdminCc:

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



Subject: length($string) > 32; length(substr($string, 0, 32)) == 31
Download (untitled) / with headers
text/plain 2.1k
Strings are being represented with an incorrect length when pulled from a database. DBD::Pg version 3.5.3; DBI version 1.634.0 Code ================================= my $dbpass = ''; use DBI; use Devel::Peek; use strict; use warnings; my $db; $db = DBI->connect('dbi:Pg:dbname=db;host=localhost','user',$dbpass,{AutoCommit => 1}); my ($md5size); my $q = $db->prepare('SELECT md5size FROM hashes WHERE md5size IS NOT NULL LIMIT 5'); $q->execute(); $q->bind_columns(\$md5size); while ($q->fetch()) { print "\n"; Dump $md5size; print $md5size , "\n"; printf "%vx\n", $md5size; print '.' x 32, '-' x 32 . "\n"; print substr($md5size, 0, 32), " (" . length($md5size) . ' -- ' . length(substr($md5size, 0, 32)) . ")\n"; } ================================= Output for the last good fetch and the first bad fetch ================================= SV = PVMG(0xc8f590) at 0x9a1800 REFCNT = 2 FLAGS = (SMG,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0xd3fcf0 "xxxxxxxxxxxxxxxxxxxxxxxx2c76efde-83654"\0 [UTF8 "xxxxxxxxxxxxxxxxxxxxxxxx2c76efde-83654"] CUR = 38 LEN = 40 MAGIC = 0xd40030 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = 38 xxxxxxxxxxxxxxxxxxxxxxxx2c76efde-83654 xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.32.63.37.36.65.66.64.65.2d.38.33.34.35.36 ................................-------------------------------- xxxxxxxxxxxxxxxxxxxxxxxx2c76efde (38 -- 32) SV = PVMG(0xc8f590) at 0x9a1800 REFCNT = 2 FLAGS = (SMG,POK,pPOK,UTF8) IV = 0 NV = 0 PV = 0xd3fcf0 "xxxxxxxxxxxxxxxxxxxxxxxxa7360334-5682"\0 [UTF8 "xxxxxxxxxxxxxxxxxxxxxxxxa7360334-5682"] CUR = 37 LEN = 40 MAGIC = 0xd40030 MG_VIRTUAL = &PL_vtbl_utf8 MG_TYPE = PERL_MAGIC_utf8(w) MG_LEN = 38 xxxxxxxxxxxxxxxxxxxxxxxxa7360334-5682 xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.xx.61.37.33.36.30.33.33.34.2d.35.36.38.32 ................................-------------------------------- xxxxxxxxxxxxxxxxxxxxxxxxa736033 (38 -- 31) ================================= Workarounds: 1. At the start of the loop, $md5size =~ /(.*)/; $md5size = $1; 2. At the end of the loop, $md5size = undef; 3. fetchrow_arrayref() doesn't exhibit the problem
Download (untitled) / with headers
text/plain 377b
Thank you for the report. Unfortunately, I was not able to reproduce this. Perhaps more information would help - what versions of everything are you using, and what does the "hashes" table look like? A quick test like this showed no size difference: $SQL = 'SELECT md5(x::text) FROM generate_series(1,5) x'; ... rest of the test script is the same, except DDump not Dump
Closing as invalid due to failure to duplicate, and lack of response. Feel free to re-open.


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.