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

Commit2435c7d

Browse files
committed
New HeapTuple structure/interface.
1 parent4d71880 commit2435c7d

File tree

8 files changed

+117
-104
lines changed

8 files changed

+117
-104
lines changed

‎src/include/access/heapam.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: heapam.h,v 1.38 1998/10/08 18:30:22 momjian Exp $
9+
* $Id: heapam.h,v 1.39 1998/11/27 19:33:31 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -89,6 +89,10 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
8989
*
9090
* ----------------
9191
*/
92+
93+
externDatumnocachegetattr(HeapTupletup,intattnum,
94+
TupleDescatt,bool*isnull);
95+
9296
#if !defined(DISABLE_COMPLEX_MACRO)
9397

9498
#definefastgetattr(tup,attnum,tupleDesc,isnull) \
@@ -101,7 +105,7 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
101105
(attnum) == 1) ? \
102106
( \
103107
(Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \
104-
(char *) (tup) + (tup)->t_hoff + \
108+
(char *) (tup)->t_data + (tup)->t_data->t_hoff + \
105109
( \
106110
((attnum) != 1) ? \
107111
(tupleDesc)->attrs[(attnum)-1]->attcacheoff \
@@ -115,7 +119,7 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
115119
) \
116120
: \
117121
( \
118-
att_isnull((attnum)-1, (tup)->t_bits) ? \
122+
att_isnull((attnum)-1, (tup)->t_data->t_bits) ? \
119123
( \
120124
((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
121125
(Datum)NULL \
@@ -129,9 +133,6 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
129133

130134
#else/* !defined(DISABLE_COMPLEX_MACRO) */
131135

132-
externDatumnocachegetattr(HeapTupletup,intattnum,
133-
TupleDescatt,bool*isnull);
134-
135136
staticDatum
136137
fastgetattr(HeapTupletup,intattnum,TupleDesctupleDesc,
137138
bool*isnull)
@@ -146,7 +147,7 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
146147
(attnum)==1) ?
147148
(
148149
(Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]),
149-
(char*) (tup)+ (tup)->t_hoff+
150+
(char*) (tup)->t_data+ (tup)->t_data->t_hoff+
150151
(
151152
((attnum)!=1) ?
152153
(tupleDesc)->attrs[(attnum)-1]->attcacheoff
@@ -160,7 +161,7 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
160161
)
161162
:
162163
(
163-
att_isnull((attnum)-1, (tup)->t_bits) ?
164+
att_isnull((attnum)-1, (tup)->t_data->t_bits) ?
164165
(
165166
((isnull) ? (*(isnull)= true) : (dummyret)NULL),
166167
(Datum)NULL
@@ -205,7 +206,7 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
205206
AssertMacro((tup) != NULL && \
206207
(attnum) > FirstLowInvalidHeapAttributeNumber && \
207208
(attnum) != 0), \
208-
((attnum) > (int) (tup)->t_natts) ? \
209+
((attnum) > (int) (tup)->t_data->t_natts) ? \
209210
( \
210211
((isnull) ? (*(isnull) = true) : (dummyret)NULL), \
211212
(Datum)NULL \
@@ -221,13 +222,12 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
221222
((isnull) ? (*(isnull) = false) : (dummyret)NULL), \
222223
((attnum) == SelfItemPointerAttributeNumber) ? \
223224
( \
224-
(Datum)((char *)(tup) + \
225-
heap_sysoffset[-SelfItemPointerAttributeNumber-1]) \
225+
(Datum)((char *)&((tup)->t_self)) \
226226
) \
227227
: \
228228
( \
229229
(Datum)*(unsigned int *) \
230-
((char *)(tup) + heap_sysoffset[-(attnum)-1]) \
230+
((char *)(tup)->t_data + heap_sysoffset[-(attnum)-1]) \
231231
) \
232232
) \
233233
) \
@@ -251,7 +251,7 @@ extern HeapScanDesc heap_beginscan(Relation relation, int atend,
251251
externvoidheap_rescan(HeapScanDescscan,boolscanFromEnd,ScanKeykey);
252252
externvoidheap_endscan(HeapScanDescscan);
253253
externHeapTupleheap_getnext(HeapScanDescscandesc,intbackw);
254-
externHeapTupleheap_fetch(Relationrelation,Snapshotsnapshot,ItemPointertid,Buffer*userbuf);
254+
externvoidheap_fetch(Relationrelation,Snapshotsnapshot,HeapTupletup,Buffer*userbuf);
255255
externOidheap_insert(Relationrelation,HeapTupletup);
256256
externintheap_delete(Relationrelation,ItemPointertid);
257257
externintheap_replace(Relationrelation,ItemPointerotid,
@@ -270,6 +270,7 @@ extern bool heap_sysattrbyval(AttrNumber attno);
270270
externDatumnocachegetattr(HeapTupletup,intattnum,
271271
TupleDescatt,bool*isnull);
272272
externHeapTupleheap_copytuple(HeapTupletuple);
273+
externvoidheap_copytuple_with_tuple(HeapTuplesrc,HeapTupledest);
273274
externHeapTupleheap_formtuple(TupleDesctupleDescriptor,
274275
Datum*value,char*nulls);
275276
externHeapTupleheap_modifytuple(HeapTupletuple,

‎src/include/access/htup.h

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: htup.h,v 1.10 1998/09/01 04:34:14 momjian Exp $
9+
* $Id: htup.h,v 1.11 1998/11/27 19:33:31 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -26,10 +26,8 @@
2626
* to avoid wasting space, the attributes should be layed out in such a
2727
* way to reduce structure padding.
2828
*/
29-
typedefstructHeapTupleData
29+
typedefstructHeapTupleHeaderData
3030
{
31-
unsignedintt_len;/* length of entire tuple */
32-
3331
Oidt_oid;/* OID of this tuple -- 4 bytes */
3432

3533
CommandIdt_cmin;/* insert CID stamp -- 4 bytes each */
@@ -38,7 +36,7 @@ typedef struct HeapTupleData
3836
TransactionIdt_xmin;/* insert XID stamp -- 4 bytes each */
3937
TransactionIdt_xmax;/* delete XID stamp */
4038

41-
ItemPointerDatat_ctid;/* current TID of this tuple */
39+
ItemPointerDatat_ctid;/* current TID of thisor newertuple */
4240

4341
int16t_natts;/* number of attributes */
4442

@@ -50,10 +48,9 @@ typedef struct HeapTupleData
5048
/* bit map of domains */
5149

5250
/* MORE DATA FOLLOWS AT END OF STRUCT */
53-
}HeapTupleData;
54-
55-
typedefHeapTupleData*HeapTuple;
51+
}HeapTupleHeaderData;
5652

53+
typedefHeapTupleHeaderData*HeapTupleHeader;
5754

5855
#defineSelfItemPointerAttributeNumber(-1)
5956
#defineObjectIdAttributeNumber(-2)
@@ -66,11 +63,33 @@ typedef HeapTupleData *HeapTuple;
6663
/* If you make any changes above, the order off offsets in this must change */
6764
externlongheap_sysoffset[];
6865

66+
/*
67+
* This new HeapTuple for version >= 6.5 and this is why it was changed:
68+
*
69+
* 1. t_len moved off on-disk tuple data - ItemIdData is used to get len;
70+
* 2. t_ctid above is not self tuple TID now - it may point to
71+
* updated version of tuple (required by MVCC);
72+
* 3. someday someone let tuple to cross block boundaries -
73+
* he have to add something below...
74+
*/
75+
typedefstructHeapTupleData
76+
{
77+
uint32t_len;/* length of *t_data */
78+
ItemPointerDatat_self;/* SelfItemPointer */
79+
HeapTupleHeadert_data;/* */
80+
}HeapTupleData;
81+
82+
typedefHeapTupleData*HeapTuple;
83+
84+
#defineHEAPTUPLESIZEDOUBLEALIGN(sizeof(HeapTupleData))
85+
86+
6987
/* ----------------
7088
*support macros
7189
* ----------------
7290
*/
73-
#defineGETSTRUCT(TUP) (((char *)(TUP)) + ((HeapTuple)(TUP))->t_hoff)
91+
#defineGETSTRUCT(TUP) (((char *)((HeapTuple)(TUP))->t_data) + \
92+
((HeapTuple)(TUP))->t_data->t_hoff)
7493

7594

7695
/*
@@ -101,9 +120,9 @@ extern long heap_sysoffset[];
101120
#defineHEAP_XACT_MASK0x0F00/* */
102121

103122
#defineHeapTupleNoNulls(tuple) \
104-
(!(((HeapTuple) (tuple))->t_infomask & HEAP_HASNULL))
123+
(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASNULL))
105124

106125
#defineHeapTupleAllFixed(tuple) \
107-
(!(((HeapTuple) (tuple))->t_infomask & HEAP_HASVARLENA))
126+
(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASVARLENA))
108127

109128
#endif/* HTUP_H */

‎src/include/access/relscan.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: relscan.h,v 1.12 1998/09/01 04:34:23 momjian Exp $
9+
* $Id: relscan.h,v 1.13 1998/11/27 19:33:31 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -22,40 +22,40 @@ typedef ItemPointerData MarkData;
2222

2323
typedefstructHeapScanDescData
2424
{
25-
Relationrs_rd;/* pointer to relation descriptor */
26-
HeapTuplers_ptup;/* previous tuple in scan */
27-
HeapTuplers_ctup;/* current tuple in scan */
28-
HeapTuplers_ntup;/* next tuple in scan */
29-
Bufferrs_pbuf;/* previous buffer in scan */
30-
Bufferrs_cbuf;/* current buffer in scan */
31-
Bufferrs_nbuf;/* next buffer in scan */
32-
ItemPointerDatars_mptid;/* marked previous tid */
33-
ItemPointerDatars_mctid;/* marked current tid */
34-
ItemPointerDatars_mntid;/* marked next tid */
35-
ItemPointerDatars_mcd;/* marked current delta XXX ??? */
36-
Snapshotrs_snapshot;/* snapshot to see */
37-
boolrs_atend;/* restart scan at end? */
38-
uint16rs_cdelta;/* current delta in chain */
39-
uint16rs_nkeys;/* number of attributes in keys */
40-
ScanKeyrs_key;/* key descriptors */
25+
Relationrs_rd;/* pointer to relation descriptor */
26+
HeapTupleDatars_ptup;/* previous tuple in scan */
27+
HeapTupleDatars_ctup;/* current tuple in scan */
28+
HeapTupleDatars_ntup;/* next tuple in scan */
29+
Bufferrs_pbuf;/* previous buffer in scan */
30+
Bufferrs_cbuf;/* current buffer in scan */
31+
Bufferrs_nbuf;/* next buffer in scan */
32+
ItemPointerDatars_mptid;/* marked previous tid */
33+
ItemPointerDatars_mctid;/* marked current tid */
34+
ItemPointerDatars_mntid;/* marked next tid */
35+
ItemPointerDatars_mcd;/* marked current delta XXX ??? */
36+
Snapshotrs_snapshot;/* snapshot to see */
37+
boolrs_atend;/* restart scan at end? */
38+
uint16rs_cdelta;/* current delta in chain */
39+
uint16rs_nkeys;/* number of attributes in keys */
40+
ScanKeyrs_key;/* key descriptors */
4141
}HeapScanDescData;
4242

4343
typedefHeapScanDescData*HeapScanDesc;
4444

4545
typedefstructIndexScanDescData
4646
{
47-
Relationrelation;/* relation descriptor */
48-
void*opaque;/* am-specific slot */
47+
Relationrelation;/* relation descriptor */
48+
void*opaque;/* am-specific slot */
4949
ItemPointerDatapreviousItemData;/* previous index pointer */
5050
ItemPointerDatacurrentItemData;/* current index pointer */
5151
ItemPointerDatanextItemData;/* next index pointer */
5252
MarkDatapreviousMarkData;/* marked previous pointer */
53-
MarkDatacurrentMarkData;/* marked current pointer */
54-
MarkDatanextMarkData;/* marked next pointer */
55-
uint8flags;/* scan position flags */
56-
boolscanFromEnd;/* restart scan at end? */
57-
uint16numberOfKeys;/* number of key attributes */
58-
ScanKeykeyData;/* key descriptor */
53+
MarkDatacurrentMarkData;/* marked current pointer */
54+
MarkDatanextMarkData;/* marked next pointer */
55+
uint8flags;/* scan position flags */
56+
boolscanFromEnd;/* restart scan at end? */
57+
uint16numberOfKeys;/* number of key attributes */
58+
ScanKeykeyData;/* key descriptor */
5959
}IndexScanDescData;
6060

6161
typedefIndexScanDescData*IndexScanDesc;

‎src/include/access/valid.h

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: valid.h,v 1.15 1998/09/01 04:34:33 momjian Exp $
9+
* $Id: valid.h,v 1.16 1998/11/27 19:33:32 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -109,49 +109,41 @@ do \
109109
*with joey's expensive function work.
110110
* ----------------
111111
*/
112-
#defineHeapTupleSatisfies(itemId, \
112+
#defineHeapTupleSatisfies(tuple, \
113113
relation, \
114114
buffer, \
115115
disk_page, \
116116
seeself, \
117117
nKeys, \
118-
key, \
119-
result) \
118+
key) \
120119
do \
121120
{ \
122121
/* We use underscores to protect the variable passed in as parameters */ \
123-
HeapTuple_tuple; \
124122
bool_res; \
125123
\
126-
if (!ItemIdIsUsed(itemId)) \
127-
(result)= (HeapTuple)NULL; \
124+
if ((key)!=NULL) \
125+
HeapKeyTest(tuple,RelationGetDescr(relation), \
126+
(nKeys), (key),_res); \
128127
else \
129-
{ \
130-
_tuple= (HeapTuple)PageGetItem((Page) (disk_page), (itemId)); \
131-
\
132-
if ((key)!=NULL) \
133-
HeapKeyTest(_tuple,RelationGetDescr(relation), \
134-
(nKeys), (key),_res); \
135-
else \
136-
_res= TRUE; \
128+
_res= TRUE; \
137129
\
138-
(result)= (HeapTuple)NULL; \
139-
if (_res) \
130+
if (_res) \
131+
{ \
132+
if ((relation)->rd_rel->relkind!=RELKIND_UNCATALOGED) \
140133
{ \
141-
if ((relation)->rd_rel->relkind==RELKIND_UNCATALOGED) \
142-
(result)=_tuple; \
143-
else \
144-
{ \
145-
uint16_infomask=_tuple->t_infomask; \
146-
\
147-
_res=HeapTupleSatisfiesVisibility(_tuple, (seeself)); \
148-
if (_tuple->t_infomask!=_infomask) \
149-
SetBufferCommitInfoNeedsSave(buffer); \
150-
if (_res) \
151-
(result)=_tuple; \
152-
} \
134+
uint16_infomask= (tuple)->t_data->t_infomask; \
135+
\
136+
_res=HeapTupleSatisfiesVisibility((tuple), (seeself)); \
137+
if ((tuple)->t_data->t_infomask!=_infomask) \
138+
SetBufferCommitInfoNeedsSave(buffer); \
139+
if (!_res) \
140+
(tuple)->t_data=NULL; \
153141
} \
154142
} \
143+
else \
144+
{ \
145+
(tuple)->t_data= NULL; \
146+
} \
155147
}while (0)
156148

157149
externboolTupleUpdatedByCurXactAndCmd(HeapTuplet);

‎src/include/executor/executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: executor.h,v 1.27 1998/10/14 05:10:05 momjian Exp $
9+
* $Id: executor.h,v 1.28 1998/11/27 19:33:32 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -85,7 +85,7 @@ extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
8585
externTupleDescExecutorStart(QueryDesc*queryDesc,EState*estate);
8686
externTupleTableSlot*ExecutorRun(QueryDesc*queryDesc,EState*estate,intfeature,intcount);
8787
externvoidExecutorEnd(QueryDesc*queryDesc,EState*estate);
88-
externHeapTupleExecConstraints(char*caller,Relationrel,HeapTupletuple);
88+
externvoidExecConstraints(char*caller,Relationrel,HeapTupletuple);
8989
#ifdefQUERY_LIMIT
9090
externintExecutorLimit(intlimit);
9191
externintExecutorGetLimit(void);

‎src/include/executor/tuptable.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: tuptable.h,v 1.8 1998/09/01 04:36:13 momjian Exp $
9+
* $Id: tuptable.h,v 1.9 1998/11/27 19:33:33 vadim Exp $
1010
*
1111
* NOTES
1212
* The tuple table interface is getting pretty ugly.
@@ -46,13 +46,13 @@
4646
*/
4747
typedefstructTupleTableSlot
4848
{
49-
NodeTagtype;
50-
HeapTupleval;
51-
boolttc_shouldFree;
52-
boolttc_descIsNew;
53-
TupleDescttc_tupleDescriptor;
54-
Bufferttc_buffer;
55-
intttc_whichplan;
49+
NodeTagtype;
50+
HeapTupleval;
51+
boolttc_shouldFree;
52+
boolttc_descIsNew;
53+
TupleDescttc_tupleDescriptor;
54+
Bufferttc_buffer;
55+
intttc_whichplan;
5656
}TupleTableSlot;
5757

5858
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp