pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql 8.4 "not" + "is contained by" operators return wrong result
2+ messages / 2 participants
[nested] [flat]

* pgsql 8.4 "not" + "is contained by" operators return wrong result
@ 2013-07-25 16:41  László Lajos Jánszky <laszlo.janszky@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: László Lajos Jánszky @ 2013-07-25 16:41 UTC (permalink / raw)
  To: pgsql-bugs

*Description:*

By pgsql 8.4 I have the following bug:

If the haystack array is null (for example by empty result of array_agg) by
is contained by, and you use it with negation, the the result is false
instead of true.


*Reproduce:*

The following query returns nothing, but it should return 1.

*SELECT 1 FROM NOT(ARRAY[1] <@ NULL**);  *

*Workaround:*

*SELECT 1 FROM (haystack IS NULL OR NOT(ARRAY[1] <@ **haystack**)); *

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pgsql 8.4 "not" + "is contained by" operators return wrong result
@ 2013-07-25 17:15  Tom Lane <tgl@sss.pgh.pa.us>
  parent: László Lajos Jánszky <laszlo.janszky@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2013-07-25 17:15 UTC (permalink / raw)
  To: László Lajos Jánszky <laszlo.janszky@gmail.com>; +Cc: pgsql-bugs

=?ISO-8859-1?Q?L=E1szl=F3_Lajos_J=E1nszky?= <laszlo.janszky@gmail.com> writes:
> The following query returns nothing, but it should return 1.
> *SELECT 1 FROM NOT(ARRAY[1] <@ NULL**);  *

I assume you meant SELECT 1 WHERE NOT(ARRAY[1] <@ NULL) ?
Because what you wrote doesn't parse.

This is not a bug.  "ARRAY[1] <@ NULL" yields NULL.  NOT (NULL) is still
NULL.  WHERE treats a NULL result as FALSE.

It might help you to consider that NULL means "unknown".  It does not
mean "empty array".

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2013-07-25 17:15 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-07-25 16:41 pgsql 8.4 "not" + "is contained by" operators return wrong result László Lajos Jánszky <laszlo.janszky@gmail.com>
2013-07-25 17:15 ` Tom Lane <tgl@sss.pgh.pa.us>

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