Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL
Дата
Msg-id 87u1itcacs.fsf@mailbox.samurai.com
обсуждение исходный текст
Ответ на Cannot assign ROWTYPE, RECORD variables in PL/pgSQL  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL  ("Josh Berkus" <josh@agliodbs.com>)
Re: Cannot assign ROWTYPE, RECORD variables in PL/pgSQL  (elein <elein@sbcglobal.net>)
Список pgsql-bugs
Josh Berkus <josh@agliodbs.com> writes:
> 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 := this_row;
>
> return that_row.first_name;
>
> end;'
> language 'plpgsql';
> =======================================
>
> ... it will error out at the assignment "that_row := this_row".

So we'd want a deep copy, right?

> The only way to populate that_row with a copy of this_row is by re-querying
> the source table.

Well, you can also iterate through the fields of this_row and assign
them to that_row manually -- of course, that's not much better.

> While a relatively easy workaround, this behaviour is annoying and
> inconsistent.  It would be nice to fix in 7.3.1 or 7.4.

Unless anyone sees a problem with this, I'll work on this. I
definately think it's inappropriate for 7.3.1 though.

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

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

Предыдущее
От: Neil Conway
Дата:
Сообщение: pg_ctl is fragile
Следующее
От: Tom Lane
Дата:
Сообщение: Re: pg_ctl is fragile