mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Support ORDER BY ... NULLS FIRST/LAST, and add ASC/DESC/NULLS FIRST/NULLS LAST
per-column options for btree indexes. The planner's support for this is still pretty rudimentary; it does not yet know how to plan mergejoins with nondefault ordering options. The documentation is pretty rudimentary, too. I'll work on improving that stuff later. Note incompatible change from prior behavior: ORDER BY ... USING will now be rejected if the operator is not a less-than or greater-than member of some btree opclass. This prevents less-than-sane behavior if an operator that doesn't actually define a proper sort ordering is selected.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.227 2007/01/05 22:19:32 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.228 2007/01/09 02:14:13 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -1147,7 +1147,7 @@ has_distinct_on_clause(Query *query)
|
||||
continue; /* we can ignore unsorted junk cols */
|
||||
return true; /* definitely not in DISTINCT list */
|
||||
}
|
||||
if (targetIsInSortList(tle, query->distinctClause))
|
||||
if (targetIsInSortList(tle, InvalidOid, query->distinctClause))
|
||||
{
|
||||
if (tle->resjunk)
|
||||
return true; /* junk TLE in DISTINCT means DISTINCT ON */
|
||||
@@ -1158,7 +1158,7 @@ has_distinct_on_clause(Query *query)
|
||||
/* This TLE is not in DISTINCT list */
|
||||
if (!tle->resjunk)
|
||||
return true; /* non-junk, non-DISTINCT, so DISTINCT ON */
|
||||
if (targetIsInSortList(tle, query->sortClause))
|
||||
if (targetIsInSortList(tle, InvalidOid, query->sortClause))
|
||||
return true; /* sorted, non-distinct junk */
|
||||
/* unsorted junk is okay, keep looking */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user