Re: [SQL] Howto to force NULL rows at the bottom ?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Stoyan Genov <genov(at)digsys(dot)bg>, Dirk Lutzebaeck <lutzeb(at)aeccom(dot)com>, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Howto to force NULL rows at the bottom ?
Date: 1999-12-06 03:34:20
Message-ID: 199912060334.WAA25609@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message cristiv 1999-12-06 03:38:04 (no subject)
Previous Message Tom Lane 1999-12-06 03:08:27 Re: [SQL] Howto to force NULL rows at the bottom ?