pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feed(no subject)
5+ messages / 5 participants
[nested] [flat]
* (no subject)
@ 2002-03-11 10:26 Bhuvan A <bhuvansql@yahoo.com>
0 siblings, 3 replies; 5+ messages in thread
From: Bhuvan A @ 2002-03-11 10:26 UTC (permalink / raw)
To: pgsql-bugs
On Mar 11, Stephan Szabo wrote:
>
> On Mon, 11 Mar 2002, Bhuvan A wrote:
>
> >
> >
> > On Mar 10, Stephan Szabo wrote:
> >
> > > On Mon, 11 Mar 2002, Bhuvan A wrote:
> > >
> > > > here i have a problem in comparing null values in plpgsql. this exist
> > > > in 7.1.x and 7.2 as well.
> > > >
> > > > the condition <null value> != <valid value> fails in plpgsql.
> > > > consider this function is triggered on every updation on a table.
> > > >
> > > > create function ftest()
> > > > returns opaque as 'declare
> > > >
> > > > begin
> > > >
> > > > if new.comp_code != old.comp_code then
> > > > ...
> > > > end if;
> > > > return new;
> > > > end;'
> > > > language 'plpgsql';
> > > >
> > > > this condition fails if old.comp_code is null and new.comp_code has
> > > > some value.
> > >
> > > <nullvalue> != <anything> is not true, it's unknown, so the if shouldn't
> >
> > what do you mean by <nullvalue> != <anything>?
>
> If you compare a NULL with anything you don't get a true value whether
> you're comparing with =, !=, <, >, etc... That's how it's defined to
> behave.
where did you get this definition of behaviour!? is it applicable only to
postgres or ..? its quite strange yaar!
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re:
@ 2002-03-11 14:33 Yury Bokhoncovich <byg@center-f1.ru>
parent: Bhuvan A <bhuvansql@yahoo.com>
2 siblings, 0 replies; 5+ messages in thread
From: Yury Bokhoncovich @ 2002-03-11 14:33 UTC (permalink / raw)
To: Bhuvan A <bhuvansql@yahoo.com>; +Cc: pgsql-bugs
Hello!
On Mon, 11 Mar 2002, Bhuvan A wrote:
[skip]
> > If you compare a NULL with anything you don't get a true value whether
> > you're comparing with =, !=, <, >, etc... That's how it's defined to
> > behave.
>
> where did you get this definition of behaviour!? is it applicable only to
> postgres or ..? its quite strange yaar!
it's standard SQL:
true and true gives true
true and false gives false
null and true gives null
null and false gives null
RTFM! Quick check on MySQL and MSSQL gives the same results.
AFAIK Interbase and Oracle behaves similarly.
So theory is confirmed by practice.
It is very amazing to listen about contrary thing, could you please tell
where you saw this?
--
WBR, Yury Bokhoncovich, Senior System Administrator, NOC of F1 Group.
Phone: +7 (3832) 106228, ext.140, E-mail: byg@center-f1.ru.
Unix is like a wigwam -- no Gates, no Windows, and an Apache inside.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re:
@ 2002-03-11 16:46 Peter Eisentraut <peter_e@gmx.net>
parent: Bhuvan A <bhuvansql@yahoo.com>
2 siblings, 0 replies; 5+ messages in thread
From: Peter Eisentraut @ 2002-03-11 16:46 UTC (permalink / raw)
To: Bhuvan A <bhuvansql@yahoo.com>; +Cc: pgsql-bugs
Bhuvan A writes:
> > If you compare a NULL with anything you don't get a true value whether
> > you're comparing with =, !=, <, >, etc... That's how it's defined to
> > behave.
>
> where did you get this definition of behaviour!? is it applicable only to
> postgres or ..? its quite strange yaar!
It's how the SQL standard defines it. If other database software claims
to comply to SQL it should also behave that way. (Before you complain
about the SQL standard, its definition was adopted from the common
mathematical notion of three-valued Boolean logic.)
If you want
a <> b
to return true if one of a and b is NULL and the other is not NULL then
you will have to do a bit more work. For example,
(a <> b) or (a is null and b is not null) or (a is not null and b is null)
--
Peter Eisentraut peter_e@gmx.net
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re:
@ 2002-03-11 17:02 Stephan Szabo <sszabo@megazone23.bigpanda.com>
parent: Bhuvan A <bhuvansql@yahoo.com>
2 siblings, 1 reply; 5+ messages in thread
From: Stephan Szabo @ 2002-03-11 17:02 UTC (permalink / raw)
To: Bhuvan A <bhuvansql@yahoo.com>; +Cc: pgsql-bugs
On Mon, 11 Mar 2002, Bhuvan A wrote:
> > If you compare a NULL with anything you don't get a true value whether
> > you're comparing with =, !=, <, >, etc... That's how it's defined to
> > behave.
>
> where did you get this definition of behaviour!? is it applicable only to
> postgres or ..? its quite strange yaar!
It makes sense if you think of NULL as an unknown value. You don't know
if this unknown value is different from any particular value (even another
NULL). NULLs are one of the ugliest parts of SQL.
In case you're wondering for SQL92 (at least the draft I have), the
section is 8.2 <comparison predicate>, General Rules 1.
1) Let X and Y be any two corresponding <row value constructor
element>s. Let XV and YV be the values represented by X and Y,
respectively.
Case:
a) If XV or YV is the null value, then "X <comp op> Y" is un-
known.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re:
@ 2002-03-11 20:12 Juliano Ignacio <jsignacio@yahoo.com>
parent: Stephan Szabo <sszabo@megazone23.bigpanda.com>
0 siblings, 0 replies; 5+ messages in thread
From: Juliano Ignacio @ 2002-03-11 20:12 UTC (permalink / raw)
To: Bhuvan A <bhuvansql@yahoo.com>; +Cc: pgsql-bugs
On Mon, 11 Mar 2002, Bhuvan A wrote:
> If you compare a NULL with anything you don't
> get a true value whether you're comparing with
> =, !=, <, >, etc... That's how it's defined to
> behave.
>
> where did you get this definition of behaviour!?
> is it applicable only to
> postgres or ..? its quite strange yaar!
I think that you are searching for a solution, so,
view the COALESCE SQL function in PostgreSQL
documentation. It will help you in your compares.
Juliano S. Ignacio
jsignacio@yahoo.com
__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2002-03-11 20:12 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-11 10:26 Bhuvan A <bhuvansql@yahoo.com>
2002-03-11 14:33 ` Re: Yury Bokhoncovich <byg@center-f1.ru>
2002-03-11 16:46 ` Re: Peter Eisentraut <peter_e@gmx.net>
2002-03-11 17:02 ` Re: Stephan Szabo <sszabo@megazone23.bigpanda.com>
2002-03-11 20:12 ` Re: Juliano Ignacio <jsignacio@yahoo.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