Perl DBI + binary data in psql not working

From: Paul Schilling <pfschill(at)direct-learning(dot)com>
To: pgsql-general(at)postgreSQL(dot)org, dbi-users(at)fugue(dot)com
Subject: Perl DBI + binary data in psql not working
Date: 1999-10-13 02:05:44
Message-ID: Pine.LNX.3.96.991012205132.23056A-100000@anakin.direct-learning.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying to use Apache::Session + psql and ran into a problem with
binary data from Storable::nfreeze To demonstrate what is happening I
wrote this quick script:

#!/usr/bin/perl
use DBI;
use strict;
use Storable qw(nfreeze thaw);

my $dbh = DBI->connect("dbi:Pg:dbname=pfschill", '', '');
my $st = $dbh->prepare_cached('
INSERT INTO sessions (id, length, a_session) VALUES (?,?,?)');

my $data = {'stuff' => 'other stuff'};
my $serialized = nfreeze $data;
my $session = "1234";

$st->bind_param(1, $session);
$st->bind_param(2, length $serialized);
$st->bind_param(3, $serialized);
$st->execute;

Running this you get:
DBD::Pg::st execute failed: ERROR: parser: parse error at or near ""
Database handle destroyed without explicit disconnect.

The sessions table is:
+-----------------------------+----------------------------------+-------+
| Field | Type | Length|
+-----------------------------+----------------------------------+-------+
| id | char() not null default '' | 16 |
| length | int4 not null default 0 | 4 |
| a_session | lo | 4 |
+-----------------------------+----------------------------------+-------+

I have also tried the text type. I can't tell if this is just a DBD::Pg
problem with binary data or if I am having a problem with binary data in
psql as well (which is why I am posting this to both lists, sorry.)

Does anyone have a solution to this? I can fall back to either using the
Apache::Session::File or MySQL for the sessions but I would rather not.

Thanks.
--
Paul Schilling
pfschill(at)direct-learning(dot)com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yin-So Chen 1999-10-13 02:34:55 Re: [GENERAL] stored procedure revisited
Previous Message Bruce Momjian 1999-10-13 01:42:35 Re: [GENERAL] Is the data type decimal() still a valid type?