X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 00578D8357 for ; Thu, 8 Sep 2005 05:09:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17807-10 for ; Thu, 8 Sep 2005 08:09:14 +0000 (GMT) Received: from floppy.pyrenet.fr (floppy.pyrenet.fr [194.116.145.2]) by svr1.postgresql.org (Postfix) with ESMTP id 775DBD7796 for ; Thu, 8 Sep 2005 05:09:14 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id E16D031F81; Thu, 8 Sep 2005 10:09:15 +0200 (MET DST) From: "Bjoern A. Zeeb" X-Newsgroups: pgsql.sql Subject: user defined type, plpgsql function and NULL Date: Thu, 8 Sep 2005 08:09:13 +0000 (UTC) Organization: Zabbadoz.NeT Lines: 64 Message-ID: X-Complaints-To: usenet@news.germany.com User-Agent: tin/1.7.7-20041215 ("Scalpay") (UNIX) (FreeBSD/5.3-BETA7 (sparc64)) To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.207 required=5 tests=[UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200509/137 X-Sequence-Number: 22684 Hi, let's say one has an user defined data type CREATE TYPE foobar_t AS ( va varchar(25), vb varchar(4), vc varchar(20), ia integer, ib integer ); and a stored procedure in plgpsql (stripped and sample only): CREATE OR REPLACE FUNCTION foobar(int, foobar_t, int, varchar) RETURNS INT AS' DECLARE ia ALIAS FOR $1; fbt ALIAS FOR $2; ib ALIAS FOR $3; vc ALIAS FOR $4; BEGIN ... IF fbt IS NULL THEN RAISE NOTICE ''fbt IS NULL;''; ELSE RAISE NOTICE ''fbt IS NOT NULL... ''; IF fbt.va IS NULL THEN RAISE NOTICE ''fbt.va IS NULL;''; ELSE RAISE NOTICE ''fbt.va = %'', fbt.va; END IF; ... END IF; ... RETURN 0; END' LANGUAGE plpgsql; If one does a SELECT foobar(1, NULL, 2, 'end'); NOTICE: ia = 1 NOTICE: fbt IS NOT NULL... NOTICE: fbt.va IS NULL; NOTICE: fbt.vb IS NULL; NOTICE: fbt.vc IS NULL; NOTICE: fbt.ia IS NULL; NOTICE: fbt.ib IS NULL; NOTICE: ib = 2 NOTICE: vc = end foobar -------- 0 (1 row) Note the second argument foobar_t is given as NULL but $2 IS NOT NULL. I cannot find anything about this in the docs but I asume that the single NULL will implicitly set all attributes to NULL? Is this correct or is it just a "works like that this time but may change at any time in the future"? -- Greetings Bjoern A. Zeeb