Re: BUG #1277: plpgsql EXECUTE bug in beta3

From: "Tom Hebbron" <news_user(at)hebbron(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1277: plpgsql EXECUTE bug in beta3
Date: 2004-10-04 18:19:43
Message-ID: cjs48c$7ho$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote in message
news:366(dot)1096909353(at)sss(dot)pgh(dot)pa(dot)us(dot)(dot)(dot)
> "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org> writes:
>> Under beta3, the following behaviour is observed:
>
>> test=# create or replace function execute_sql(text) returns void AS
>> $$begin
>> execute $1; return; end; $$ language plpgsql;
>> CREATE FUNCTION
>> test=#
>> test=# select execute_sql('create table a (i integer); insert into a(i)
>> values(1);');
>> ERROR: relation "a" does not exist
>> CONTEXT: SQL query "create table a (i integer); insert into a(i)
>> values(1);"
>> PL/pgSQL function "execute_sql" line 1 at execute statement
>
> This is happening because EXECUTE now parses and plans the whole string
> in one go, so that it tries to plan the INSERT before the CREATE has
> been carried out. You would see the same behavior if you tried for
> instance to execute those two commands as the body of an SQL function.
> I am inclined to regard this as "not a bug", and tell you to execute the
> two queries in separate EXECUTE commands. I'm not sure it's worth the
> substantial additional complexity in spi.c that would be needed to
> preserve the old behavior --- especially when the documentation does not
> suggest anywhere that you can use EXECUTE to execute more than one
> command in the first place.
>
> Anyone else have an opinion?
>
> regards, tom lane
>

I guessed it would be something like that - thanks for the explanation -
will update our code to perform each step individually.

--
Tom Hebbron
www.hebbron.com

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Sean Chittenden 2004-10-04 23:17:38 Re: bgwriter interfering with consistent view of system tables?
Previous Message Tom Lane 2004-10-04 17:02:33 Re: BUG #1277: plpgsql EXECUTE bug in beta3