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

Commit617dd33

Browse files
committed
Eliminate duplicate hasnulls bit testing in index tuple access, and
clean up itup.h a little bit.
1 parent926e8a0 commit617dd33

File tree

3 files changed

+33
-64
lines changed

3 files changed

+33
-64
lines changed

‎src/backend/access/common/indextuple.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.73 2005/03/21 01:23:55 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/access/common/indextuple.c,v 1.74 2005/03/27 18:38:26 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -137,7 +137,7 @@ index_form_tuple(TupleDesc tupleDescriptor,
137137
isnull,
138138
(char*)tp+hoff,
139139
&tupmask,
140-
(hasnull ? (bits8*)tp+sizeof(*tuple) :NULL));
140+
(hasnull ? (bits8*)tp+sizeof(IndexTupleData) :NULL));
141141

142142
#ifdefTOAST_INDEX_HACK
143143
for (i=0;i<numberOfAttributes;i++)
@@ -230,8 +230,7 @@ nocache_index_getattr(IndexTuple tup,
230230
*isnull= false;
231231
#endif
232232

233-
data_off=IndexTupleHasMinHeader(tup) ?sizeof*tup :
234-
IndexInfoFindDataOffset(tup->t_info);
233+
data_off=IndexInfoFindDataOffset(tup->t_info);
235234

236235
attnum--;
237236

@@ -256,7 +255,7 @@ nocache_index_getattr(IndexTuple tup,
256255
*/
257256

258257
/* XXX "knows" t_bits are just after fixed tuple header! */
259-
bp= (bits8*) ((char*)tup+sizeof(*tup));
258+
bp= (bits8*) ((char*)tup+sizeof(IndexTupleData));
260259

261260
#ifdefIN_MACRO
262261
/* This is handled in the macro */

‎src/include/access/ibit.h

Lines changed: 0 additions & 32 deletions
This file was deleted.

‎src/include/access/itup.h

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,31 @@
77
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/access/itup.h,v 1.42 2005/03/21 01:24:04 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/access/itup.h,v 1.43 2005/03/27 18:38:27 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#ifndefITUP_H
1515
#defineITUP_H
1616

17-
#include"access/ibit.h"
1817
#include"access/tupdesc.h"
1918
#include"access/tupmacs.h"
2019
#include"storage/itemptr.h"
2120

2221

22+
/*
23+
* Index tuple header structure
24+
*
25+
* All index tuples start with IndexTupleData. If the HasNulls bit is set,
26+
* this is followed by an IndexAttributeBitMapData. The index attribute
27+
* values follow, beginning at a MAXALIGN boundary.
28+
*
29+
* Note that the space allocated for the bitmap does not vary with the number
30+
* of attributes; that is because we don't have room to store the number of
31+
* attributes in the header. Given the MAXALIGN constraint there's no space
32+
* savings to be had anyway, for usual values of INDEX_MAX_KEYS.
33+
*/
34+
2335
typedefstructIndexTupleData
2436
{
2537
ItemPointerDatat_tid;/* reference TID to heap tuple */
@@ -36,44 +48,40 @@ typedef struct IndexTupleData
3648

3749
unsigned shortt_info;/* various info about tuple */
3850

39-
/*
40-
* please make sure sizeof(IndexTupleData) is MAXALIGN'ed. See
41-
* IndexInfoFindDataOffset() for the reason.
42-
*/
43-
4451
}IndexTupleData;/* MORE DATA FOLLOWS AT END OF STRUCT */
4552

4653
typedefIndexTupleData*IndexTuple;
4754

55+
typedefstructIndexAttributeBitMapData
56+
{
57+
bits8bits[(INDEX_MAX_KEYS+8-1) /8];
58+
}IndexAttributeBitMapData;
59+
60+
typedefIndexAttributeBitMapData*IndexAttributeBitMap;
4861

49-
/* ----------------
50-
*externs
51-
* ----------------
62+
/*
63+
* t_info manipulation macros
5264
*/
53-
5465
#defineINDEX_SIZE_MASK 0x1FFF
55-
#defineINDEX_NULL_MASK 0x8000
66+
/* bit 0x2000 is not used at present */
5667
#defineINDEX_VAR_MASK0x4000
57-
/* bit 0x2000 is not used */
68+
#defineINDEX_NULL_MASK 0x8000
5869

5970
#defineIndexTupleSize(itup)((Size) (((IndexTuple) (itup))->t_info & INDEX_SIZE_MASK))
6071
#defineIndexTupleDSize(itup)((Size) ((itup).t_info & INDEX_SIZE_MASK))
6172
#defineIndexTupleHasNulls(itup)((((IndexTuple) (itup))->t_info & INDEX_NULL_MASK))
6273
#defineIndexTupleHasVarwidths(itup) ((((IndexTuple) (itup))->t_info & INDEX_VAR_MASK))
6374

64-
#defineIndexTupleHasMinHeader(itup) (!IndexTupleHasNulls(itup))
6575

6676
/*
6777
* Takes an infomask as argument (primarily because this needs to be usable
6878
* at index_form_tuple time so enough space is allocated).
69-
*
70-
* Change me if adding an attribute to IndexTuples!!!!!!!!!!!
7179
*/
7280
#defineIndexInfoFindDataOffset(t_info) \
7381
( \
74-
(!((unsigned short)(t_info) & INDEX_NULL_MASK)) ? \
82+
(!((t_info) & INDEX_NULL_MASK)) ? \
7583
( \
76-
(Size)sizeof(IndexTupleData) \
84+
(Size)MAXALIGN(sizeof(IndexTupleData)) \
7785
) \
7886
: \
7987
( \
@@ -85,7 +93,7 @@ typedef IndexTupleData *IndexTuple;
8593
*index_getattr
8694
*
8795
*This gets called many times, so we macro the cacheable and NULL
88-
*lookups, and callnoncachegetattr() for the rest.
96+
*lookups, and callnocache_index_getattr() for the rest.
8997
*
9098
* ----------------
9199
*/
@@ -98,21 +106,15 @@ typedef IndexTupleData *IndexTuple;
98106
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
99107
( \
100108
fetchatt((tupleDesc)->attrs[(attnum)-1], \
101-
(char *) (tup) + \
102-
( \
103-
IndexTupleHasMinHeader(tup) ? \
104-
sizeof (*(tup)) \
105-
: \
106-
IndexInfoFindDataOffset((tup)->t_info) \
107-
) \
109+
(char *) (tup) + IndexInfoFindDataOffset((tup)->t_info) \
108110
+ (tupleDesc)->attrs[(attnum)-1]->attcacheoff) \
109111
) \
110112
: \
111113
nocache_index_getattr((tup), (attnum), (tupleDesc), (isnull)) \
112114
) \
113115
: \
114116
( \
115-
(att_isnull((attnum)-1, (char *)(tup) + sizeof(*(tup)))) ? \
117+
(att_isnull((attnum)-1, (char *)(tup) + sizeof(IndexTupleData))) ? \
116118
( \
117119
*(isnull) = true, \
118120
(Datum)NULL \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp