bad variable subst after "AS"

Поиск
Список
Период
Сортировка
От Darren Duncan
Тема bad variable subst after "AS"
Дата
Msg-id 4C91BA41.4090403@darrenduncan.net
обсуждение исходный текст
Ответы Re: bad variable subst after "AS"  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: bad variable subst after "AS"  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
Re: bad variable subst after "AS"  (Andrew Dunstan <andrew@dunslane.net>)
Re: bad variable subst after "AS"  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-hackers
I don't know if this is a bug or not, but if not, it looks like a misfeature ...

When executing the following in Pg 8.4.4:
  CREATE OR REPLACE FUNCTION f () RETURNS TABLE(a1 INTEGER) AS  $BODY$  BEGIN    RETURN QUERY SELECT a0 AS a1 FROM rv;
 RETURN;  END;  $BODY$  LANGUAGE plpgsql;
 

... I get this error:
  ERROR: syntax error at or near "$1"  SQL state: 42601

My impression of this is that Pg is treating the "a1" after the "AS" like it was
a variable reference and so substituted it for $1.

Now that just seems wrong to me.  I can understand either "a0" or "rv" getting a
substitution, but something following an "AS" being substituted is just wrong.

Is that a bug and if not then what is the rationale for working that way, and
can it be changed?

Meanwhile, what is the best way to write f to work around this misbehavior?

Thank you.

-- Darren Duncan



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

Предыдущее
От: SAKAMOTO Masahiko
Дата:
Сообщение: Re: patch: SQL/MED(FDW) DDL
Следующее
От: Pavel Stehule
Дата:
Сообщение: Re: bad variable subst after "AS"