pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAre scalar type's in/out functions implicitly STRICT?
5+ messages / 3 participants
[nested] [flat]
* Are scalar type's in/out functions implicitly STRICT?
@ 2003-02-28 00:45 Denis Zaitsev <zzz@cd-club.ru>
0 siblings, 2 replies; 5+ messages in thread
From: Denis Zaitsev @ 2003-02-28 00:45 UTC (permalink / raw)
To: pgsql-sql
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. And this is not
documented, AFAIK. Have I missed something or is it a some hard
well-known etc. fact? Thanks in advance.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Are scalar type's in/out functions implicitly STRICT?
@ 2003-02-28 02:44 Tom Lane <tgl@sss.pgh.pa.us>
parent: Denis Zaitsev <zzz@cd-club.ru>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2003-02-28 02:44 UTC (permalink / raw)
To: Denis Zaitsev <zzz@cd-club.ru>; +Cc: pgsql-sql
Denis Zaitsev <zzz@cd-club.ru> 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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Are scalar type's in/out functions implicitly STRICT?
@ 2003-02-28 03:24 Bruno Wolff III <bruno@wolff.to>
parent: Denis Zaitsev <zzz@cd-club.ru>
1 sibling, 1 reply; 5+ messages in thread
From: Bruno Wolff III @ 2003-02-28 03:24 UTC (permalink / raw)
To: Denis Zaitsev <zzz@cd-club.ru>; +Cc: pgsql-sql
On Fri, Feb 28, 2003 at 05:45:44 +0500,
Denis Zaitsev <zzz@cd-club.ru> wrote:
> 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. And this is not
> documented, AFAIK. Have I missed something or is it a some hard
> well-known etc. fact? Thanks in advance.
Are you using the version one calling sequence?
The version zero method doesn't have a way handle nulls other than by
declaring the function strict.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Are scalar type's in/out functions implicitly STRICT?
@ 2003-03-02 00:40 Denis Zaitsev <zzz@cd-club.ru>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Denis Zaitsev @ 2003-03-02 00:40 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
On Thu, Feb 27, 2003 at 09:44:37PM -0500, Tom Lane wrote:
> Denis Zaitsev <zzz@cd-club.ru> 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.
>
Ok, thanks.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Are scalar type's in/out functions implicitly STRICT?
@ 2003-03-02 00:41 Denis Zaitsev <zzz@cd-club.ru>
parent: Bruno Wolff III <bruno@wolff.to>
0 siblings, 0 replies; 5+ messages in thread
From: Denis Zaitsev @ 2003-03-02 00:41 UTC (permalink / raw)
To: pgsql-sql
On Thu, Feb 27, 2003 at 09:24:44PM -0600, Bruno Wolff III wrote:
> On Fri, Feb 28, 2003 at 05:45:44 +0500,
> Denis Zaitsev <zzz@cd-club.ru> wrote:
> > 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. And this is not
> > documented, AFAIK. Have I missed something or is it a some hard
> > well-known etc. fact? Thanks in advance.
>
> Are you using the version one calling sequence?
Yes, I am - v1.
> The version zero method doesn't have a way handle nulls other than by
> declaring the function strict.
>
Hmm, examples/docs show such a way for v0...
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2003-03-02 00:41 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-02-28 00:45 Are scalar type's in/out functions implicitly STRICT? Denis Zaitsev <zzz@cd-club.ru>
2003-02-28 02:44 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-03-02 00:40 ` Denis Zaitsev <zzz@cd-club.ru>
2003-02-28 03:24 ` Bruno Wolff III <bruno@wolff.to>
2003-03-02 00:41 ` Denis Zaitsev <zzz@cd-club.ru>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox