Re: Allow COMMENT ON to accept an expression rather than just a string

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Allow COMMENT ON to accept an expression rather than just a string
Дата
Msg-id 3973.1239475479@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Allow COMMENT ON to accept an expression rather than just a string  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: Allow COMMENT ON to accept an expression rather than just a string  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-hackers
Pavel Stehule <pavel.stehule@gmail.com> writes:
> But the proc
> CREATE OR REPLACE FUNCTION some_proc(tabname varchar)
> RETURNS void AS $$
> BEGIN
>   EXECUTE 'CREATE TABLE $1(a integer)' USING tabname;

> is more readable than EXECUTE 'CREATE TABLE ' || tabname || '(....

I was intentionally excluding the idea of substituting parameters for
names as opposed to constants.  For one thing it's fundamentally
ambiguous --- given
string_var := 'foo';
EXECUTE 'SELECT $1 FROM bar' USING string_var;

is that supposed to mean SELECT 'foo' FROM bar or SELECT foo FROM bar?

The other problem is that if you allow name substitution it becomes
entirely impossible to do any planning or even validity checking before
the parameter values are available.  So while string assembly is kind
of a pain in the rear when you really do need a dynamic name reference,
I think we should keep it firmly separate from parameter substitution.
        regards, tom lane


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

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: Allow COMMENT ON to accept an expression rather than just a string
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: Allow COMMENT ON to accept an expression rather than just a string