public inbox for [email protected]  
help / color / mirror / Atom feed
From: Josh Kupershmidt <[email protected]>
To: Pavel Stehule <[email protected]>
Cc: pgsql-docs <[email protected]>
Subject: Re: documentation bug - behave of NEW a OLD in plpgsql's triggers
Date: Thu, 5 May 2011 20:56:36 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

[Moving to -docs]

On Mon, May 2, 2011 at 12:00 PM, Pavel Stehule <[email protected]> wrote:
> Hello
>
> one czech user reported a bug in documentation -
> http://www.postgresql.org/docs/8.4/static/plpgsql-trigger.html
>
> NEW
>
>    Data type RECORD; variable holding the new database row for
> INSERT/UPDATE operations in row-level triggers. This variable is NULL
> in statement-level triggers and for DELETE operations.
> OLD
>
>    Data type RECORD; variable holding the old database row for
> UPDATE/DELETE operations in row-level triggers. This variable is NULL
> in statement-level triggers and for INSERT operations.
>
> It isn't correct. NEW is not declared in DELETE trigger, OLD isn't
> declared in INSERT

If I've understood you correctly, the problem is that the docs claim
that the variables are defined with a value of NULL, when in fact they
are undefined. For example, if you try to use variable NEW in a delete
trigger, you'll get an error message like:
|  ERROR:  record "new" is not assigned yet
|  DETAIL:  The tuple structure of a not-yet-assigned record is indeterminate.

How about a doc tweak like the attached?

Josh


Attachments:

  [text/x-patch] plpgsql_triggers.patch (1.7K, 2-plpgsql_triggers.patch)
  download | inline diff:
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index 1866e43..6b6cf37 100644
*** a/doc/src/sgml/plpgsql.sgml
--- b/doc/src/sgml/plpgsql.sgml
*************** RAISE unique_violation USING MESSAGE = '
*** 3279,3286 ****
        <para>
         Data type <type>RECORD</type>; variable holding the new
         database row for <command>INSERT</>/<command>UPDATE</> operations in row-level
!        triggers. This variable is <symbol>NULL</symbol> in statement-level triggers
!        and for <command>DELETE</command> operations.
        </para>
       </listitem>
      </varlistentry>
--- 3279,3286 ----
        <para>
         Data type <type>RECORD</type>; variable holding the new
         database row for <command>INSERT</>/<command>UPDATE</> operations in row-level
!        triggers. This variable is not defined in statement-level triggers
!        or <command>DELETE</command> operations.
        </para>
       </listitem>
      </varlistentry>
*************** RAISE unique_violation USING MESSAGE = '
*** 3291,3298 ****
        <para>
         Data type <type>RECORD</type>; variable holding the old
         database row for <command>UPDATE</>/<command>DELETE</> operations in row-level
!        triggers. This variable is <symbol>NULL</symbol> in statement-level triggers
!        and for <command>INSERT</command> operations.
        </para>
       </listitem>
      </varlistentry>
--- 3291,3298 ----
        <para>
         Data type <type>RECORD</type>; variable holding the old
         database row for <command>UPDATE</>/<command>DELETE</> operations in row-level
!        triggers. This variable is not defined in statement-level triggers
!        or <command>INSERT</command> operations.
        </para>
       </listitem>
      </varlistentry>


view thread (11+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: documentation bug - behave of NEW a OLD in plpgsql's triggers
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox