From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | plpgsql - DECLARE - cannot to use %TYPE or %ROWTYPE for composite types |
Date: | 2015-10-19 07:52:28 |
Message-ID: | CAFj8pRCQREdqf_Oov0-8xENUf-VxyQRptgAAat0rPNU7B+BHRA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
We cannot to declare variable with referenced type on other composite
variable. This limit is probably artificial, because any composite type is
any type too in PostgreSQL.
The issue:
referencing on composite variables doesn't work
do $$ declare x int; y x%type; begin end; $$; -- ok
do $$ declare x pg_class; y x%type; begin end; $$; -- invalid type name
"x%type"
do $$ declare x pg_class; y x%rowtype; begin end; $$; -- relation "x" does
not exist
The %ROWTYPE needs a record in pg_class. Probably we should not to change
it. The change can bring a compatibility issues. So there are two
possibilities:
1. %TYPE can be used for any kind of variables. This behave will be
consistent with polymorphic parameters - we have "anyelement", and we have
not "anyrow".
2. introduce new keyword - %RECTYPE .. it can work, but there will be gap
between polymorphic parameters.
Comments, notices?
Regards
Pavel
From | Date | Subject | |
---|---|---|---|
Next Message | YUriy Zhuravlev | 2015-10-19 09:51:49 | Re: Some questions about the array. |
Previous Message | Etsuro Fujita | 2015-10-19 07:51:59 | Re: Foreign join pushdown vs EvalPlanQual |