Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a0586d

Browse files
committed
Introduce notion of different types of slots (without implementing them).
Upcoming work intends to allow pluggable ways to introduce new ways ofstoring table data. Accessing those table access methods from theexecutor requires TupleTableSlots to be carry tuples in the nativeformat of such storage methods; otherwise there'll be a significantconversion overhead.Different access methods will require different data to store tuplesefficiently (just like virtual, minimal, heap already require fieldsin TupleTableSlot). To allow that without requiring additional pointerindirections, we want to have different structs (embeddingTupleTableSlot) for different types of slots. Thus different types ofslots are needed, which requires adapting creators of slots.The slot that most efficiently can represent a type of tuple in anexecutor node will often depend on the type of slot a child nodeuses. Therefore we need to track the type of slot is returned bynodes, so parent slots can create slots based on that.Relatedly, JIT compilation of tuple deforming needs to know which typeof slot a certain expression refers to, so it can create anappropriate deforming function for the type of tuple in the slot.But not all nodes will only return one type of slot, e.g. an appendnode will potentially return different types of slots for each of itssubplans.Therefore add function that allows to query the type of a node'sresult slot, and whether it'll always be the same type (whether it'sfixed). This can be queried using ExecGetResultSlotOps().The scan, result, inner, outer type of slots are automaticallyinferred from ExecInitScanTupleSlot(), ExecInitResultSlot(),left/right subtrees respectively. If that's not correct for a node,that can be overwritten using new fields in PlanState.This commit does not introduce the actually abstracted implementationof different kind of TupleTableSlots, that will be left for a followupcommit. The different types of slots introduced will, for now, stilluse the same backing implementation.While this already partially invalidates the big comment intuptable.h, it seems to make more sense to update it later, when thedifferent TupleTableSlot implementations actually exist.Author: Ashutosh Bapat and Andres Freund, with changes by Amit KhandekarDiscussion:https://postgr.es/m/20181105210039.hh4vvi4vwoq5ba2q@alap3.anarazel.de
1 parent763f2ed commit1a0586d

File tree

69 files changed

+478
-176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+478
-176
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4503,7 +4503,8 @@ ProjIndexIsUnchanged(Relation relation, HeapTuple oldtup, HeapTuple newtup)
45034503
List*indexoidlist=RelationGetIndexList(relation);
45044504
EState*estate=CreateExecutorState();
45054505
ExprContext*econtext=GetPerTupleExprContext(estate);
4506-
TupleTableSlot*slot=MakeSingleTupleTableSlot(RelationGetDescr(relation));
4506+
TupleTableSlot*slot=MakeSingleTupleTableSlot(RelationGetDescr(relation),
4507+
&TTSOpsHeapTuple);
45074508
boolequals= true;
45084509
Datumold_values[INDEX_MAX_KEYS];
45094510
boolold_isnull[INDEX_MAX_KEYS];

‎src/backend/catalog/index.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,7 +2510,8 @@ IndexBuildHeapRangeScan(Relation heapRelation,
25102510
*/
25112511
estate=CreateExecutorState();
25122512
econtext=GetPerTupleExprContext(estate);
2513-
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
2513+
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation),
2514+
&TTSOpsHeapTuple);
25142515

25152516
/* Arrange for econtext's scan tuple to be the tuple under test */
25162517
econtext->ecxt_scantuple=slot;
@@ -2997,7 +2998,8 @@ IndexCheckExclusion(Relation heapRelation,
29972998
*/
29982999
estate=CreateExecutorState();
29993000
econtext=GetPerTupleExprContext(estate);
3000-
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
3001+
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation),
3002+
&TTSOpsHeapTuple);
30013003

30023004
/* Arrange for econtext's scan tuple to be the tuple under test */
30033005
econtext->ecxt_scantuple=slot;
@@ -3315,7 +3317,8 @@ validate_index_heapscan(Relation heapRelation,
33153317
*/
33163318
estate=CreateExecutorState();
33173319
econtext=GetPerTupleExprContext(estate);
3318-
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
3320+
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation),
3321+
&TTSOpsHeapTuple);
33193322

33203323
/* Arrange for econtext's scan tuple to be the tuple under test */
33213324
econtext->ecxt_scantuple=slot;

‎src/backend/catalog/indexing.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple)
9595
heapRelation=indstate->ri_RelationDesc;
9696

9797
/* Need a slot to hold the tuple being examined */
98-
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation));
98+
slot=MakeSingleTupleTableSlot(RelationGetDescr(heapRelation),
99+
&TTSOpsHeapTuple);
99100
ExecStoreHeapTuple(heapTuple,slot, false);
100101

101102
/*

‎src/backend/commands/analyze.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,8 @@ compute_index_stats(Relation onerel, double totalrows,
730730
estate=CreateExecutorState();
731731
econtext=GetPerTupleExprContext(estate);
732732
/* Need a slot to hold the current heap tuple, too */
733-
slot=MakeSingleTupleTableSlot(RelationGetDescr(onerel));
733+
slot=MakeSingleTupleTableSlot(RelationGetDescr(onerel),
734+
&TTSOpsHeapTuple);
734735

735736
/* Arrange for econtext's scan tuple to be the tuple under test */
736737
econtext->ecxt_scantuple=slot;

‎src/backend/commands/constraint.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ unique_key_recheck(PG_FUNCTION_ARGS)
122122
/*
123123
* The heap tuple must be put into a slot for FormIndexDatum.
124124
*/
125-
slot=MakeSingleTupleTableSlot(RelationGetDescr(trigdata->tg_relation));
125+
slot=MakeSingleTupleTableSlot(RelationGetDescr(trigdata->tg_relation),
126+
&TTSOpsHeapTuple);
126127

127128
ExecStoreHeapTuple(new_row,slot, false);
128129

‎src/backend/commands/copy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,9 +2488,11 @@ CopyFrom(CopyState cstate)
24882488
ExecInitRangeTable(estate,cstate->range_table);
24892489

24902490
/* Set up a tuple slot too */
2491-
myslot=ExecInitExtraTupleSlot(estate,tupDesc);
2491+
myslot=ExecInitExtraTupleSlot(estate,tupDesc,
2492+
&TTSOpsHeapTuple);
24922493
/* Triggers might need a slot as well */
2493-
estate->es_trig_tuple_slot=ExecInitExtraTupleSlot(estate,NULL);
2494+
estate->es_trig_tuple_slot=ExecInitExtraTupleSlot(estate,NULL,
2495+
&TTSOpsHeapTuple);
24942496

24952497
/*
24962498
* Set up a ModifyTableState so we can let FDW(s) init themselves for

‎src/backend/commands/explain.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt, const char *queryString,
266266
Assert(es->indent==0);
267267

268268
/* output tuples */
269-
tstate=begin_tup_output_tupdesc(dest,ExplainResultDesc(stmt));
269+
tstate=begin_tup_output_tupdesc(dest,ExplainResultDesc(stmt),
270+
&TTSOpsVirtual);
270271
if (es->format==EXPLAIN_FORMAT_TEXT)
271272
do_text_output_multiline(tstate,es->str->data);
272273
else

‎src/backend/commands/functioncmds.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,8 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
23472347
tupTypmod=HeapTupleHeaderGetTypMod(td);
23482348
retdesc=lookup_rowtype_tupdesc(tupType,tupTypmod);
23492349

2350-
tstate=begin_tup_output_tupdesc(dest,retdesc);
2350+
tstate=begin_tup_output_tupdesc(dest,retdesc,
2351+
&TTSOpsHeapTuple);
23512352

23522353
rettupdata.t_len=HeapTupleHeaderGetDatumLength(td);
23532354
ItemPointerSetInvalid(&(rettupdata.t_self));

‎src/backend/commands/subscriptioncmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ fetch_table_list(WalReceiverConn *wrconn, List *publications)
11481148
res->err)));
11491149

11501150
/* Process tables. */
1151-
slot=MakeSingleTupleTableSlot(res->tupledesc);
1151+
slot=MakeSingleTupleTableSlot(res->tupledesc,&TTSOpsMinimalTuple);
11521152
while (tuplestore_gettupleslot(res->tuplestore, true, false,slot))
11531153
{
11541154
char*nspname;

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4736,8 +4736,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
47364736
* tuples are the same, the tupDescs might not be (consider ADD COLUMN
47374737
* without a default).
47384738
*/
4739-
oldslot=MakeSingleTupleTableSlot(oldTupDesc);
4740-
newslot=MakeSingleTupleTableSlot(newTupDesc);
4739+
oldslot=MakeSingleTupleTableSlot(oldTupDesc,&TTSOpsHeapTuple);
4740+
newslot=MakeSingleTupleTableSlot(newTupDesc,&TTSOpsHeapTuple);
47414741

47424742
/* Preallocate values/isnull arrays */
47434743
i=Max(newTupDesc->natts,oldTupDesc->natts);
@@ -8527,7 +8527,7 @@ validateCheckConstraint(Relation rel, HeapTuple constrtup)
85278527

85288528
econtext=GetPerTupleExprContext(estate);
85298529
tupdesc=RelationGetDescr(rel);
8530-
slot=MakeSingleTupleTableSlot(tupdesc);
8530+
slot=MakeSingleTupleTableSlot(tupdesc,&TTSOpsHeapTuple);
85318531
econtext->ecxt_scantuple=slot;
85328532

85338533
snapshot=RegisterSnapshot(GetLatestSnapshot());

‎src/backend/commands/trigger.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ TriggerEnabled(EState *estate, ResultRelInfo *relinfo,
35253525
{
35263526
oldContext=MemoryContextSwitchTo(estate->es_query_cxt);
35273527
estate->es_trig_oldtup_slot=
3528-
ExecInitExtraTupleSlot(estate,NULL);
3528+
ExecInitExtraTupleSlot(estate,NULL,&TTSOpsHeapTuple);
35293529
MemoryContextSwitchTo(oldContext);
35303530
}
35313531
oldslot=estate->es_trig_oldtup_slot;
@@ -3539,7 +3539,7 @@ TriggerEnabled(EState *estate, ResultRelInfo *relinfo,
35393539
{
35403540
oldContext=MemoryContextSwitchTo(estate->es_query_cxt);
35413541
estate->es_trig_newtup_slot=
3542-
ExecInitExtraTupleSlot(estate,NULL);
3542+
ExecInitExtraTupleSlot(estate,NULL,&TTSOpsHeapTuple);
35433543
MemoryContextSwitchTo(oldContext);
35443544
}
35453545
newslot=estate->es_trig_newtup_slot;
@@ -4546,8 +4546,10 @@ afterTriggerInvokeEvents(AfterTriggerEventList *events,
45464546
ExecDropSingleTupleTableSlot(slot1);
45474547
ExecDropSingleTupleTableSlot(slot2);
45484548
}
4549-
slot1=MakeSingleTupleTableSlot(rel->rd_att);
4550-
slot2=MakeSingleTupleTableSlot(rel->rd_att);
4549+
slot1=MakeSingleTupleTableSlot(rel->rd_att,
4550+
&TTSOpsMinimalTuple);
4551+
slot2=MakeSingleTupleTableSlot(rel->rd_att,
4552+
&TTSOpsMinimalTuple);
45514553
}
45524554
if (trigdesc==NULL)/* should not happen */
45534555
elog(ERROR,"relation %u has no triggers",

‎src/backend/executor/execExpr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,8 @@ ExecInitWholeRowVar(ExprEvalStep *scratch, Var *variable, ExprState *state)
24232423
scratch->d.wholerow.junkFilter=
24242424
ExecInitJunkFilter(subplan->plan->targetlist,
24252425
ExecGetResultType(subplan)->tdhasoid,
2426-
ExecInitExtraTupleSlot(parent->state,NULL));
2426+
ExecInitExtraTupleSlot(parent->state,NULL,
2427+
&TTSOpsVirtual));
24272428
}
24282429
}
24292430
}
@@ -3214,6 +3215,7 @@ ExecBuildAggTransCall(ExprState *state, AggState *aggstate,
32143215
*/
32153216
ExprState*
32163217
ExecBuildGroupingEqual(TupleDescldesc,TupleDescrdesc,
3218+
constTupleTableSlotOps*lops,constTupleTableSlotOps*rops,
32173219
intnumCols,
32183220
AttrNumber*keyColIdx,
32193221
Oid*eqfunctions,

‎src/backend/executor/execGrouping.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ execTuplesMatchPrepare(TupleDesc desc,
7575
eqFunctions[i]=get_opcode(eqOperators[i]);
7676

7777
/* build actual expression */
78-
expr=ExecBuildGroupingEqual(desc,desc,numCols,keyColIdx,eqFunctions,
78+
expr=ExecBuildGroupingEqual(desc,desc,NULL,NULL,
79+
numCols,keyColIdx,eqFunctions,
7980
parent);
8081

8182
returnexpr;
@@ -202,10 +203,13 @@ BuildTupleHashTable(PlanState *parent,
202203
* We copy the input tuple descriptor just for safety --- we assume all
203204
* input tuples will have equivalent descriptors.
204205
*/
205-
hashtable->tableslot=MakeSingleTupleTableSlot(CreateTupleDescCopy(inputDesc));
206+
hashtable->tableslot=MakeSingleTupleTableSlot(CreateTupleDescCopy(inputDesc),
207+
&TTSOpsMinimalTuple);
206208

207209
/* build comparator for all columns */
210+
/* XXX: should we support non-minimal tuples for the inputslot? */
208211
hashtable->tab_eq_func=ExecBuildGroupingEqual(inputDesc,inputDesc,
212+
&TTSOpsMinimalTuple,&TTSOpsMinimalTuple,
209213
numCols,
210214
keyColIdx,eqfuncoids,
211215
parent);

‎src/backend/executor/execIndexing.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ check_exclusion_or_unique_constraint(Relation heap, Relation index,
706706
* to this slot. Be sure to save and restore caller's value for
707707
* scantuple.
708708
*/
709-
existing_slot=MakeSingleTupleTableSlot(RelationGetDescr(heap));
709+
existing_slot=MakeSingleTupleTableSlot(RelationGetDescr(heap),
710+
&TTSOpsHeapTuple);
710711

711712
econtext=GetPerTupleExprContext(estate);
712713
save_scantuple=econtext->ecxt_scantuple;

‎src/backend/executor/execJunk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ExecInitJunkFilter(List *targetList, bool hasoid, TupleTableSlot *slot)
7878
if (slot)
7979
ExecSetSlotDescriptor(slot,cleanTupType);
8080
else
81-
slot=MakeSingleTupleTableSlot(cleanTupType);
81+
slot=MakeSingleTupleTableSlot(cleanTupType,&TTSOpsVirtual);
8282

8383
/*
8484
* Now calculate the mapping between the original tuple's attributes and
@@ -149,7 +149,7 @@ ExecInitJunkFilterConversion(List *targetList,
149149
if (slot)
150150
ExecSetSlotDescriptor(slot,cleanTupType);
151151
else
152-
slot=MakeSingleTupleTableSlot(cleanTupType);
152+
slot=MakeSingleTupleTableSlot(cleanTupType,&TTSOpsVirtual);
153153

154154
/*
155155
* Calculate the mapping between the original tuple's attributes and the

‎src/backend/executor/execMain.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,10 +1052,12 @@ InitPlan(QueryDesc *queryDesc, int eflags)
10521052
if (junk_filter_needed)
10531053
{
10541054
JunkFilter*j;
1055+
TupleTableSlot*slot;
10551056

1057+
slot=ExecInitExtraTupleSlot(estate,NULL,&TTSOpsVirtual);
10561058
j=ExecInitJunkFilter(planstate->plan->targetlist,
10571059
tupType->tdhasoid,
1058-
ExecInitExtraTupleSlot(estate,NULL));
1060+
slot);
10591061
estate->es_junkFilter=j;
10601062

10611063
/* Want to return the cleaned tuple type */
@@ -1928,7 +1930,7 @@ ExecPartitionCheckEmitError(ResultRelInfo *resultRelInfo,
19281930
*/
19291931
if (map!=NULL)
19301932
slot=execute_attr_map_slot(map,slot,
1931-
MakeTupleTableSlot(tupdesc));
1933+
MakeTupleTableSlot(tupdesc,&TTSOpsVirtual));
19321934
}
19331935

19341936
insertedCols=GetInsertedColumns(resultRelInfo,estate);
@@ -2009,7 +2011,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
20092011
*/
20102012
if (map!=NULL)
20112013
slot=execute_attr_map_slot(map,slot,
2012-
MakeTupleTableSlot(tupdesc));
2014+
MakeTupleTableSlot(tupdesc,&TTSOpsVirtual));
20132015
}
20142016

20152017
insertedCols=GetInsertedColumns(resultRelInfo,estate);
@@ -2059,7 +2061,7 @@ ExecConstraints(ResultRelInfo *resultRelInfo,
20592061
*/
20602062
if (map!=NULL)
20612063
slot=execute_attr_map_slot(map,slot,
2062-
MakeTupleTableSlot(tupdesc));
2064+
MakeTupleTableSlot(tupdesc,&TTSOpsVirtual));
20632065
}
20642066

20652067
insertedCols=GetInsertedColumns(resultRelInfo,estate);
@@ -2167,7 +2169,7 @@ ExecWithCheckOptions(WCOKind kind, ResultRelInfo *resultRelInfo,
21672169
*/
21682170
if (map!=NULL)
21692171
slot=execute_attr_map_slot(map,slot,
2170-
MakeTupleTableSlot(tupdesc));
2172+
MakeTupleTableSlot(tupdesc,&TTSOpsVirtual));
21712173
}
21722174

21732175
insertedCols=GetInsertedColumns(resultRelInfo,estate);

‎src/backend/executor/execPartition.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, Relation rel)
144144
* We need an additional tuple slot for storing transient tuples that
145145
* are converted to the root table descriptor.
146146
*/
147-
proute->root_tuple_slot=MakeTupleTableSlot(RelationGetDescr(rel));
147+
proute->root_tuple_slot=MakeTupleTableSlot(RelationGetDescr(rel),
148+
&TTSOpsHeapTuple);
148149
}
149150

150151
i=0;
@@ -740,7 +741,8 @@ ExecInitRoutingInfo(ModifyTableState *mtstate,
740741
*/
741742
proute->partition_tuple_slots[partidx]=
742743
ExecInitExtraTupleSlot(estate,
743-
RelationGetDescr(partrel));
744+
RelationGetDescr(partrel),
745+
&TTSOpsHeapTuple);
744746
}
745747

746748
/*
@@ -974,7 +976,7 @@ get_partition_dispatch_recurse(Relation rel, Relation parent,
974976
* using the correct tuple descriptor when computing its partition key
975977
* for tuple routing.
976978
*/
977-
pd->tupslot=MakeSingleTupleTableSlot(tupdesc);
979+
pd->tupslot=MakeSingleTupleTableSlot(tupdesc,&TTSOpsHeapTuple);
978980
pd->tupmap=convert_tuples_by_name_map_if_req(RelationGetDescr(parent),
979981
tupdesc,
980982
gettext_noop("could not convert row type"));

‎src/backend/executor/execSRF.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ ExecPrepareTuplestoreResult(SetExprState *sexpr,
873873
slotDesc=NULL;/* keep compiler quiet */
874874
}
875875

876-
sexpr->funcResultSlot=MakeSingleTupleTableSlot(slotDesc);
876+
sexpr->funcResultSlot=MakeSingleTupleTableSlot(slotDesc,
877+
&TTSOpsMinimalTuple);
877878
MemoryContextSwitchTo(oldcontext);
878879
}
879880

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp