Re: The tuple structure of a not-yet-assigned record is indeterminate. - Mailing list pgsql-general

From Craig Ringer
Subject Re: The tuple structure of a not-yet-assigned record is indeterminate.
Date
Msg-id 49C6E1B6.8030702@postnewspapers.com.au
Whole thread Raw
In response to The tuple structure of a not-yet-assigned record is indeterminate.  (M L <novemberox@gmail.com>)
Responses Re: The tuple structure of a not-yet-assigned record is indeterminate.  (M L <novemberox@gmail.com>)
List 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

pgsql-general by date:

Previous
From: M L
Date:
Subject: The tuple structure of a not-yet-assigned record is indeterminate.
Next
From: Greenhorn
Date:
Subject: bash & postgres