Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6906C1337BE4 for ; Thu, 5 May 2011 23:58:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 30254-07 for ; Fri, 6 May 2011 02:58:47 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wy0-f174.google.com (mail-wy0-f174.google.com [74.125.82.174]) by mail.postgresql.org (Postfix) with ESMTP id A822A1337BC4 for ; Thu, 5 May 2011 23:58:44 -0300 (ADT) Received: by wya21 with SMTP id 21so2080192wya.19 for ; Thu, 05 May 2011 19:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=Je66KSiId43TUnDvv55AMC/riaUxVGNSexrdoB7TWZ8=; b=xyeMYi07vY2lNGFbjVOHSXEu6pgn1dttVpWpKokqCVou7NHjBADjzcB3Q04B233nUb LikJkq2TRf85YGc+U2paF6YvJRfjE8DjdKU2ZhSlDNU3dd5vAmbphCKs58yRgqCKPmE5 wKbqBxEW47dMPNimqoj8RMmDeFFkJ3kBtjmjk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=XND07mua7q69J7AXswRJVuwCiGG0hCUwzTXA+nxl4w1x5b/otUEQhVolYWOrJmg26e vYUzf1vDkaSkV+vq6G5aCtOdY0uT4Vy5QI1XslVbY3danwQAq4LXVrCeyF3WhOoX/vQd kMHS1SEtUc3F1/OUgju5flrWTBEpPP+JrjNPo= Received: by 10.216.240.197 with SMTP id e47mr7038033wer.11.1304650724206; Thu, 05 May 2011 19:58:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.121.15 with HTTP; Thu, 5 May 2011 19:58:24 -0700 (PDT) In-Reply-To: <1102.1304649395@sss.pgh.pa.us> References: <1102.1304649395@sss.pgh.pa.us> From: Josh Kupershmidt Date: Thu, 5 May 2011 22:58:24 -0400 Message-ID: Subject: Re: [BUGS] documentation bug - behave of NEW a OLD in plpgsql's triggers To: Tom Lane Cc: Pavel Stehule , pgsql-docs Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201105/16 X-Sequence-Number: 6691 On Thu, May 5, 2011 at 10:36 PM, Tom Lane wrote: > That is, in fact, exactly the behavior you get if you declare a RECORD > variable and set it to NULL. =A0If these variables were indeed not > declared, you'd get a complaint about "new" not being a known variable. Hrm, guess I learned something. I tested with a trigger function which used= : ... IF NEW IS NULL THEN RAISE NOTICE 'new is null.'; ... which was giving me 'ERROR: record "new" is not assigned yet' when used as an on-delete trigger. I am a little surprised that you can't use IS NULL to test out a record-type variable which you've just declared to be NULL, e.g. this function blows up: CREATE OR REPLACE FUNCTION test_trg() RETURNS TRIGGER AS $$ DECLARE SOMEVAR record; BEGIN SOMEVAR :=3D NULL; IF SOMEVAR IS NULL THEN RAISE NOTICE 'somevar is null.'; END IF; RETURN NEW; END; $$ LANGUAGE plpgsql; with the same error message. Josh