* 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. */
| 5155 | * transformed value of cmd->bound. |
| 5156 | */ |
| 5157 | static void |
| 5158 | transformPartitionCmd(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 |
no test coverage detected