Skip site navigation (1) Skip section navigation (2)

Re: Bytea and perl

From: "Greg Sabino Mullane" <greg(at)turnstep(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Bytea and perl
Date: 2006-03-24 02:50:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-novice
Hash: SHA1

> OK.  Here is my follow-up question.  Why is this explicit parameter binding
> necessary?  When would I want to have pg_type be something other than
> PG_BYTEA when inserting into a bytea column?

You wouldn't, but the trick is getting all the pieces to know that the column
is bytea. DBD::Pg has no inherent way to find out for iteslf. Nor does libpq.
The planner has an idea, but that information is not transmitted back to DBD:Pg.
The difference then becomes that the low-level calls that DDB::Pg makes to
PostgreSQL via PQexecParams and PQexecPrepared are different if any of the values
are binary. If they are, we can't simply pass a string, but have to pass a
separate array of string lengths, as we can't use \0 to indicae the end of the
data anymore.

> The reason this is important is that many (read this as ALL, as far as I
> know) modules built on top of DBI do not use explicit paramater binding and
> rely on the sth->execute(...) quoting to do the right thing, which it does
> with all column types except bytea, it seems.

Well, there are other column type cases where it will fail, but they are not
as common as bytea. Unfortunately, there is no easy solution. Hopefully these
high-level interface modules left some hooks and knobs to handle this sort
of situation. If they don't, drop them a line, because they should. :)

> I guess a third option is the large object interface, which I am trying to
> avoid.

I suspect that this is even less supported by the other modules, so you might
as well go with the binding at that point. Good luck: hopefully one of the
four options will work out for you.

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200603232139



pgsql-novice by date

Next:From: Sean DavisDate: 2006-03-24 02:58:15
Subject: Re: Bytea and perl
Previous:From: operationsengineer1Date: 2006-03-23 22:14:51
Subject: Re: PostgreSQL a slow DB?

pgsql-hackers by date

Next:From: Christopher Kings-LynneDate: 2006-03-24 02:55:53
Subject: Worthwhile optimisation of position()?
Previous:From: Joel MillerDate: 2006-03-24 01:47:33
Subject: Re: [SUGGESTION] CVSync

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group