mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Remove EState.es_range_table_array.
Now that list_nth is O(1), there's no good reason to maintain a separate array of RTE pointers rather than indexing into estate->es_range_table. Deleting the array doesn't save all that much either; but just on cleanliness grounds, it's better not to have duplicate representations of the identical information. Discussion: https://postgr.es/m/14960.1565384592@sss.pgh.pa.us
This commit is contained in:
parent
5ee190f8ec
commit
3c926587b5
@ -2790,7 +2790,6 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree)
|
|||||||
estate->es_snapshot = parentestate->es_snapshot;
|
estate->es_snapshot = parentestate->es_snapshot;
|
||||||
estate->es_crosscheck_snapshot = parentestate->es_crosscheck_snapshot;
|
estate->es_crosscheck_snapshot = parentestate->es_crosscheck_snapshot;
|
||||||
estate->es_range_table = parentestate->es_range_table;
|
estate->es_range_table = parentestate->es_range_table;
|
||||||
estate->es_range_table_array = parentestate->es_range_table_array;
|
|
||||||
estate->es_range_table_size = parentestate->es_range_table_size;
|
estate->es_range_table_size = parentestate->es_range_table_size;
|
||||||
estate->es_relations = parentestate->es_relations;
|
estate->es_relations = parentestate->es_relations;
|
||||||
estate->es_queryEnv = parentestate->es_queryEnv;
|
estate->es_queryEnv = parentestate->es_queryEnv;
|
||||||
|
@ -113,7 +113,6 @@ CreateExecutorState(void)
|
|||||||
estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */
|
estate->es_snapshot = InvalidSnapshot; /* caller must initialize this */
|
||||||
estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */
|
estate->es_crosscheck_snapshot = InvalidSnapshot; /* no crosscheck */
|
||||||
estate->es_range_table = NIL;
|
estate->es_range_table = NIL;
|
||||||
estate->es_range_table_array = NULL;
|
|
||||||
estate->es_range_table_size = 0;
|
estate->es_range_table_size = 0;
|
||||||
estate->es_relations = NULL;
|
estate->es_relations = NULL;
|
||||||
estate->es_rowmarks = NULL;
|
estate->es_rowmarks = NULL;
|
||||||
@ -720,29 +719,17 @@ ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
|
|||||||
* ExecInitRangeTable
|
* ExecInitRangeTable
|
||||||
* Set up executor's range-table-related data
|
* Set up executor's range-table-related data
|
||||||
*
|
*
|
||||||
* We build an array from the range table list to allow faster lookup by RTI.
|
* In addition to the range table proper, initialize arrays that are
|
||||||
* (The es_range_table field is now somewhat redundant, but we keep it to
|
* indexed by rangetable index.
|
||||||
* avoid breaking external code unnecessarily.)
|
|
||||||
* This is also a convenient place to set up the parallel es_relations array.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ExecInitRangeTable(EState *estate, List *rangeTable)
|
ExecInitRangeTable(EState *estate, List *rangeTable)
|
||||||
{
|
{
|
||||||
Index rti;
|
|
||||||
ListCell *lc;
|
|
||||||
|
|
||||||
/* Remember the range table List as-is */
|
/* Remember the range table List as-is */
|
||||||
estate->es_range_table = rangeTable;
|
estate->es_range_table = rangeTable;
|
||||||
|
|
||||||
/* Set up the equivalent array representation */
|
/* Set size of associated arrays */
|
||||||
estate->es_range_table_size = list_length(rangeTable);
|
estate->es_range_table_size = list_length(rangeTable);
|
||||||
estate->es_range_table_array = (RangeTblEntry **)
|
|
||||||
palloc(estate->es_range_table_size * sizeof(RangeTblEntry *));
|
|
||||||
rti = 0;
|
|
||||||
foreach(lc, rangeTable)
|
|
||||||
{
|
|
||||||
estate->es_range_table_array[rti++] = lfirst_node(RangeTblEntry, lc);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate an array to store an open Relation corresponding to each
|
* Allocate an array to store an open Relation corresponding to each
|
||||||
@ -753,8 +740,8 @@ ExecInitRangeTable(EState *estate, List *rangeTable)
|
|||||||
palloc0(estate->es_range_table_size * sizeof(Relation));
|
palloc0(estate->es_range_table_size * sizeof(Relation));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* es_rowmarks is also parallel to the es_range_table_array, but it's
|
* es_rowmarks is also parallel to the es_range_table, but it's allocated
|
||||||
* allocated only if needed.
|
* only if needed.
|
||||||
*/
|
*/
|
||||||
estate->es_rowmarks = NULL;
|
estate->es_rowmarks = NULL;
|
||||||
}
|
}
|
||||||
|
@ -535,8 +535,7 @@ extern void ExecInitRangeTable(EState *estate, List *rangeTable);
|
|||||||
static inline RangeTblEntry *
|
static inline RangeTblEntry *
|
||||||
exec_rt_fetch(Index rti, EState *estate)
|
exec_rt_fetch(Index rti, EState *estate)
|
||||||
{
|
{
|
||||||
Assert(rti > 0 && rti <= estate->es_range_table_size);
|
return (RangeTblEntry *) list_nth(estate->es_range_table, rti - 1);
|
||||||
return estate->es_range_table_array[rti - 1];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
|
extern Relation ExecGetRangeTableRelation(EState *estate, Index rti);
|
||||||
|
@ -502,7 +502,6 @@ typedef struct EState
|
|||||||
Snapshot es_snapshot; /* time qual to use */
|
Snapshot es_snapshot; /* time qual to use */
|
||||||
Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */
|
Snapshot es_crosscheck_snapshot; /* crosscheck time qual for RI */
|
||||||
List *es_range_table; /* List of RangeTblEntry */
|
List *es_range_table; /* List of RangeTblEntry */
|
||||||
struct RangeTblEntry **es_range_table_array; /* equivalent array */
|
|
||||||
Index es_range_table_size; /* size of the range table arrays */
|
Index es_range_table_size; /* size of the range table arrays */
|
||||||
Relation *es_relations; /* Array of per-range-table-entry Relation
|
Relation *es_relations; /* Array of per-range-table-entry Relation
|
||||||
* pointers, or NULL if not yet opened */
|
* pointers, or NULL if not yet opened */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user