Re: prepared statements and DBD::Pg

From: David Fetter <david(at)fetter(dot)org>
To: Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com>
Cc: Andrej <andrej(dot)groups(at)gmail(dot)com>, JP Fletcher <jpfletch(at)ca(dot)afilias(dot)info>, pgsql-general(at)postgresql(dot)org
Subject: Re: prepared statements and DBD::Pg
Date: 2009-05-07 13:50:11
Message-ID: 20090507135011.GI20491@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, May 07, 2009 at 02:31:08PM +0100, Tim Bunce wrote:
> On Thu, May 07, 2009 at 04:54:06AM +1200, Andrej wrote:
> > 2009/5/7 JP Fletcher <jpfletch(at)ca(dot)afilias(dot)info>:
> > > Hi,
> > >
> > > I see different behavior with DBI/DBD::Pg (1.607/2.11.8, pg 8.1) when the
> > > first command in a prepared statement is 'CREATE TEMP TABLE'.
> > >
> > > For instance, this works:
> > >
> > > my $prepare_sql =<<SQL;
> > > CREATE TEMP TABLE foo( id int, user_id int,);
> > > INSERT INTO foo(1, 1);
> > > INSERT INTO foo(2, 2);
> > > SQL
> > > my $sth = $dbh->prepare($prepare_sql);
> > >
> > > This produces the error
> > > ERROR: cannot insert multiple commands into a prepared statement
> > >
> > Blessed be CPAN and the manuals for DBD
> > http://search.cpan.org/~turnstep/DBD-Pg-2.13.1/Pg.pm#prepare
> >
> > WARNING: DBD::Pg now (as of version 1.40) uses true prepared
> > statements by sending them to the backend to be prepared by the
> > Postgres server. Statements that were legal before may no longer
> > work.
>
> Sure seems like a bug, or at best a misfeature, that DBD::Pg doesn't
> simply fallback to client-side prepare when a server-side prepare
> can't be performed. I believe DBD::mysql does that.

It's a safety feature. :)

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2009-05-07 13:51:36 Re: "No transaction in progress" warning
Previous Message Magnus Hagander 2009-05-07 13:44:18 Re: [GENERAL] how to select temp table