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

Commit4f6c49f

Browse files
committed
Clean up index/btree comments/macros, as approved.
1 parent660ca3e commit4f6c49f

File tree

6 files changed

+52
-42
lines changed

6 files changed

+52
-42
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.51 2001/02/15 20:57:01 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.52 2001/02/22 21:48:48 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -230,7 +230,7 @@ nocache_index_getattr(IndexTuple tup,
230230

231231
attnum--;
232232

233-
if (IndexTupleNoNulls(tup))
233+
if (!IndexTupleHasNulls(tup))
234234
{
235235
#ifdefIN_MACRO
236236
/* This is handled in the macro */
@@ -301,7 +301,7 @@ nocache_index_getattr(IndexTuple tup,
301301
returnfetchatt(att[attnum],
302302
tp+att[attnum]->attcacheoff);
303303
}
304-
elseif (!IndexTupleAllFixed(tup))
304+
elseif (IndexTupleHasVarlenas(tup))
305305
{
306306
intj;
307307

@@ -365,7 +365,7 @@ nocache_index_getattr(IndexTuple tup,
365365

366366
for (i=0;i<attnum;i++)
367367
{
368-
if (!IndexTupleNoNulls(tup))
368+
if (IndexTupleHasNulls(tup))
369369
{
370370
if (att_isnull(i,bp))
371371
{

‎src/backend/access/gist/gist.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.69 2001/01/29 00:39:12 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.70 2001/02/22 21:48:48 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -1102,7 +1102,7 @@ gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t)
11021102
{
11031103
memcpy(datum,entry.pred,entry.bytes);
11041104
/* clear out old size */
1105-
t->t_info &=0xe000;
1105+
t->t_info &=~INDEX_SIZE_MASK;
11061106
/* or in new size */
11071107
t->t_info |=MAXALIGN(entry.bytes+sizeof(IndexTupleData));
11081108

‎src/backend/access/hash/hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.48 2001/01/29 00:39:13 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.49 2001/02/22 21:48:49 momjian Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -170,7 +170,7 @@ hashbuild(PG_FUNCTION_ARGS)
170170
* of the way nulls are handled here.
171171
*/
172172

173-
if (itup->t_info&INDEX_NULL_MASK)
173+
if (IndexTupleHasNulls(itup))
174174
{
175175
pfree(itup);
176176
continue;
@@ -256,7 +256,7 @@ hashinsert(PG_FUNCTION_ARGS)
256256
itup=index_formtuple(RelationGetDescr(rel),datum,nulls);
257257
itup->t_tid=*ht_ctid;
258258

259-
if (itup->t_info&INDEX_NULL_MASK)
259+
if (IndexTupleHasNulls(itup))
260260
PG_RETURN_POINTER((InsertIndexResult)NULL);
261261

262262
hitem=_hash_formitem(itup);

‎src/backend/access/hash/hashutil.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.25 2001/01/24 19:42:47 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.26 2001/02/22 21:48:49 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -72,7 +72,7 @@ _hash_formitem(IndexTuple itup)
7272
Sizetuplen;
7373

7474
/* disallow nulls in hash keys */
75-
if (itup->t_info&INDEX_NULL_MASK)
75+
if (IndexTupleHasNulls(itup))
7676
elog(ERROR,"hash indices cannot include null keys");
7777

7878
/* make a copy of the index tuple with room for the sequence number */

‎src/include/access/itup.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: itup.h,v 1.29 2001/02/21 19:07:04 momjian Exp $
10+
* $Id: itup.h,v 1.30 2001/02/22 21:48:49 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -24,12 +24,14 @@ typedef struct IndexTupleData
2424
{
2525
ItemPointerDatat_tid;/* reference TID to heap tuple */
2626

27-
/*
27+
/* ---------------
2828
* t_info is layed out in the following fashion:
2929
*
30-
* 15th (leftmost) bit: "has nulls" bit 14th bit: "has varlenas" bit 13th
31-
* bit: "has rules" bit - (removed ay 11/94) bits 12-0 bit: size of
32-
* tuple.
30+
* 15th (high) bit: has nulls
31+
* 14th bit: has varlenas
32+
* 13th bit: unused
33+
* 12-0 bit: size of tuple
34+
* ---------------
3335
*/
3436

3537
unsigned shortt_info;/* various info about tuple */
@@ -69,13 +71,14 @@ typedef RetrieveIndexResultData *RetrieveIndexResult;
6971
#defineINDEX_SIZE_MASK 0x1FFF
7072
#defineINDEX_NULL_MASK 0x8000
7173
#defineINDEX_VAR_MASK0x4000
74+
/* bit 0x2000 is not used */
7275

73-
#defineIndexTupleSize(itup)((Size) (((IndexTuple) (itup))->t_info &0x1FFF))
74-
#defineIndexTupleDSize(itup)((Size) ((itup).t_info &0x1FFF))
75-
#defineIndexTupleNoNulls(itup) (!(((IndexTuple) (itup))->t_info &0x8000))
76-
#defineIndexTupleAllFixed(itup) (!(((IndexTuple) (itup))->t_info &0x4000))
76+
#defineIndexTupleSize(itup)((Size) (((IndexTuple) (itup))->t_info &INDEX_SIZE_MASK))
77+
#defineIndexTupleDSize(itup)((Size) ((itup).t_info &INDEX_SIZE_MASK))
78+
#defineIndexTupleHasNulls(itup)((((IndexTuple) (itup))->t_info &INDEX_NULL_MASK))
79+
#defineIndexTupleHasVarlenas(itup)((((IndexTuple) (itup))->t_info &INDEX_VAR_MASK))
7780

78-
#defineIndexTupleHasMinHeader(itup) (IndexTupleNoNulls(itup))
81+
#defineIndexTupleHasMinHeader(itup) (!IndexTupleHasNulls(itup))
7982

8083
/*
8184
* Takes an infomask as argument (primarily because this needs to be usable
@@ -107,7 +110,7 @@ typedef RetrieveIndexResultData *RetrieveIndexResult;
107110
( \
108111
AssertMacro(PointerIsValid(isnull) && (attnum) > 0), \
109112
*(isnull) = false, \
110-
IndexTupleNoNulls(tup) ? \
113+
!IndexTupleHasNulls(tup) ? \
111114
( \
112115
(tupleDesc)->attrs[(attnum)-1]->attcacheoff >= 0 ? \
113116
( \

‎src/include/access/nbtree.h

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: nbtree.h,v 1.52 2001/02/21 19:07:04 momjian Exp $
10+
* $Id: nbtree.h,v 1.53 2001/02/22 21:48:49 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,8 +21,9 @@
2121

2222
/*
2323
*BTPageOpaqueData -- At the end of every page, we store a pointer
24-
*to both siblings in the tree. See Lehman and Yao's paper for more
25-
*info. In addition, we need to know what sort of page this is
24+
*to both siblings in the tree. This is used to do forward/backward
25+
* index scans. See Lehman and Yao's paper for more
26+
*info. In addition, we need to know what type of page this is
2627
*(leaf or internal), and whether the page is available for reuse.
2728
*
2829
*We also store a back-link to the parent page, but this cannot be trusted
@@ -32,31 +33,28 @@
3233

3334
typedefstructBTPageOpaqueData
3435
{
35-
BlockNumberbtpo_prev;
36-
BlockNumberbtpo_next;
37-
BlockNumberbtpo_parent;
38-
uint16btpo_flags;
36+
BlockNumberbtpo_prev;/* used for backward index scans */
37+
BlockNumberbtpo_next;/* used for forward index scans */
38+
BlockNumberbtpo_parent;/* pointer to parent, but not updated
39+
on parent split */
40+
uint16btpo_flags;/* LEAF?, ROOT?, FREE?, META?, REORDER? */
3941

4042
}BTPageOpaqueData;
4143

4244
typedefBTPageOpaqueData*BTPageOpaque;
4345

4446
/* Bits defined in btpo_flags */
45-
#defineBTP_LEAF(1 << 0)/*It's a leaf page */
46-
#defineBTP_ROOT(1 << 1)/*It's theroot page (has no parent) */
47-
#defineBTP_FREE(1 << 2)/* notcurrently used... */
48-
#defineBTP_META(1 << 3)/*Set in themeta-page only */
49-
#defineBTP_REORDER(1 << 4)/* itemsmust be re-ordered */
47+
#defineBTP_LEAF(1 << 0)/*leaf page, if not internal page */
48+
#defineBTP_ROOT(1 << 1)/* root page (has no parent) */
49+
#defineBTP_FREE(1 << 2)/*pagenotin use */
50+
#defineBTP_META(1 << 3)/* meta-page */
51+
#defineBTP_REORDER(1 << 4)/* itemsneed reordering */
5052

5153

52-
#defineBTREE_METAPAGE0/* first page is meta */
53-
#defineBTREE_MAGIC0x053162
54-
55-
#defineBTreeInvalidParent(opaque)\
56-
(opaque->btpo_parent == InvalidBlockNumber || \
57-
opaque->btpo_parent == BTREE_METAPAGE)
58-
59-
#defineBTREE_VERSION1
54+
/*
55+
* The Meta page is always the first page in the btree index.
56+
* Its primary purpose is to point to the location of the btree root page.
57+
*/
6058

6159
typedefstructBTMetaPageData
6260
{
@@ -69,6 +67,15 @@ typedef struct BTMetaPageData
6967
#defineBTPageGetMeta(p) \
7068
((BTMetaPageData *) &((PageHeader) p)->pd_linp[0])
7169

70+
#defineBTREE_METAPAGE0/* first page is meta */
71+
#defineBTREE_MAGIC0x053162/* magic number of btree pages */
72+
73+
#defineBTreeInvalidParent(opaque)\
74+
(opaque->btpo_parent == InvalidBlockNumber || \
75+
opaque->btpo_parent == BTREE_METAPAGE)
76+
77+
#defineBTREE_VERSION1
78+
7279
/*
7380
*BTScanOpaqueData is used to remember which buffers we're currently
7481
*examining in the scan.We keep these buffers pinned (but not locked,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp