summaryrefslogtreecommitdiff
path: root/src/backend/tcop/utility.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2012-12-01 14:27:30 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2012-12-01 14:27:30 -0500
commit7b90469b71761d240bf5efe3ad5bbd228429278e (patch)
tree96ea25cfed788dcb24d897c7898e09799a1b1efb /src/backend/tcop/utility.c
parent452739df82f3cf8f061520a0bdd0af892423652f (diff)
Allow adding values to an enum type created in the current transaction.
Normally it is unsafe to allow ALTER TYPE ADD VALUE in a transaction block, because instances of the value could be added to indexes later in the same transaction, and then they would still be accessible even if the transaction rolls back. However, we can allow this if the enum type itself was created in the current transaction, because then any such indexes would have to go away entirely on rollback. The reason for allowing this is to support pg_upgrade's new usage of pg_restore --single-transaction: in --binary-upgrade mode, pg_dump emits enum types as a succession of ALTER TYPE ADD VALUE commands so that it can preserve the values' OIDs. The support is a bit limited, so we'll leave it undocumented. Andres Freund
Diffstat (limited to 'src/backend/tcop/utility.c')
-rw-r--r--src/backend/tcop/utility.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index 491bd29a1c6..a42b8e9b535 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -972,14 +972,7 @@ standard_ProcessUtility(Node *parsetree,
case T_AlterEnumStmt: /* ALTER TYPE (enum) */
if (isCompleteQuery)
EventTriggerDDLCommandStart(parsetree);
-
- /*
- * We disallow this in transaction blocks, because we can't cope
- * with enum OID values getting into indexes and then having their
- * defining pg_enum entries go away.
- */
- PreventTransactionChain(isTopLevel, "ALTER TYPE ... ADD");
- AlterEnum((AlterEnumStmt *) parsetree);
+ AlterEnum((AlterEnumStmt *) parsetree, isTopLevel);
break;
case T_ViewStmt: /* CREATE VIEW */