Received: from candle.pha.pa.us (pgman@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id WAA33546 for ; Sun, 5 Dec 1999 22:35:38 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id WAA25609; Sun, 5 Dec 1999 22:34:21 -0500 (EST) From: Bruce Momjian Message-Id: <199912060334.WAA25609@candle.pha.pa.us> Subject: Re: [SQL] Howto to force NULL rows at the bottom ? In-Reply-To: <14623.944449707@sss.pgh.pa.us> from Tom Lane at "Dec 5, 1999 10:08:27 pm" To: Tom Lane Date: Sun, 5 Dec 1999 22:34:20 -0500 (EST) CC: Hiroshi Inoue , Peter Eisentraut , Stoyan Genov , Dirk Lutzebaeck , pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL65 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > I am not sure how we can resolve this. btree cannot easily work > differently than it does --- we could make either choice for where nulls > appear in the index, but once we've done that we have no real choice > about what ORDER BY on the index will do, in either direction. So > it seems that we really do need to make nulls sort differently in > ASC and DESC sorts. But the explicit-sort routine has no idea whether > ASC or DESC is involved ... indeed can't, because we may have a > "USING operator" clause in there and no ASC or DESC anywhere. Shall > explicit-sort try to guess whether the operator it's given represents > the fore or aft direction of a btree index? The operator might not be > one that is btree-indexable at all, so I don't see how that can work. We are pretty cheezy about using > and < for ORDER BY. Any chance to look up the actual comparison symbol from the cache and do something based on "<" or ">"? Do we have a pg_operator oid or something else there? If it is not one of those, we can just order them however we want to. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026