X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 69A7FD1C512 for ; Fri, 1 Aug 2003 06:30:43 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 22627-04 for ; Fri, 1 Aug 2003 03:29:37 -0300 (ADT) Received: from megazone.bigpanda.com (45.mufb.snfc.sffca01r18.dsl.att.net [12.103.249.45]) by svr1.postgresql.org (Postfix) with ESMTP id 95EFDD1C510 for ; Fri, 1 Aug 2003 03:30:36 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 5A5E4D62E; Thu, 31 Jul 2003 23:30:36 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 5014E5C10; Thu, 31 Jul 2003 23:30:36 -0700 (PDT) Date: Thu, 31 Jul 2003 23:30:36 -0700 (PDT) From: Stephan Szabo To: maillist Cc: "pgsql-admin@postgresql.org" Subject: Re: fyi In-Reply-To: <3F2A05C7.4C171687@tnss.com> Message-ID: <20030731232208.G38816-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/10 X-Sequence-Number: 9733 On Fri, 1 Aug 2003, maillist wrote: > Stephan Szabo wrote: > > > > On Thu, 31 Jul 2003, maillist wrote: > > > > > select * from apps where (not apppag = null); > > > returns nothing when it should return every thing > > > > No. It should return nothing. apppag = null returns unknown for every > > row. Use IS NULL to test if a value is null. > hmmm now i'm confused when i set a value i don't use the phrase to null > and '= null' has always worked in the past, and if '= null' doesn't work > it should be an invalid query because i can see no other use for it, and > for the most part is, to are ignored anyways. Old versions converted an explicit token sequence like = NULL into IS NULL for you (due to broken clients). Newer versions have a compatibility GUC configuration option transform_null_equals which turns it on (which I usually forget about). However, the option should generally be discouraged because it is inconsistent (= NULL is converted, but comparing two variables where the second is NULL does not for example and not foo=null works but foo!=null doesn't). The change was made to better fit the SQL specification. As for =NULL in general, it's pretty meaningless but meets our syntactic constraints. > so would the correct query be > select * from apps where (not apppag = is null) > or > select * from apps where (not apppag is null) Actually since you're doing not, I'd suggest where (apppag is not null) > both of these look silly, but I do use null in other fields on purpuse > to represent uninitailized fields. So I definitlay am going to have to > grep my code for "=*null" and check to see what needs to be done. Ijust > thought it was a bug, that should not have been found, because the query > had un needed checks. I need to do more testing before I allow > production servers to upgrade You can turn on the option as a short term thing, although I'd suggest changing the queries in any case.