Re: date bug - Mailing list pgsql-bugs

From Tom Lane
Subject Re: date bug
Date
Msg-id 28774.990053980@sss.pgh.pa.us
Whole thread Raw
In response to date bug  ("Jeff Patterson" <jpat@mywayhealth.com>)
List pgsql-bugs
"Jeff Patterson" <jpat@mywayhealth.com> writes:
> Strange date behavior as shown below.

This is not a date bug; it's your misunderstanding of how SQL functions
work.  A function that returns a scalar can only return one result, so
it makes no sense to try to define its result as a SELECT from a
multi-row table.

As it happens, what you get is the result from the first row returned
by the SELECT.  (Personally I'd have thought it'd make more sense to
raise an error if the SELECT returns multiple rows, but we'd probably
break existing applications if we changed it.)

Perhaps you want something on the order of

    SELECT EXISTS(SELECT 1 FROM holidays WHERE date = $1)

            regards, tom lane

pgsql-bugs by date:

Previous
From: "Jonathan Ellis"
Date:
Subject: Re: orphaned trigger
Next
From: Stephan Szabo
Date:
Subject: Re: orphaned trigger