MCPcopy Create free account
hub / github.com/apache/cloudberry / ATExecGPPartCmds

Function ATExecGPPartCmds

src/backend/commands/tablecmds_gp.c:1111–1483  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1109}
1110
1111void
1112ATExecGPPartCmds(Relation origrel, AlterTableCmd *cmd)
1113{
1114 Relation rel = origrel;
1115 List *stmts = NIL;
1116 ListCell *l;
1117
1118 while (cmd->subtype == AT_PartAlter)
1119 {
1120 GpAlterPartitionCmd *pc;
1121 GpAlterPartitionId *pid;
1122 Oid partrelid;
1123
1124 pc = castNode(GpAlterPartitionCmd, cmd->def);
1125 pid = (GpAlterPartitionId *) pc->partid;
1126 cmd = (AlterTableCmd *) pc->arg;
1127
1128 if (rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE)
1129 {
1130 ereport(ERROR,
1131 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1132 errmsg("table \"%s\" is not partitioned",
1133 RelationGetRelationName(rel))));
1134 }
1135
1136 partrelid = GpFindTargetPartition(rel, pid, false);
1137 Assert(OidIsValid(partrelid));
1138
1139 if (rel != origrel)
1140 table_close(rel, AccessShareLock);
1141 rel = table_open(partrelid, AccessShareLock);
1142 }
1143
1144 /*
1145 * Most ALTER PARTITION commands are to ADD/DROP subpartitions, and don't
1146 * make sense unless the partition itself is a partitioned table. SET
1147 * DISTRIBUTED BY and SET TABLESPACE are exceptions.
1148 */
1149 if (rel->rd_rel->relkind != RELKIND_PARTITIONED_TABLE &&
1150 cmd->subtype != AT_SetDistributedBy &&
1151 cmd->subtype != AT_SetTableSpace)
1152 {
1153 ereport(ERROR,
1154 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
1155 errmsg("table \"%s\" is not partitioned",
1156 RelationGetRelationName(rel))));
1157 }
1158
1159 switch (cmd->subtype)
1160 {
1161 case AT_PartTruncate:
1162 {
1163 GpAlterPartitionCmd *pc = castNode(GpAlterPartitionCmd, cmd->def);
1164 GpAlterPartitionId *pid = (GpAlterPartitionId *) pc->partid;
1165 TruncateStmt *truncstmt = (TruncateStmt *) pc->arg;
1166 Oid partrelid;
1167 RangeVar *rv;
1168 Relation partrel;

Callers 1

ATExecCmdFunction · 0.85

Calls 15

GpFindTargetPartitionFunction · 0.85
table_closeFunction · 0.85
table_openFunction · 0.85
makeRangeVarFunction · 0.85
get_namespace_nameFunction · 0.85
lappendFunction · 0.85
get_partition_ancestorsFunction · 0.85
list_lengthFunction · 0.85
RelationGetPartitionDescFunction · 0.85
generatePartitionSpecFunction · 0.85
GetGpPartitionTemplateFunction · 0.85
generatePartitionsFunction · 0.85

Tested by

no test coverage detected