diff options
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 77 |
1 files changed, 57 insertions, 20 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 90a5238..0f79c81 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -785,10 +785,6 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId, } else if (stmt->partbound) { - /* - * For partitions, when no other tablespace is specified, we default - * the tablespace to the parent partitioned table's. - */ Assert(list_length(inheritOids) == 1); tablespaceId = get_rel_tablespace(linitial_oid(inheritOids)); } @@ -6802,6 +6798,9 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel, TupleDesc tupdesc; FormData_pg_attribute *aattr[] = {&attribute}; + /* since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + /* At top level, permission check was done in ATPrepCmd, else do it */ if (recursing) ATSimplePermissions((*cmd)->subtype, rel, ATT_TABLE | ATT_FOREIGN_TABLE); @@ -8517,6 +8516,10 @@ ATExecDropColumn(List **wqueue, Relation rel, const char *colName, /* Initialize addrs on the first invocation */ Assert(!recursing || addrs != NULL); + + /* since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + if (!recursing) addrs = new_object_addresses(); @@ -10974,6 +10977,9 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, Oid refrelid; bool changed = false; + /* since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + currcon = (Form_pg_constraint) GETSTRUCT(contuple); conoid = currcon->oid; refrelid = currcon->confrelid; @@ -11981,6 +11987,9 @@ ATExecDropConstraint(Relation rel, const char *constrName, bool is_no_inherit_constraint = false; char contype; + /* since this function recurses, it could be driven to stack overflow */ + check_stack_depth(); + /* At top level, permission check was done in ATPrepCmd, else do it */ if (recursing) ATSimplePermissions(AT_DropConstraint, rel, ATT_TABLE | ATT_FOREIGN_TABLE); @@ -12722,8 +12731,29 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, RememberConstraintForRebuilding(foundObject.objectId, tab); break; + case OCLASS_PROC: + + /* + * A new-style SQL function can depend on a column, if that + * column is referenced in the parsed function body. Ideally + * we'd automatically update the function by deparsing and + * reparsing it, but that's risky and might well fail anyhow. + * FIXME someday. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter type of a column used by a function or procedure"), + errdetail("%s depends on column \"%s\"", + getObjectDescription(&foundObject, false), + colName))); + break; + case OCLASS_REWRITE: - /* XXX someday see if we can cope with revising views */ + + /* + * View/rule bodies have pretty much the same issues as + * function bodies. FIXME someday. + */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot alter type of a column used by a view or rule"), @@ -12739,9 +12769,9 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, * specified as an update target, or because the column is * used in the trigger's WHEN condition. The first case would * not require any extra work, but the second case would - * require updating the WHEN expression, which will take a - * significant amount of new code. Since we can't easily tell - * which case applies, we punt for both. FIXME someday. + * require updating the WHEN expression, which has the same + * issues as above. Since we can't easily tell which case + * applies, we punt for both. FIXME someday. */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), @@ -12813,7 +12843,20 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, RememberStatisticsForRebuilding(foundObject.objectId, tab); break; - case OCLASS_PROC: + case OCLASS_PUBLICATION_REL: + + /* + * Column reference in a PUBLICATION ... FOR TABLE ... WHERE + * clause. Same issues as above. FIXME someday. + */ + ereport(ERROR, + (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), + errmsg("cannot alter type of a column used by a publication WHERE clause"), + errdetail("%s depends on column \"%s\"", + getObjectDescription(&foundObject, false), + colName))); + break; + case OCLASS_TYPE: case OCLASS_CAST: case OCLASS_COLLATION: @@ -12844,7 +12887,6 @@ ATExecAlterColumnType(AlteredTableInfo *tab, Relation rel, case OCLASS_PARAMETER_ACL: case OCLASS_PUBLICATION: case OCLASS_PUBLICATION_NAMESPACE: - case OCLASS_PUBLICATION_REL: case OCLASS_SUBSCRIPTION: case OCLASS_TRANSFORM: @@ -16551,16 +16593,11 @@ AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid, nspOid, false, false, objsMoved); /* Fix other dependent stuff */ - if (rel->rd_rel->relkind == RELKIND_RELATION || - rel->rd_rel->relkind == RELKIND_MATVIEW || - rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) - { - AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid, objsMoved); - AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid, - objsMoved, AccessExclusiveLock); - AlterConstraintNamespaces(RelationGetRelid(rel), oldNspOid, nspOid, - false, objsMoved); - } + AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid, objsMoved); + AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid, + objsMoved, AccessExclusiveLock); + AlterConstraintNamespaces(RelationGetRelid(rel), oldNspOid, nspOid, + false, objsMoved); table_close(classRel, RowExclusiveLock); } |