Re: PL/pgSQL 2

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: PL/pgSQL 2
Дата
Msg-id 54047A32.1050504@2ndquadrant.com
обсуждение исходный текст
Ответ на PL/pgSQL 2  (Joel Jacobson <joel@trustly.com>)
Ответы Re: PL/pgSQL 2  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: PL/pgSQL 2  (Joel Jacobson <joel@trustly.com>)
Список pgsql-hackers
On 09/01/2014 05:04 PM, Joel Jacobson wrote:
> From the top of my head, these are Things I personally would want to see
> in plpgsql2:

Oh, also, I'd *love* to improve how non-plannable statements with
PL/PgSQL variable subsitutions behave.

*I* understand why the following is wrong:

DO
$$
DECLARE    tablename text;
BEGIN   tablename := 'sometable';   DROP TABLE tablename;
END;
$$;

and produces:

ERROR:  table "tablename" does not exist
CONTEXT:  SQL statement "DROP TABLE tablename"
PL/pgSQL function inline_code_block line 6 at SQL statement


but going by the number of questions I see about this, and similar
issues with ALTER USER and so on, it's not obvious to new users.

It's not clear how to make this friendly without making it dangerous
though. If you have:
   DROP TABLE x;

then someone declares a variable
   x := 'customers';

you don't want to suddenly be issuing a
   DROP TABLE customers;

... which is why I suspect this might need to be not 100% backward
compatible, perhaps requiring a variable-marker prefix.

-- Craig Ringer                   http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services



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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: PL/pgSQL 2
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: PL/pgSQL 2