Cannot assign ROWTYPE, RECORD variables in PL/pgSQL

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
Дата
Msg-id 200211061427.16554.josh@agliodbs.com
обсуждение исходный текст
Ответы Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL  (Neil Conway <neilc@samurai.com>)
Список pgsql-bugs
Bug: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
Affects: PL/pgSQL
Severity:  Annoyance
Priority:  Minor Enhancement
Confirmed On: 7.3beta2, Linux

Given the following function:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
create or replace function rowtype_test ()
returns text as '
declare this_row candidates%rowtype;
    that_row candidates%rowtype;
begin
select * into this_row
from candidates;

that_row :=3D this_row;

return that_row.first_name;

end;'
language 'plpgsql';
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

... it will error out at the assignment "that_row :=3D this_row".

For that matter, any attempt to assign the contents of two ROWTYPE or RECOR=
D=20
variables directly to each other will error out:

that_record :=3D this_record;

SELECT this_row INTO that_row;

SELECT * INTO that_row
FROM this_row;

The only way to populate that_row with a copy of this_row is by re-querying=
=20
the source table.   While a relatively easy workaround, this behaviour is=
=20
annoying and inconsistent.  It would be nice to fix in 7.3.1 or 7.4.

Thanks for your attention.

--=20
-Josh Berkus
 Aglio Database Solutions
 San Francisco

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: like not using indexes in 7.3b5?
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: Problem with a sequence being acted on by an on insert