dbTalk Databases Forums  

[BUGS] BUG #1591: BETWEEN NULL AND NULL causes crash

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #1591: BETWEEN NULL AND NULL causes crash in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Williamson
 
Posts: n/a

Default [BUGS] BUG #1591: BETWEEN NULL AND NULL causes crash - 04-10-2005 , 02:25 PM







The following bug has been logged online:

Bug reference: 1591
Logged by: Michael Williamson
Email address: michael.williamson (AT) caseware (DOT) com
PostgreSQL version: 8.0.1
Operating system: Windows 2000
Description: BETWEEN NULL AND NULL causes crash
Details:

Hello,

I have the following query:

SELECT * FROM Entities
WHERE NULL IS NULL OR (EntityNo BETWEEN NULL AND COALESCE(NULL,NULL))

This causes one of two results: postmaster crashes or goes into an infinite
loop. The reason I have such a strange query is because values are filled
in from a dialog. It looks more like:

SELECT * FROM Entities
WHERE %p1 IS NULL OR (EntityNo BETWEEN %p1 AND COALESCE(%p2,%p1))

This query executes ok on other dbs (mssql, mysql) and returns the correct
result (all records). I can fix it for postgre by doing:

SELECT * FROM Entities
WHERE NULL IS NULL OR (EntityNo BETWEEN NULL AND COALESCE(NULL,NULL,''))

But none the less nothing should make it loop infinitely or crash.

Thanks

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #1591: BETWEEN NULL AND NULL causes crash - 04-10-2005 , 04:03 PM






"Michael Williamson" <michael.williamson (AT) caseware (DOT) com> writes:
Quote:
SELECT * FROM Entities
WHERE NULL IS NULL OR (EntityNo BETWEEN NULL AND COALESCE(NULL,NULL))
This causes one of two results: postmaster crashes or goes into an infinite
loop.
Good catch. COALESCE(NULL,NULL) is actually broken as far back as 7.4,
though I'm not sure if the error is visible in that version. If you
need the patch it's

Index: clauses.c
================================================== =================
RCS file: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v
retrieving revision 1.186.4.2
diff -c -r1.186.4.2 clauses.c
*** clauses.c 2 Feb 2005 21:49:43 -0000 1.186.4.2
--- clauses.c 10 Apr 2005 20:54:52 -0000
***************
*** 1771,1776 ****
--- 1771,1780 ----
newargs = lappend(newargs, e);
}

+ /* If all the arguments were constant null, the result is just null */
+ if (newargs == NIL)
+ return (Node *) makeNullConst(coalesceexpr->coalescetype);
+
newcoalesce = makeNode(CoalesceExpr);
newcoalesce->coalescetype = coalesceexpr->coalescetype;
newcoalesce->args = newargs;


regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.