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

Function transformPartitionCmd

src/backend/parser/parse_utilcmd.c:5157–5203  ·  view source on GitHub ↗

* transformPartitionCmd * Analyze the ATTACH/DETACH PARTITION command * * In case of the ATTACH PARTITION command, cxt->partbound is set to the * transformed value of cmd->bound. */

Source from the content-addressed store, hash-verified

5155 * transformed value of cmd->bound.
5156 */
5157static void
5158transformPartitionCmd(CreateStmtContext *cxt, PartitionCmd *cmd)
5159{
5160 Relation parentRel = cxt->rel;
5161
5162 switch (parentRel->rd_rel->relkind)
5163 {
5164 case RELKIND_PARTITIONED_TABLE:
5165 /* transform the partition bound, if any */
5166 Assert(RelationGetPartitionKey(parentRel) != NULL);
5167 if (cmd->bound != NULL)
5168 cxt->partbound = transformPartitionBound(cxt->pstate, parentRel,
5169 RelationGetPartitionKey(parentRel), cmd->bound);
5170 break;
5171 case RELKIND_PARTITIONED_INDEX:
5172
5173 /*
5174 * A partitioned index cannot have a partition bound set. ALTER
5175 * INDEX prevents that with its grammar, but not ALTER TABLE.
5176 */
5177 if (cmd->bound != NULL)
5178 ereport(ERROR,
5179 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5180 errmsg("\"%s\" is not a partitioned table",
5181 RelationGetRelationName(parentRel))));
5182 break;
5183 case RELKIND_RELATION:
5184 /* the table must be partitioned */
5185 ereport(ERROR,
5186 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5187 errmsg("table \"%s\" is not partitioned",
5188 RelationGetRelationName(parentRel))));
5189 break;
5190 case RELKIND_INDEX:
5191 /* the index must be partitioned */
5192 ereport(ERROR,
5193 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
5194 errmsg("index \"%s\" is not partitioned",
5195 RelationGetRelationName(parentRel))));
5196 break;
5197 default:
5198 /* parser shouldn't let this case through */
5199 elog(ERROR, "\"%s\" is not a partitioned table or index",
5200 RelationGetRelationName(parentRel));
5201 break;
5202 }
5203}
5204
5205/*
5206 * transformPartitionBound

Callers 1

transformAlterTableStmtFunction · 0.85

Calls 4

RelationGetPartitionKeyFunction · 0.85
transformPartitionBoundFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected