Re: PL/pgSQL 2
От | Pavel Stehule |
---|---|
Тема | Re: PL/pgSQL 2 |
Дата | |
Msg-id | CAFj8pRBkseBgpA+ajrh71tKbBLtbwpYqFG9HsO-_nLC6WpdXXA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: PL/pgSQL 2 (Craig Ringer <craig@2ndquadrant.com>) |
Ответы |
Re: PL/pgSQL 2
|
Список | pgsql-hackers |
2014-09-01 15:52 GMT+02:00 Craig Ringer <craig@2ndquadrant.com>:
On 09/01/2014 05:04 PM, Joel Jacobson wrote:> From the top of my head, these are Things I personally would want to seeOh, also, I'd *love* to improve how non-plannable statements with
> in plpgsql2:
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.
It is in ToDo - allow parametrization for COMMANDs.
But this is one point, when I am not sure if we would it. Now - situation is very simply. Variables should not be used as table or column name. With your proposal, the situation will by much more complex, and probably variables should be used in SELECT * FROM x; but it can be ambiguous SELECT x FROM table ... so maybe better to don't allow it
Regards
Pavel
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
В списке pgsql-hackers по дате отправления: