Skip Menu |
 

This queue is for tickets about the CGI-Session CPAN distribution.

Report information
The Basics
Id: 14558
Status: resolved
Priority: 0/
Queue: CGI-Session

People
Owner: Nobody in particular
Requestors: tylerm [...] activestate.com
Cc:
AdminCc:

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

Attachments


Subject: PostgreSQL Driver can't use a binary serializer
Download (untitled) / with headers
text/plain 513b
The CGI::Session::PostgreSQL driver does not support the use of binary serializers (eg; storable) due to DBD::Pg's decision to be unlike every other DBD driver. While other drivers will always reliably quote binary data containing NULLs, DBD::Pg chooses to only do so if you bind() the parameter as type PG_BYTEA. The attached patch works around this quirk by always bind()ing the SQL parameters when adding/updating a session record. This lets you use the "Storable" serializer with postgres. Cheers, Tyler
Download pgsql-binary.patch
text/x-diff 1.5k
diff -rdu CGI-Session-3.95.old/Session/PostgreSQL.pm CGI-Session-3.95/Session/PostgreSQL.pm --- CGI-Session-3.95.old/Session/PostgreSQL.pm 2005-09-12 12:55:02.000000000 -0700 +++ CGI-Session-3.95/Session/PostgreSQL.pm 2005-09-12 12:55:19.000000000 -0700 @@ -26,6 +26,7 @@ CGI::Session::Serialize::Default ); +use DBD::Pg qw(:pg_types); # driver specific libraries should go below @@ -63,24 +64,22 @@ eval { if( $db_data ) { - #warn('do update sid='.$sid.' data='.$self->freeze($data)); - - $dbh->do( - ' UPDATE '.$TABLE_NAME. - ' SET a_session='.$dbh->quote($self->freeze($data)). - ' WHERE id='.$dbh->quote($sid) - ); - + my $sth = $dbh->prepare( + "UPDATE $TABLE_NAME SET a_session = ? WHERE id = ?" + ); + + $sth->bind_param(1, $self->freeze($data), { pg_type => PG_BYTEA }); + $sth->bind_param(2, $sid); + $sth->execute; } else { - #warn('do insert sid='.$sid.' data='.$self->freeze($data)); - - $dbh->do( - 'INSERT INTO '.$TABLE_NAME.' (id,a_session) '. - 'VALUES ('.$dbh->quote($sid).', '.$dbh->quote($self->freeze($data)).')' - ); - + my $sth = $dbh->prepare( + "INSERT INTO $TABLE_NAME (id, a_session) VALUES (?, ?)" + ); + + $sth->bind_param(1, $sid); + $sth->bind_param(2, $self->freeze($data), { pg_type => PG_BYTEA }); } };
Download (untitled) / with headers
text/plain 133b
The problem was fixed in 4.02. Try it. Let us know if the problem still persists. -- Sherzod Ruzmetov http://author.handalak.com/


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.