"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