boolean function return values - Mailing list pgsql-general

From Eugene Barlow
Subject boolean function return values
Date
Msg-id 1092246088.28529.8.camel@legolas
Whole thread Raw
Responses Re: boolean function return values  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Can someone explain why I would get different results when using "WHERE
x()"  v.s. using "WHERE x() = true" for functions that return a
boolean?  We have also seen the query optimizer behave differently
between the two uses when using functional indices.

I am using postgres 7.4.2 and here are the real details:

CREATE OR REPLACE FUNCTION validlivesitecontent(text, text, integer)
RETURNS boolean
    AS '
DECLARE
   Publisher ALIAS for $1;
   ContentType ALIAS for $2;
   Status ALIAS for $3;
BEGIN
   return (Status & 3 = 0) and (Publisher != ''DataSource'' and
ContentType != ''Packages'' and ContentType != ''SpecialDeals'');
END;
'
    LANGUAGE plpgsql IMMUTABLE STRICT;


user1=# select count(*) from t_content where
validlivesitecontent(publisher, contenttype, status);
 count
--------
 770403
(1 row)

user1=# select count(*) from t_content where
validlivesitecontent(publisher, contenttype, status) = true;
  count
---------
 1258365
(1 row)



Thanks!
--Eugene Barlow
TripAdvisor - www.tripadvisor.com



pgsql-general by date:

Previous
From: Chris Travers
Date:
Subject: Re: Losing records when server hang
Next
From: "Ismail Seyfi"
Date:
Subject: pgcrypto/encrypt insertion failes due to \\ (2 slah being next to each other)