Обсуждение: BUG #4329: Transaction model changed?

Поиск
Список
Период
Сортировка

BUG #4329: Transaction model changed?

От
"Gerd Grossmann"
Дата:
The following bug has been logged online:

Bug reference:      4329
Logged by:          Gerd Grossmann
Email address:      gerdgrossmann@njini.com
PostgreSQL version: 8.0.17
Operating system:   Red Hat Enterprise Linux 4
Description:        Transaction model changed?
Details:

Executing the following

CREATE OR REPLACE FUNCTION compatTest() RETURNS void
    AS $$
DECLARE
    createStmnt TEXT;
BEGIN
    createStmnt:='CREATE TABLE test (val integer);INSERT INTO test (val)
VALUES (1);';
    EXECUTE createStmnt;
    RETURN;
END;
$$
    LANGUAGE plpgsql;

SELECT compatTest();

would just work fine under postgresql 8.3 but does not work with postgresql
8.0. It complains that the table test does not exist! Instead it has to be
written like this:

CREATE OR REPLACE FUNCTION compatTest() RETURNS void
    AS $$
DECLARE
    createStmnt TEXT;
BEGIN
    createStmnt:='CREATE TABLE test (val integer);';
    EXECUTE createStmnt;
    createStmnt:='INSERT INTO test (val) VALUES (1);';
    EXECUTE createStmnt;
    RETURN;
END;
$$
    LANGUAGE plpgsql;

SELECT compatTest();

To me it looks like 8.3 is correct. I assume this is also the reason why it
changed. But since it was not documented anywhere ..

Re: BUG #4329: Transaction model changed?

От
Tom Lane
Дата:
"Gerd Grossmann" <gerdgrossmann@njini.com> writes:
> Executing the following

>     createStmnt:='CREATE TABLE test (val integer);INSERT INTO test (val)
> VALUES (1);';
>     EXECUTE createStmnt;

> would just work fine under postgresql 8.3 but does not work with postgresql
> 8.0. It complains that the table test does not exist!

I get the same complaint in both versions; which I find unsurprising
because the whole querystring is parsed and planned before execution
begins.

            regards, tom lane