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

Commit7ced1d1

Browse files
committed
Add FIELDNO_* macro designating offset into structs required for JIT.
For any interesting JIT target, fields inside structs need to beaccessed.b96d550 contains infrastructure for syncing the definitionof types between postgres C code and runtime code generation withLLVM. But that doesn't sync the number or names of fields insidestructs, just the types (including padding etc).One option would be to hardcode the offset numbers in the JIT code,but that'd be hard to keep in sync. Instead add macros indicating thefield offset to the fields that need to be accessed. Not pretty, butmanageable.Author: Andres FreundDiscussion:https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de
1 parentfb46ac2 commit7ced1d1

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

‎src/include/access/htup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ typedef struct HeapTupleData
6464
uint32t_len;/* length of *t_data */
6565
ItemPointerDatat_self;/* SelfItemPointer */
6666
Oidt_tableOid;/* table the tuple came from */
67+
#defineFIELDNO_HEAPTUPLEDATA_DATA 3
6768
HeapTupleHeadert_data;/* -> tuple header and data */
6869
}HeapTupleData;
6970

‎src/include/access/htup_details.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,18 @@ struct HeapTupleHeaderData
157157

158158
/* Fields below here must match MinimalTupleData! */
159159

160+
#defineFIELDNO_HEAPTUPLEHEADERDATA_INFOMASK2 2
160161
uint16t_infomask2;/* number of attributes + various flags */
161162

163+
#defineFIELDNO_HEAPTUPLEHEADERDATA_INFOMASK 3
162164
uint16t_infomask;/* various flag bits, see below */
163165

166+
#defineFIELDNO_HEAPTUPLEHEADERDATA_HOFF 4
164167
uint8t_hoff;/* sizeof header incl. bitmap, padding */
165168

166169
/* ^ - 23 bytes - ^ */
167170

171+
#defineFIELDNO_HEAPTUPLEHEADERDATA_BITS 5
168172
bits8t_bits[FLEXIBLE_ARRAY_MEMBER];/* bitmap of NULLs */
169173

170174
/* MORE DATA FOLLOWS AT END OF STRUCT */

‎src/include/executor/nodeAgg.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,12 @@ typedef struct AggStatePerAggData
240240
*/
241241
typedefstructAggStatePerGroupData
242242
{
243+
#defineFIELDNO_AGGSTATEPERGROUPDATA_TRANSVALUE 0
243244
DatumtransValue;/* current transition value */
245+
#defineFIELDNO_AGGSTATEPERGROUPDATA_TRANSVALUEISNULL 1
244246
booltransValueIsNull;
245247

248+
#defineFIELDNO_AGGSTATEPERGROUPDATA_NOTRANSVALUE 2
246249
boolnoTransValue;/* true if transValue not set yet */
247250

248251
/*

‎src/include/executor/tuptable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,23 @@ typedef struct TupleTableSlot
116116
booltts_isempty;/* true = slot is empty */
117117
booltts_shouldFree;/* should pfree tts_tuple? */
118118
booltts_shouldFreeMin;/* should pfree tts_mintuple? */
119+
#defineFIELDNO_TUPLETABLESLOT_SLOW 4
119120
booltts_slow;/* saved state for slot_deform_tuple */
121+
#defineFIELDNO_TUPLETABLESLOT_TUPLE 5
120122
HeapTupletts_tuple;/* physical tuple, or NULL if virtual */
123+
#defineFIELDNO_TUPLETABLESLOT_TUPLEDESCRIPTOR 6
121124
TupleDesctts_tupleDescriptor;/* slot's tuple descriptor */
122125
MemoryContexttts_mcxt;/* slot itself is in this context */
123126
Buffertts_buffer;/* tuple's buffer, or InvalidBuffer */
127+
#defineFIELDNO_TUPLETABLESLOT_NVALID 9
124128
inttts_nvalid;/* # of valid values in tts_values */
129+
#defineFIELDNO_TUPLETABLESLOT_VALUES 10
125130
Datum*tts_values;/* current per-attribute values */
131+
#defineFIELDNO_TUPLETABLESLOT_ISNULL 11
126132
bool*tts_isnull;/* current per-attribute isnull flags */
127133
MinimalTupletts_mintuple;/* minimal tuple, or NULL if none */
128134
HeapTupleDatatts_minhdr;/* workspace for minimal-tuple-only case */
135+
#defineFIELDNO_TUPLETABLESLOT_OFF 14
129136
uint32tts_off;/* saved state for slot_deform_tuple */
130137
booltts_fixedTupleDescriptor;/* descriptor can't be changed */
131138
}TupleTableSlot;

‎src/include/fmgr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,12 @@ typedef struct FunctionCallInfoData
8080
fmNodePtrcontext;/* pass info about context of call */
8181
fmNodePtrresultinfo;/* pass or return extra info about result */
8282
Oidfncollation;/* collation for function to use */
83+
#defineFIELDNO_FUNCTIONCALLINFODATA_ISNULL 4
8384
boolisnull;/* function must set true if result is NULL */
8485
shortnargs;/* # arguments actually passed */
86+
#defineFIELDNO_FUNCTIONCALLINFODATA_ARG 6
8587
Datumarg[FUNC_MAX_ARGS];/* Arguments passed to function */
88+
#defineFIELDNO_FUNCTIONCALLINFODATA_ARGNULL 7
8689
boolargnull[FUNC_MAX_ARGS];/* T if arg[i] is actually NULL */
8790
}FunctionCallInfoData;
8891

‎src/include/nodes/execnodes.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,15 @@ typedef struct ExprState
6464
* Storage for result value of a scalar expression, or for individual
6565
* column results within expressions built by ExecBuildProjectionInfo().
6666
*/
67+
#defineFIELDNO_EXPRSTATE_RESNULL 2
6768
boolresnull;
69+
#defineFIELDNO_EXPRSTATE_RESVALUE 3
6870
Datumresvalue;
6971

7072
/*
7173
* If projecting a tuple result, this slot holds the result; else NULL.
7274
*/
75+
#defineFIELDNO_EXPRSTATE_RESULTSLOT 4
7376
TupleTableSlot*resultslot;
7477

7578
/*
@@ -208,8 +211,11 @@ typedef struct ExprContext
208211
NodeTagtype;
209212

210213
/* Tuples that Var nodes in expression may refer to */
214+
#defineFIELDNO_EXPRCONTEXT_SCANTUPLE 1
211215
TupleTableSlot*ecxt_scantuple;
216+
#defineFIELDNO_EXPRCONTEXT_INNERTUPLE 2
212217
TupleTableSlot*ecxt_innertuple;
218+
#defineFIELDNO_EXPRCONTEXT_OUTERTUPLE 3
213219
TupleTableSlot*ecxt_outertuple;
214220

215221
/* Memory contexts for expression evaluation --- see notes above */
@@ -224,15 +230,21 @@ typedef struct ExprContext
224230
* Values to substitute for Aggref nodes in the expressions of an Agg
225231
* node, or for WindowFunc nodes within a WindowAgg node.
226232
*/
233+
#defineFIELDNO_EXPRCONTEXT_AGGVALUES 8
227234
Datum*ecxt_aggvalues;/* precomputed values for aggs/windowfuncs */
235+
#defineFIELDNO_EXPRCONTEXT_AGGNULLS 9
228236
bool*ecxt_aggnulls;/* null flags for aggs/windowfuncs */
229237

230238
/* Value to substitute for CaseTestExpr nodes in expression */
239+
#defineFIELDNO_EXPRCONTEXT_CASEDATUM 10
231240
DatumcaseValue_datum;
241+
#defineFIELDNO_EXPRCONTEXT_CASENULL 11
232242
boolcaseValue_isNull;
233243

234244
/* Value to substitute for CoerceToDomainValue nodes in expression */
245+
#defineFIELDNO_EXPRCONTEXT_DOMAINDATUM 12
235246
DatumdomainValue_datum;
247+
#defineFIELDNO_EXPRCONTEXT_DOMAINNULL 13
236248
booldomainValue_isNull;
237249

238250
/* Link to containing EState (NULL if a standalone ExprContext) */
@@ -1847,12 +1859,15 @@ typedef struct AggState
18471859
ExprContext*hashcontext;/* econtexts for long-lived data (hashtable) */
18481860
ExprContext**aggcontexts;/* econtexts for long-lived data (per GS) */
18491861
ExprContext*tmpcontext;/* econtext for input expressions */
1862+
#defineFIELDNO_AGGSTATE_CURAGGCONTEXT 14
18501863
ExprContext*curaggcontext;/* currently active aggcontext */
18511864
AggStatePerAggcurperagg;/* currently active aggregate, if any */
1865+
#defineFIELDNO_AGGSTATE_CURPERTRANS 16
18521866
AggStatePerTranscurpertrans;/* currently active trans state, if any */
18531867
boolinput_done;/* indicates end of input */
18541868
boolagg_done;/* indicates completion of Agg scan */
18551869
intprojected_set;/* The last projected grouping set */
1870+
#defineFIELDNO_AGGSTATE_CURRENT_SET 20
18561871
intcurrent_set;/* The current grouping set being evaluated */
18571872
Bitmapset*grouped_cols;/* grouped cols in current projection */
18581873
List*all_grouped_cols;/* list of all grouped cols in DESC order */
@@ -1874,6 +1889,7 @@ typedef struct AggState
18741889
* per-group pointers */
18751890

18761891
/* support for evaluation of agg input expressions: */
1892+
#defineFIELDNO_AGGSTATE_ALL_PERGROUPS 34
18771893
AggStatePerGroup*all_pergroups;/* array of first ->pergroups, than
18781894
* ->hash_pergroup */
18791895
ProjectionInfo*combinedproj;/* projection machinery */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp