Re: The tuple structure of a not-yet-assigned record is indeterminate.

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: M L <novemberox(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: The tuple structure of a not-yet-assigned record is indeterminate.
Date: 2009-03-23 01:11:18
Message-ID: 49C6E1B6.8030702@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

M L wrote:

> CREATE TRIGGER league AFTER insert ON t_leagues FOR STATEMENT EXECUTE
> PROCEDURE add_view();
>
> Then in psql I made an query and got error:
>
> league=# INSERT INTO t_leagues (name) VALUES('3liga');
> ERROR: record "new" is not assigned yet
> DETAIL: The tuple structure of a not-yet-assigned record is indeterminate.
> CONTEXT: PL/pgSQL function "add_view" line 4 at RAISE

`NEW' and `OLD' refer to the tuple operated on by this call of the
trigger. They're not valid for FOR EACH STATEMENT triggers, since the
statement might've added/modified/deleted zero or more than one tuple.

If you want to see the values of the tuples modified, use a FOR EACH ROW
trigger.

> Whats wrong, I supposed that id is not reserverd at the moment

That's not the case. Your trigger is being called *AFTER* the row is
inserted, so the ID must've been assigned. In any case, default
expressions (including those used to assign values from sequences) are
actually evaluated even before the BEFORE triggers are invoked.

--
Craig Ringer

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message M L 2009-03-23 02:03:44 Re: The tuple structure of a not-yet-assigned record is indeterminate.
Previous Message M L 2009-03-22 22:47:48 The tuple structure of a not-yet-assigned record is indeterminate.