Re: BUG #5154: ERROR: cannot assign non-composite value to a row variable

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jeff Shanab <jshanab(at)earthlink(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5154: ERROR: cannot assign non-composite value to a row variable
Date: 2009-10-31 04:37:00
Message-ID: 162867790910302137k5e678473v250b89004a69b61e@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello

2009/10/31 Jeff Shanab <jshanab(at)earthlink(dot)net>:
>
> The following bug has been logged online:
>
> Bug reference:      5154
> Logged by:          Jeff Shanab
> Email address:      jshanab(at)earthlink(dot)net
> PostgreSQL version: 8.3.5
> Operating system:   Linux
> Description:        ERROR:  cannot assign non-composite value to a row
> variable
> Details:
>
> As discussed on the irc. I had a problem with a utility function that was
> being passed a NEW row and a null for the OLD row. The error was created
> when it tries to store the row variable in the local variables. RhodiumToad
> on the list provided this simple test.
>
> create type foo1 as (a integer, b text);
> CREATE TYPE
> create type foo2 as (c integer, d foo1);
> CREATE TYPE
>
> create function foo() returns foo2 language plpgsql as $f$ declare v foo2;
> begin v := null; return v; end; $f$;
> CREATE FUNCTION
>

This isn't bug - it is just feature. ROW value cannot contain scalar
value. If you would to like reset variable, use NULL row constant.

BEGIN
v := (NULL, NULL);

-- it is equalent to NULL

RAISE NOTICE 'IS IT NULL %', v IS NULL;

RETURN NULL;
END;

Regards
Pavel Stehule

> select foo();
>
> ERROR: cannot assign non-composite value to a row variable
>
> CONTEXT: PL/pgSQL function "foo" line 1 at assignment
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Fetter 2009-10-31 05:45:21 Re: BUG #5150: math bug
Previous Message John R Pierce 2009-10-31 03:51:57 Re: BUG #5150: math bug