* QueuePartitionConstraintValidation * * Add an entry to wqueue to have the given partition constraint validated by * Phase 3, for the given relation, and all its children. * * We first verify whether the given constraint is implied by pre-existing * relation constraints; if it is, there's no need to scan the table to * validate, so don't queue in that case. */
| 21363 | * validate, so don't queue in that case. |
| 21364 | */ |
| 21365 | static void |
| 21366 | QueuePartitionConstraintValidation(List **wqueue, Relation scanrel, |
| 21367 | List *partConstraint, |
| 21368 | bool validate_default) |
| 21369 | { |
| 21370 | /* |
| 21371 | * Based on the table's existing constraints, determine whether or not we |
| 21372 | * may skip scanning the table. |
| 21373 | */ |
| 21374 | if (PartConstraintImpliedByRelConstraint(scanrel, partConstraint)) |
| 21375 | { |
| 21376 | if (!validate_default) |
| 21377 | ereport(DEBUG1, |
| 21378 | (errmsg_internal("partition constraint for table \"%s\" is implied by existing constraints", |
| 21379 | RelationGetRelationName(scanrel)))); |
| 21380 | else |
| 21381 | ereport(DEBUG1, |
| 21382 | (errmsg_internal("updated partition constraint for default partition \"%s\" is implied by existing constraints", |
| 21383 | RelationGetRelationName(scanrel)))); |
| 21384 | return; |
| 21385 | } |
| 21386 | |
| 21387 | /* |
| 21388 | * Constraints proved insufficient. For plain relations, queue a |
| 21389 | * validation item now; for partitioned tables, recurse to process each |
| 21390 | * partition. |
| 21391 | */ |
| 21392 | if (scanrel->rd_rel->relkind == RELKIND_RELATION) |
| 21393 | { |
| 21394 | AlteredTableInfo *tab; |
| 21395 | |
| 21396 | /* Grab a work queue entry. */ |
| 21397 | tab = ATGetQueueEntry(wqueue, scanrel); |
| 21398 | |
| 21399 | if (Gp_role == GP_ROLE_EXECUTE) |
| 21400 | { |
| 21401 | /* |
| 21402 | * In the QE, we receive these from the QD. We should reach |
| 21403 | * the same conclusions if we re-did the work here. |
| 21404 | */ |
| 21405 | Assert(equal(tab->partition_constraint, linitial(partConstraint))); |
| 21406 | Assert(tab->validate_default == validate_default); |
| 21407 | } |
| 21408 | else |
| 21409 | { |
| 21410 | Assert(tab->partition_constraint == NULL); |
| 21411 | tab->partition_constraint = (Expr *) linitial(partConstraint); |
| 21412 | tab->validate_default = validate_default; |
| 21413 | } |
| 21414 | } |
| 21415 | else if (scanrel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE) |
| 21416 | { |
| 21417 | PartitionDesc partdesc = RelationGetPartitionDesc(scanrel, true); |
| 21418 | int i; |
| 21419 | |
| 21420 | for (i = 0; i < partdesc->nparts; i++) |
| 21421 | { |
| 21422 | Relation part_rel; |
no test coverage detected