aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 8a6d0ad9661..f6987001533 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -950,7 +950,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty)
*
* Note that the SQL-function versions of this omit any info about the
* index tablespace; this is intentional because pg_dump wants it that way.
- * However pg_get_indexdef_string() includes index tablespace if not default.
+ * However pg_get_indexdef_string() includes the index tablespace.
* ----------
*/
Datum
@@ -982,7 +982,11 @@ pg_get_indexdef_ext(PG_FUNCTION_ARGS)
prettyFlags)));
}
-/* Internal version that returns a palloc'd C string; no pretty-printing */
+/*
+ * Internal version for use by ALTER TABLE.
+ * Includes a tablespace clause in the result.
+ * Returns a palloc'd C string; no pretty-printing.
+ */
char *
pg_get_indexdef_string(Oid indexrelid)
{
@@ -1231,20 +1235,19 @@ pg_get_indexdef_worker(Oid indexrelid, int colno,
}
/*
- * If it's in a nondefault tablespace, say so, but only if requested
+ * Print tablespace, but only if requested
*/
if (showTblSpc)
{
Oid tblspc;
tblspc = get_rel_tablespace(indexrelid);
- if (OidIsValid(tblspc))
- {
- if (isConstraint)
- appendStringInfoString(&buf, " USING INDEX");
- appendStringInfo(&buf, " TABLESPACE %s",
- quote_identifier(get_tablespace_name(tblspc)));
- }
+ if (!OidIsValid(tblspc))
+ tblspc = MyDatabaseTableSpace;
+ if (isConstraint)
+ appendStringInfoString(&buf, " USING INDEX");
+ appendStringInfo(&buf, " TABLESPACE %s",
+ quote_identifier(get_tablespace_name(tblspc)));
}
/*