procedure string constant is parsed at procedure create time.

Поиск
Список
Период
Сортировка
От jian he
Тема procedure string constant is parsed at procedure create time.
Дата
Msg-id CACJufxGQcEnMCT7yR8+FV4cd996UwGabYtxwqi7pNzq7tf8ZtQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: procedure string constant is parsed at procedure create time.
Re: procedure string constant is parsed at procedure create time.
Список pgsql-general
hi.
table "test" does not exist.

---1.this will work.
CREATE or replace PROCEDURE template_create() LANGUAGE SQL
AS $proc$ DROP TABLE if exists test cascade; CREATE TABLE test(id
int4range,valid_at tsrange,name text);$proc$;

----2.this will have errors.
CREATE or replace PROCEDURE template_create() LANGUAGE SQL AS $proc$
    DROP TABLE if exists test cascade;
    CREATE TABLE test(id int4range,valid_at tsrange,name text);
    INSERT INTO test VALUES (NULL, tsrange('2018-01-01',
'2019-01-01'), 'null key');
$proc$;

----3.language plpgsql works fine.
CREATE or replace PROCEDURE template_create()
LANGUAGE plpgsql AS $proc$
    begin
        DROP TABLE if exists test101 cascade;
        CREATE TABLE test101(id int4range,valid_at tsrange,name text);
        INSERT INTO test101 VALUES (NULL, tsrange('2018-01-01',
'2019-01-01'), 'null key');
    end
$proc$;

per manual: https://www.postgresql.org/docs/current/sql-createprocedure.html
"....This form only works for LANGUAGE SQL, the string constant form
works for all languages. This form is parsed at procedure definition
time, the string constant form is parsed at execution time...."

Why does the 2nd query fail? What am I missing?



В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Postgres Out Of Memory Crash
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: procedure string constant is parsed at procedure create time.