Re: DDL+SQL in PL/pgSQL EXECUTE - Mailing list pgsql-hackers

From Tom Lane
Subject Re: DDL+SQL in PL/pgSQL EXECUTE
Date
Msg-id 8495.1237380508@sss.pgh.pa.us
Whole thread Raw
In response to DDL+SQL in PL/pgSQL EXECUTE  (Vlad Arkhipov <arhipov@dc.baikal.ru>)
List pgsql-hackers
Vlad Arkhipov <arhipov@dc.baikal.ru> writes:
> 3. ERROR:  relation "t" does not exist
> SELECT _EXEC('CREATE TABLE T(ID INTEGER); INSERT INTO T(ID) VALUES (1)');

> 4. Inserts NULL value into ID column instead of default 10.
> BEGIN WORK;
> CREATE TABLE T(ID INTEGER);
> SELECT _EXEC('ALTER TABLE T ALTER COLUMN ID SET DEFAULT(10); INSERT INTO 
> T DEFAULT VALUES');

Commands submitted in a single string are typically parsed and planned
before they are executed (though the behavior probably depends on
context and which PG version you're talking about).  My advice is
don't do that.

If we were to do anything about it, it'd probably be to ban
multi-statement EXECUTE on security grounds ...
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: cs_CZ vs regression tests, part N
Next
From: Alvaro Herrera
Date:
Subject: Re: gettext, plural form and translation