aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-12-20 00:23:19 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-12-20 00:23:19 +0000
commitef6bac332376d3c4d3b8c1954e3c8a8018250d90 (patch)
tree56e702f05475fa0cb4c7719eee17bc986324a7df /src
parent1b1f7e977be44b31af0cd15ed4c3435b5f34bb57 (diff)
downloadpostgresql-ef6bac332376d3c4d3b8c1954e3c8a8018250d90.tar.gz
postgresql-ef6bac332376d3c4d3b8c1954e3c8a8018250d90.zip
When given a nonzero column number, pg_get_indexdef() is only supposed to
print the index key variable or expression for that column. It was mistakenly printing ASC/DESC/NULLS FIRST/NULLS LAST decoration too --- and not only for the target column, but all columns. Someday we should have an option to extract that info (and the opclass decoration as well) for a single index column ... but today is not that day. Per bug #3829 and subsequent discussion.
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/adt/ruleutils.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 8e4d5c90cd3..da6ae839820 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.266 2007/12/01 23:44:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.267 2007/12/20 00:23:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -769,25 +769,28 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, bool showTblSpc,
keycoltype = exprType(indexkey);
}
- /* Add the operator class name */
+ /* Provide decoration only in the colno=0 case */
if (!colno)
+ {
+ /* Add the operator class name, if not default */
get_opclass_name(indclass->values[keyno], keycoltype, &buf);
- /* Add options if relevant */
- if (amrec->amcanorder)
- {
- /* if it supports sort ordering, report DESC and NULLS opts */
- if (opt & INDOPTION_DESC)
- {
- appendStringInfo(&buf, " DESC");
- /* NULLS FIRST is the default in this case */
- if (!(opt & INDOPTION_NULLS_FIRST))
- appendStringInfo(&buf, " NULLS LAST");
- }
- else
+ /* Add options if relevant */
+ if (amrec->amcanorder)
{
- if (opt & INDOPTION_NULLS_FIRST)
- appendStringInfo(&buf, " NULLS FIRST");
+ /* if it supports sort ordering, report DESC and NULLS opts */
+ if (opt & INDOPTION_DESC)
+ {
+ appendStringInfo(&buf, " DESC");
+ /* NULLS FIRST is the default in this case */
+ if (!(opt & INDOPTION_NULLS_FIRST))
+ appendStringInfo(&buf, " NULLS LAST");
+ }
+ else
+ {
+ if (opt & INDOPTION_NULLS_FIRST)
+ appendStringInfo(&buf, " NULLS FIRST");
+ }
}
}
}