summaryrefslogtreecommitdiff
path: root/src/backend/nodes/outfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-01-09 02:14:16 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-01-09 02:14:16 +0000
commit443175822942ef1f15cd047cda58990a089ef180 (patch)
treea5e4272719d3323d9aa17312d0d867804b652f10 /src/backend/nodes/outfuncs.c
parent3a32ba2f3f54378e3e06366a5ff06e339984f065 (diff)
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.
Diffstat (limited to 'src/backend/nodes/outfuncs.c')
-rw-r--r--src/backend/nodes/outfuncs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index 8f341daf9da..1ffaa08dfe9 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.291 2007/01/05 22:19:30 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.292 2007/01/09 02:14:12 tgl Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
@@ -510,6 +510,10 @@ _outSort(StringInfo str, Sort *node)
appendStringInfo(str, " :sortOperators");
for (i = 0; i < node->numCols; i++)
appendStringInfo(str, " %u", node->sortOperators[i]);
+
+ appendStringInfo(str, " :nullsFirst");
+ for (i = 0; i < node->numCols; i++)
+ appendStringInfo(str, " %s", booltostr(node->nullsFirst[i]));
}
static void
@@ -1265,6 +1269,7 @@ _outPathKeyItem(StringInfo str, PathKeyItem *node)
WRITE_NODE_FIELD(key);
WRITE_OID_FIELD(sortop);
+ WRITE_BOOL_FIELD(nulls_first);
}
static void
@@ -1499,6 +1504,8 @@ _outIndexElem(StringInfo str, IndexElem *node)
WRITE_STRING_FIELD(name);
WRITE_NODE_FIELD(expr);
WRITE_NODE_FIELD(opclass);
+ WRITE_ENUM_FIELD(ordering, SortByDir);
+ WRITE_ENUM_FIELD(nulls_ordering, SortByNulls);
}
static void
@@ -1565,6 +1572,7 @@ _outSortClause(StringInfo str, SortClause *node)
WRITE_UINT_FIELD(tleSortGroupRef);
WRITE_OID_FIELD(sortop);
+ WRITE_BOOL_FIELD(nulls_first);
}
static void
@@ -1574,6 +1582,7 @@ _outGroupClause(StringInfo str, GroupClause *node)
WRITE_UINT_FIELD(tleSortGroupRef);
WRITE_OID_FIELD(sortop);
+ WRITE_BOOL_FIELD(nulls_first);
}
static void