1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

Fill EState.es_rteperminfos more systematically.

While testing a fix for bug #17823, I discovered that EvalPlanQualStart
failed to copy es_rteperminfos from the parent EState, resulting in
failure if anything in EPQ execution wanted to consult that information.

This led me to conclude that commit a61b1f748 had been too haphazard
about where to fill es_rteperminfos, and that we need to be sure that
that happens exactly where es_range_table gets filled.  So I changed the
signature of ExecInitRangeTable to help ensure that this new requirement
doesn't get missed.  (Indeed, pgoutput.c was also failing to fill it.
Maybe we don't ever need it there, but I wouldn't bet on that.)

No test case yet; one will arrive with the fix for #17823.
But that needs to be back-patched, while this fix is HEAD-only.

Discussion: https://postgr.es/m/17823-b64909cf7d63de84@postgresql.org
This commit is contained in:
Tom Lane
2023-03-06 13:10:57 -05:00
parent e76cbb6cd6
commit b803b7d132
6 changed files with 21 additions and 16 deletions

View File

@ -807,15 +807,14 @@ InitPlan(QueryDesc *queryDesc, int eflags)
int i;
/*
* Do permissions checks and save the list for later use.
* Do permissions checks
*/
ExecCheckPermissions(rangeTable, plannedstmt->permInfos, true);
estate->es_rteperminfos = plannedstmt->permInfos;
/*
* initialize the node's execution state
*/
ExecInitRangeTable(estate, rangeTable);
ExecInitRangeTable(estate, rangeTable, plannedstmt->permInfos);
estate->es_plannedstmt = plannedstmt;
estate->es_part_prune_infos = plannedstmt->partPruneInfos;
@ -2805,11 +2804,12 @@ EvalPlanQualStart(EPQState *epqstate, Plan *planTree)
rcestate->es_range_table = parentestate->es_range_table;
rcestate->es_range_table_size = parentestate->es_range_table_size;
rcestate->es_relations = parentestate->es_relations;
rcestate->es_queryEnv = parentestate->es_queryEnv;
rcestate->es_rowmarks = parentestate->es_rowmarks;
rcestate->es_rteperminfos = parentestate->es_rteperminfos;
rcestate->es_plannedstmt = parentestate->es_plannedstmt;
rcestate->es_junkFilter = parentestate->es_junkFilter;
rcestate->es_output_cid = parentestate->es_output_cid;
rcestate->es_queryEnv = parentestate->es_queryEnv;
/*
* ResultRelInfos needed by subplans are initialized from scratch when the