pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedBOOLEAN data type?
5+ messages / 3 participants
[nested] [flat]
* BOOLEAN data type?
@ 2001-04-13 16:08 Josh Berkus <josh@agliodbs.com>
2001-04-13 16:52 ` Re: BOOLEAN data type? Peter Eisentraut <peter_e@gmx.net>
2001-04-14 18:32 ` Re: BOOLEAN data type? Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 5+ messages in thread
From: Josh Berkus @ 2001-04-13 16:08 UTC (permalink / raw)
To: pgsql-sql
Folks:
I had assumed that the BOOL column type was a tru boolean. That is, I
wrote some functions on the understand that, given table def:
CREATE TABLE order_details (
order_detail_id SERIAL NOT NULL PRIMARY KEY,
detail_id INT4 NOT NULL,
order_usq INT4 NOT NULL,
detail_required BOOL DEFAULT FALSE );
That the following query:
SELECT detail_id FROM order_detials
WHERE order_usq = 7703 AND detail_required;
... should be equivalent to:
SELECT detail_id FROM order_detials
WHERE order_usq = 7703 AND detail_required = TRUE;
However, in testing (7.1 RC2), the query turned out to mean this:
SELECT detail_id FROM order_detials
WHERE order_usq = 7703 AND detail_required IS NOT NULL;
... throwing off a lot of my results until I figured it out.
Can someone explain this to me? I thought the whole point of a BOOL
data type was that it could be treated as a Boolean value, and used for
testing and comparison without and "= TRUE" or "= FALSE". What's going
on here?
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BOOLEAN data type?
2001-04-13 16:08 BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
@ 2001-04-13 16:52 ` Peter Eisentraut <peter_e@gmx.net>
2001-04-14 22:09 ` Re: BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
1 sibling, 1 reply; 5+ messages in thread
From: Peter Eisentraut @ 2001-04-13 16:52 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
Josh Berkus writes:
> That the following query:
>
> SELECT detail_id FROM order_detials
> WHERE order_usq = 7703 AND detail_required;
>
> ... should be equivalent to:
>
> SELECT detail_id FROM order_detials
> WHERE order_usq = 7703 AND detail_required = TRUE;
>
> However, in testing (7.1 RC2), the query turned out to mean this:
>
> SELECT detail_id FROM order_detials
> WHERE order_usq = 7703 AND detail_required IS NOT NULL;
No way. You're doing something wrong. How about showing the data that
makes you believe this?
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BOOLEAN data type?
2001-04-13 16:08 BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
2001-04-13 16:52 ` Re: BOOLEAN data type? Peter Eisentraut <peter_e@gmx.net>
@ 2001-04-14 22:09 ` Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 5+ messages in thread
From: Josh Berkus @ 2001-04-14 22:09 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
Peter,
> No way. You're doing something wrong. How about showing the data
> that
> makes you believe this?
Hey, take it easy. It was only a technical question / potential issue.
Not a personal criticism.
Based on your implied assertion that the queries *should* be working in
a Boolean fashion, I took them apart and re-built them ... and it turned
out to be a data problem in a linked table (a unique index was dropped
somehow without my awareness while altering the tables).
So Booleans are working properly, and you can relax now.
-Josh Berkus
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BOOLEAN data type?
2001-04-13 16:08 BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
@ 2001-04-14 18:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-04-14 22:12 ` Re: BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2001-04-14 18:32 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
"Josh Berkus" <josh@agliodbs.com> writes:
> Can someone explain this to me?
Are you taking into account that SQL booleans are actually three-valued?
They can be TRUE, FALSE, or NULL (NULL taken as meaning "don't know").
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: BOOLEAN data type?
2001-04-13 16:08 BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
2001-04-14 18:32 ` Re: BOOLEAN data type? Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-04-14 22:12 ` Josh Berkus <josh@agliodbs.com>
0 siblings, 0 replies; 5+ messages in thread
From: Josh Berkus @ 2001-04-14 22:12 UTC (permalink / raw)
To: pgsql-sql
Tom,
> Are you taking into account that SQL booleans are actually
> three-valued?
> They can be TRUE, FALSE, or NULL (NULL taken as meaning "don't
> know").
That turned out not to be the issue, but that's good information to
have. I'll need to remember to make all of my BOOLEAN columns NOT NULL
DEFAULT FALSE.
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2001-04-14 22:12 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-04-13 16:08 BOOLEAN data type? Josh Berkus <josh@agliodbs.com>
2001-04-13 16:52 ` Peter Eisentraut <peter_e@gmx.net>
2001-04-14 22:09 ` Josh Berkus <josh@agliodbs.com>
2001-04-14 18:32 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-04-14 22:12 ` Josh Berkus <josh@agliodbs.com>
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