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

Commit75c6c2b

Browse files
committed
Inlined heap_getattr().
1 parent20afa04 commit75c6c2b

File tree

9 files changed

+48
-104
lines changed

9 files changed

+48
-104
lines changed

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

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.20 1997/08/24 23:07:26 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.21 1997/08/26 23:31:20 momjian Exp $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -39,8 +39,6 @@
3939
#defineregister
4040
#endif/* !NO_ASSERT_CHECKING && sparc && sunos4 */
4141

42-
staticchar*heap_getsysattr(HeapTupletup,Bufferb,intattnum);
43-
4442
/* ----------------------------------------------------------------
4543
*misc support routines
4644
* ----------------------------------------------------------------
@@ -337,7 +335,7 @@ heap_sysattrbyval(AttrNumber attno)
337335
*heap_getsysattr
338336
* ----------------
339337
*/
340-
staticchar*
338+
char*
341339
heap_getsysattr(HeapTupletup,Bufferb,intattnum)
342340
{
343341
switch (attnum) {
@@ -423,7 +421,6 @@ fastgetattr(HeapTuple tup,
423421
* ----------------
424422
*/
425423

426-
Assert(PointerIsValid(isnull));
427424
Assert(attnum>0);
428425

429426
/* ----------------
@@ -435,7 +432,8 @@ fastgetattr(HeapTuple tup,
435432
* ----------------
436433
*/
437434

438-
*isnull= false;
435+
if (isnull)
436+
*isnull= false;
439437

440438
if (HeapTupleNoNulls(tup)) {
441439
attnum--;
@@ -469,7 +467,8 @@ fastgetattr(HeapTuple tup,
469467
*/
470468

471469
if (att_isnull(attnum,bp)) {
472-
*isnull= true;
470+
if (isnull)
471+
*isnull= true;
473472
returnNULL;
474473
}
475474

@@ -659,58 +658,6 @@ fastgetattr(HeapTuple tup,
659658
}
660659
}
661660

662-
/* ----------------
663-
* heap_getattr
664-
*
665-
* Find a particular field in a row represented as a heap tuple.
666-
* We return a pointer into that heap tuple, which points to the
667-
* first byte of the value of the field in question.
668-
*
669-
* If the field in question has a NULL value, we return a null
670-
* pointer and return <*isnull> == true. Otherwise, we return
671-
* <*isnull> == false.
672-
*
673-
* <tup> is the pointer to the heap tuple. <attnum> is the attribute
674-
* number of the column (field) caller wants. <tupleDesc> is a
675-
* pointer to the structure describing the row and all its fields.
676-
* ---------------- */
677-
char*
678-
heap_getattr(HeapTupletup,
679-
Bufferb,
680-
intattnum,
681-
TupleDesctupleDesc,
682-
bool*isnull)
683-
{
684-
boollocalIsNull;
685-
686-
/* ----------------
687-
* sanity checks
688-
* ----------------
689-
*/
690-
Assert(tup!=NULL);
691-
692-
if (!PointerIsValid(isnull))
693-
isnull=&localIsNull;
694-
695-
if (attnum> (int)tup->t_natts) {
696-
*isnull= true;
697-
return ((char*)NULL);
698-
}elseif (attnum>0) {
699-
/* ----------------
700-
* take care of user defined attributes
701-
* ----------------
702-
*/
703-
returnfastgetattr(tup,attnum,tupleDesc,isnull);
704-
}else {
705-
/* ----------------
706-
* take care of system attributes
707-
* ----------------
708-
*/
709-
*isnull= false;
710-
returnheap_getsysattr(tup,b,attnum);
711-
}
712-
}
713-
714661
/* ----------------
715662
*heap_copytuple
716663
*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.14 1997/08/24 23:07:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.15 1997/08/26 23:31:22 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414

1515
#include<postgres.h>
1616

1717
#include<fmgr.h>
18-
#include<access/heaptuple.h>
18+
#include<access/heapam.h>
1919
#include<access/valid.h>
2020
#include<access/xact.h>
2121
#include<storage/bufpage.h>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.14 1997/08/18 20:51:30 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.15 1997/08/26 23:31:23 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -17,7 +17,7 @@
1717
#include<postgres.h>
1818

1919
#include<fmgr.h>
20-
#include<access/heaptuple.h>
20+
#include<access/heapam.h>
2121
#include<access/printtup.h>
2222
#include<catalog/pg_type.h>
2323
#include<libpq/libpq.h>
@@ -91,7 +91,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
9191
j=0;
9292
k=1 <<7;
9393
for (i=0;i<tuple->t_natts; ) {
94-
attr=heap_getattr(tuple,InvalidBuffer,++i,typeinfo,&isnull);
94+
i++;/* heap_getattr is a macro, so no increment */
95+
attr=heap_getattr(tuple,InvalidBuffer,i,typeinfo,&isnull);
9596
if (!isnull)
9697
j |=k;
9798
k >>=1;
@@ -214,7 +215,8 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
214215
j=0;
215216
k=1 <<7;
216217
for (i=0;i<tuple->t_natts; ) {
217-
attr=heap_getattr(tuple,InvalidBuffer,++i,typeinfo,&isnull);
218+
i++;/* heap_getattr is a macro, so no increment */
219+
attr=heap_getattr(tuple,InvalidBuffer,i,typeinfo,&isnull);
218220
if (!isnull)
219221
j |=k;
220222
k >>=1;

‎src/backend/access/index/indexam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.12 1997/08/19 21:29:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.13 1997/08/26 23:31:28 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*index_open - open an index relation by relationId
@@ -69,7 +69,7 @@
6969
#include<utils/relcache.h>
7070
#include<fmgr.h>
7171
#include<storage/lmgr.h>
72-
#include<access/heaptuple.h>
72+
#include<access/heapam.h>
7373

7474
/* ----------------
7575
* undefine macros we aren't going to use that would otherwise

‎src/backend/executor/execJunk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.4 1997/01/10 20:17:25 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.5 1997/08/26 23:31:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,7 +17,6 @@
1717
#include"postgres.h"
1818

1919
#include"utils/palloc.h"
20-
#include"access/heaptuple.h"
2120
#include"access/heapam.h"
2221
#include"executor/executor.h"
2322
#include"nodes/relation.h"

‎src/backend/executor/nodeUnique.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.6 1997/01/10 20:17:38 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.7 1997/08/26 23:31:44 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -31,7 +31,6 @@
3131
#include"executor/nodeUnique.h"
3232
#include"optimizer/clauses.h"
3333
#include"access/heapam.h"
34-
#include"access/heaptuple.h"
3534
#include"access/printtup.h"/* for typtoout() */
3635
#include"utils/builtins.h"/* for namecpy()*/
3736

‎src/include/access/heapam.h

Lines changed: 26 additions & 3 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.7 1997/08/19 21:37:30 momjian Exp $
9+
* $Id: heapam.h,v 1.8 1997/08/26 23:31:53 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -78,6 +78,30 @@ typedef HeapAccessStatisticsData *HeapAccessStatistics;
7878
#defineIncrHeapAccessStat(x) \
7979
(heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
8080

81+
/* ----------------
82+
* heap_getattr
83+
*
84+
* Find a particular field in a row represented as a heap tuple.
85+
* We return a pointer into that heap tuple, which points to the
86+
* first byte of the value of the field in question.
87+
*
88+
* If the field in question has a NULL value, we return a null
89+
* pointer and return <*isnull> == true. Otherwise, we return
90+
* <*isnull> == false.
91+
*
92+
* <tup> is the pointer to the heap tuple. <attnum> is the attribute
93+
* number of the column (field) caller wants. <tupleDesc> is a
94+
* pointer to the structure describing the row and all its fields.
95+
* ---------------- */
96+
#defineheap_getattr(tup,b,attnum,tupleDesc,isnull) \
97+
(AssertMacro((tup) != NULL) ? \
98+
((attnum) > (int) (tup)->t_natts) ? \
99+
(((isnull) ? (*(isnull) = true) : NULL), (char *) NULL) : \
100+
((attnum) > 0) ? \
101+
fastgetattr((tup), (attnum), (tupleDesc), (isnull)) : \
102+
(((isnull) ? (*(isnull) = false) : NULL), heap_getsysattr((tup), (b), (attnum))) : \
103+
(char *) NULL)
104+
81105
externHeapAccessStatisticsheap_access_stats;/* in stats.c */
82106

83107
/* ----------------
@@ -114,10 +138,9 @@ extern void DataFill(char *data, TupleDesc tupleDesc,
114138
externintheap_attisnull(HeapTupletup,intattnum);
115139
externintheap_sysattrlen(AttrNumberattno);
116140
externboolheap_sysattrbyval(AttrNumberattno);
141+
externchar*heap_getsysattr(HeapTupletup,Bufferb,intattnum);
117142
externchar*fastgetattr(HeapTupletup,intattnum,
118143
TupleDescatt,bool*isnull);
119-
externchar*heap_getattr(HeapTupletup,Bufferb,intattnum,
120-
TupleDescatt,bool*isnull);
121144
externHeapTupleheap_copytuple(HeapTupletuple);
122145
externHeapTupleheap_formtuple(TupleDesctupleDescriptor,
123146
Datumvalue[],charnulls[]);

‎src/include/access/heaptuple.h

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

‎src/include/storage/bufpage.h

Lines changed: 4 additions & 4 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: bufpage.h,v 1.9 1997/08/24 23:08:01 momjian Exp $
9+
* $Id: bufpage.h,v 1.10 1997/08/26 23:31:58 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -221,7 +221,7 @@ typedef enum {
221221
*Assumes page is locked.
222222
*/
223223
#definePageGetSpecialSize(page) \
224-
((uint16) (PageGetPageSize(page) - ((PageHeader)page)->pd_special))
224+
((uint16) (PageGetPageSize(page) - ((PageHeader)(page))->pd_special))
225225

226226
/*
227227
* PageGetSpecialPointer --
@@ -245,8 +245,8 @@ typedef enum {
245245
*/
246246
#definePageGetItem(page,itemId) \
247247
(AssertMacro(PageIsValid(page)) ? \
248-
AssertMacro(itemId->lp_flags & LP_USED) ? \
249-
(Item)(((char *)page) + itemId->lp_off) : false : false)
248+
AssertMacro((itemId)->lp_flags & LP_USED) ? \
249+
(Item)(((char *)(page)) +(itemId)->lp_off) : false : false)
250250

251251
/*
252252
* BufferGetPageSize --

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp