X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 9D7F84758E6 for ; Thu, 27 Feb 2003 22:32:36 -0500 (EST) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with SMTP id 57928-07 for ; Thu, 27 Feb 2003 22:32:26 -0500 (EST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 4FF1647605A for ; Thu, 27 Feb 2003 21:44:40 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.6/8.12.6) with ESMTP id h1S2ib5u001342; Thu, 27 Feb 2003 21:44:37 -0500 (EST) To: Denis Zaitsev Cc: pgsql-sql@postgresql.org Subject: Re: Are scalar type's in/out functions implicitly STRICT? In-reply-to: <20030228054544.A4208@natasha.zzz.zzz> References: <20030228054544.A4208@natasha.zzz.zzz> Comments: In-reply-to Denis Zaitsev message dated "Fri, 28 Feb 2003 05:45:44 +0500" Date: Thu, 27 Feb 2003 21:44:37 -0500 Message-ID: <1341.1046400277@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new X-Archive-Number: 200302/608 X-Sequence-Number: 12006 Denis Zaitsev writes: > So, I create some new scalar type and I don't declare its in/out > functions as STRICT. But PostgreSQL copes with them such as they > would be STRICT - they never get the NULL value. This is likely true in many places --- for example, COPY has a shortcut because it wants to substitute \N for nulls. It would not be a bright idea to assume that it's true in every place and forevermore. In general, if you have a C function and don't want to be bothered with explicit PG_ISNULL testing, you'd better mark it STRICT. An example of an easy way to crash an I/O function without such guards is to invoke it explicitly: regression=# select textin(null::cstring); textin -------- (1 row) regression=# select textout(null::text); textout --------- (1 row) regards, tom lane