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

Function AdjustReplicatedTableCounts

src/backend/executor/execMain.c:4217–4252  ·  view source on GitHub ↗

* Adjust INSERT/UPDATE/DELETE count for replicated table ON QD */

Source from the content-addressed store, hash-verified

4215 * Adjust INSERT/UPDATE/DELETE count for replicated table ON QD
4216 */
4217static void
4218AdjustReplicatedTableCounts(EState *estate)
4219{
4220 ResultRelInfo *resultRelInfo;
4221 ListCell *l;
4222 bool containReplicatedTable = false;
4223 int numsegments = 1;
4224
4225 if (Gp_role != GP_ROLE_DISPATCH)
4226 return;
4227
4228 /* check if result_relations contain replicated table*/
4229 foreach(l, estate->es_opened_result_relations)
4230 {
4231 resultRelInfo = lfirst(l);
4232 if (!resultRelInfo->ri_RelationDesc->rd_cdbpolicy)
4233 continue;
4234
4235 if (GpPolicyIsReplicated(resultRelInfo->ri_RelationDesc->rd_cdbpolicy))
4236 {
4237 containReplicatedTable = true;
4238 numsegments = resultRelInfo->ri_RelationDesc->rd_cdbpolicy->numsegments;
4239 }
4240 else if (containReplicatedTable)
4241 {
4242 /*
4243 * If one is replicated table, error if other tables are not
4244 * replicated table.
4245 */
4246 elog(ERROR, "mix of replicated and non-replicated tables in result_relation is not supported");
4247 }
4248 }
4249
4250 if (containReplicatedTable)
4251 estate->es_processed = estate->es_processed / numsegments;
4252}
4253
4254/*
4255 * Greenplum specific code:

Callers 1

ExecEndPlanFunction · 0.85

Calls 2

GpPolicyIsReplicatedFunction · 0.85
foreachFunction · 0.50

Tested by

no test coverage detected