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

Commit5997386

Browse files
committed
Remove the no-longer-useful HashItem/HashItemData level of structure.
Same motivation as for BTItem.
1 parentc389760 commit5997386

File tree

7 files changed

+34
-98
lines changed

7 files changed

+34
-98
lines changed

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.82 2005/11/06 19:29:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.83 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -91,7 +91,6 @@ hashbuildCallback(Relation index,
9191
{
9292
HashBuildState*buildstate= (HashBuildState*)state;
9393
IndexTupleitup;
94-
HashItemhitem;
9594

9695
/* form an index tuple and point it at the heap tuple */
9796
itup=index_form_tuple(RelationGetDescr(index),values,isnull);
@@ -104,13 +103,10 @@ hashbuildCallback(Relation index,
104103
return;
105104
}
106105

107-
hitem=_hash_formitem(itup);
108-
109-
_hash_doinsert(index,hitem);
106+
_hash_doinsert(index,itup);
110107

111108
buildstate->indtuples+=1;
112109

113-
pfree(hitem);
114110
pfree(itup);
115111
}
116112

@@ -132,7 +128,6 @@ hashinsert(PG_FUNCTION_ARGS)
132128
RelationheapRel= (Relation)PG_GETARG_POINTER(4);
133129
boolcheckUnique=PG_GETARG_BOOL(5);
134130
#endif
135-
HashItemhitem;
136131
IndexTupleitup;
137132

138133
/* generate an index tuple */
@@ -154,11 +149,8 @@ hashinsert(PG_FUNCTION_ARGS)
154149
PG_RETURN_BOOL(false);
155150
}
156151

157-
hitem=_hash_formitem(itup);
158-
159-
_hash_doinsert(rel,hitem);
152+
_hash_doinsert(rel,itup);
160153

161-
pfree(hitem);
162154
pfree(itup);
163155

164156
PG_RETURN_BOOL(true);
@@ -565,12 +557,12 @@ hashbulkdelete(PG_FUNCTION_ARGS)
565557
maxoffno=PageGetMaxOffsetNumber(page);
566558
while (offno <=maxoffno)
567559
{
568-
HashItemhitem;
560+
IndexTupleitup;
569561
ItemPointerhtup;
570562

571-
hitem= (HashItem)PageGetItem(page,
572-
PageGetItemId(page,offno));
573-
htup=&(hitem->hash_itup.t_tid);
563+
itup= (IndexTuple)PageGetItem(page,
564+
PageGetItemId(page,offno));
565+
htup=&(itup->t_tid);
574566
if (callback(htup,callback_state))
575567
{
576568
/* delete the item from the page */

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

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.40 2005/11/06 19:29:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.41 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -20,23 +20,21 @@
2020

2121

2222
staticOffsetNumber_hash_pgaddtup(Relationrel,Bufferbuf,
23-
Sizeitemsize,HashItemhitem);
23+
Sizeitemsize,IndexTupleitup);
2424

2525

2626
/*
27-
*_hash_doinsert() -- Handle insertion of a singleHashItem in the table.
27+
*_hash_doinsert() -- Handle insertion of a singleindex tuple.
2828
*
2929
*This routine is called by the public interface routines, hashbuild
30-
*and hashinsert. By here, hashitem is completely filled in.
31-
*The datum to be used as a "key" is in the hashitem.
30+
*and hashinsert. By here, itup is completely filled in.
3231
*/
3332
void
34-
_hash_doinsert(Relationrel,HashItemhitem)
33+
_hash_doinsert(Relationrel,IndexTupleitup)
3534
{
3635
Bufferbuf;
3736
Buffermetabuf;
3837
HashMetaPagemetap;
39-
IndexTupleitup;
4038
BlockNumberblkno;
4139
Pagepage;
4240
HashPageOpaquepageopaque;
@@ -51,17 +49,14 @@ _hash_doinsert(Relation rel, HashItem hitem)
5149
* Compute the hash key for the item. We do this first so as not to need
5250
* to hold any locks while running the hash function.
5351
*/
54-
itup=&(hitem->hash_itup);
5552
if (rel->rd_rel->relnatts!=1)
5653
elog(ERROR,"hash indexes support only one index key");
5754
datum=index_getattr(itup,1,RelationGetDescr(rel),&isnull);
5855
Assert(!isnull);
5956
hashkey=_hash_datum2hashkey(rel,datum);
6057

6158
/* compute item size too */
62-
itemsz=IndexTupleDSize(hitem->hash_itup)
63-
+ (sizeof(HashItemData)-sizeof(IndexTupleData));
64-
59+
itemsz=IndexTupleDSize(*itup);
6560
itemsz=MAXALIGN(itemsz);/* be safe, PageAddItem will do this but we
6661
* need to be consistent */
6762

@@ -157,7 +152,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
157152
}
158153

159154
/* found page with enough space, so add the item here */
160-
(void)_hash_pgaddtup(rel,buf,itemsz,hitem);
155+
(void)_hash_pgaddtup(rel,buf,itemsz,itup);
161156

162157
/* write and release the modified page */
163158
_hash_wrtbuf(rel,buf);
@@ -199,7 +194,7 @@ static OffsetNumber
199194
_hash_pgaddtup(Relationrel,
200195
Bufferbuf,
201196
Sizeitemsize,
202-
HashItemhitem)
197+
IndexTupleitup)
203198
{
204199
OffsetNumberitup_off;
205200
Pagepage;
@@ -208,7 +203,7 @@ _hash_pgaddtup(Relation rel,
208203
page=BufferGetPage(buf);
209204

210205
itup_off=OffsetNumberNext(PageGetMaxOffsetNumber(page));
211-
if (PageAddItem(page, (Item)hitem,itemsize,itup_off,LP_USED)
206+
if (PageAddItem(page, (Item)itup,itemsize,itup_off,LP_USED)
212207
==InvalidOffsetNumber)
213208
elog(ERROR,"failed to add index item to \"%s\"",
214209
RelationGetRelationName(rel));

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.49 2005/11/22 18:17:05 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.50 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
* NOTES
1414
* Overflow pages look like ordinary relation pages.
@@ -561,7 +561,7 @@ _hash_squeezebucket(Relation rel,
561561
HashPageOpaqueropaque;
562562
OffsetNumberwoffnum;
563563
OffsetNumberroffnum;
564-
HashItemhitem;
564+
IndexTupleitup;
565565
Sizeitemsz;
566566

567567
/*
@@ -608,10 +608,9 @@ _hash_squeezebucket(Relation rel,
608608
/* this test is needed in case page is empty on entry */
609609
if (roffnum <=PageGetMaxOffsetNumber(rpage))
610610
{
611-
hitem= (HashItem)PageGetItem(rpage,
612-
PageGetItemId(rpage,roffnum));
613-
itemsz=IndexTupleDSize(hitem->hash_itup)
614-
+ (sizeof(HashItemData)-sizeof(IndexTupleData));
611+
itup= (IndexTuple)PageGetItem(rpage,
612+
PageGetItemId(rpage,roffnum));
613+
itemsz=IndexTupleDSize(*itup);
615614
itemsz=MAXALIGN(itemsz);
616615

617616
/*
@@ -645,7 +644,7 @@ _hash_squeezebucket(Relation rel,
645644
* we have found room so insert on the "write" page.
646645
*/
647646
woffnum=OffsetNumberNext(PageGetMaxOffsetNumber(wpage));
648-
if (PageAddItem(wpage, (Item)hitem,itemsz,woffnum,LP_USED)
647+
if (PageAddItem(wpage, (Item)itup,itemsz,woffnum,LP_USED)
649648
==InvalidOffsetNumber)
650649
elog(ERROR,"failed to add index item to \"%s\"",
651650
RelationGetRelationName(rel));

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.54 2005/11/22 18:17:05 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.55 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
* NOTES
1414
* Postgres hash pages look like ordinary relation pages. The opaque
@@ -249,7 +249,7 @@ _hash_metapinit(Relation rel)
249249
*/
250250
data_width=get_typavgwidth(RelationGetDescr(rel)->attrs[0]->atttypid,
251251
RelationGetDescr(rel)->attrs[0]->atttypmod);
252-
item_width=MAXALIGN(sizeof(HashItemData))+MAXALIGN(data_width)+
252+
item_width=MAXALIGN(sizeof(IndexTupleData))+MAXALIGN(data_width)+
253253
sizeof(ItemIdData);/* include the line pointer */
254254
ffactor= (BLCKSZ*3 /4) /item_width;
255255
/* keep to a sane range */
@@ -539,7 +539,6 @@ _hash_splitbucket(Relation rel,
539539
BlockNumbernblkno;
540540
boolnull;
541541
Datumdatum;
542-
HashItemhitem;
543542
HashPageOpaqueoopaque;
544543
HashPageOpaquenopaque;
545544
IndexTupleitup;
@@ -618,8 +617,7 @@ _hash_splitbucket(Relation rel,
618617
* It is annoying to call the hash function while holding locks, but
619618
* releasing and relocking the page for each tuple is unappealing too.
620619
*/
621-
hitem= (HashItem)PageGetItem(opage,PageGetItemId(opage,ooffnum));
622-
itup=&(hitem->hash_itup);
620+
itup= (IndexTuple)PageGetItem(opage,PageGetItemId(opage,ooffnum));
623621
datum=index_getattr(itup,1,itupdesc,&null);
624622
Assert(!null);
625623

@@ -633,9 +631,7 @@ _hash_splitbucket(Relation rel,
633631
* current page in the new bucket, we must allocate a new overflow
634632
* page and place the tuple on that page instead.
635633
*/
636-
itemsz=IndexTupleDSize(hitem->hash_itup)
637-
+ (sizeof(HashItemData)-sizeof(IndexTupleData));
638-
634+
itemsz=IndexTupleDSize(*itup);
639635
itemsz=MAXALIGN(itemsz);
640636

641637
if (PageGetFreeSpace(npage)<itemsz)
@@ -650,7 +646,7 @@ _hash_splitbucket(Relation rel,
650646
}
651647

652648
noffnum=OffsetNumberNext(PageGetMaxOffsetNumber(npage));
653-
if (PageAddItem(npage, (Item)hitem,itemsz,noffnum,LP_USED)
649+
if (PageAddItem(npage, (Item)itup,itemsz,noffnum,LP_USED)
654650
==InvalidOffsetNumber)
655651
elog(ERROR,"failed to add index item to \"%s\"",
656652
RelationGetRelationName(rel));

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.42 2005/11/06 19:29:00 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.43 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -37,7 +37,6 @@ _hash_next(IndexScanDesc scan, ScanDirection dir)
3737
Pagepage;
3838
OffsetNumberoffnum;
3939
ItemPointercurrent;
40-
HashItemhitem;
4140
IndexTupleitup;
4241

4342
/* we still have the buffer pinned and read-locked */
@@ -55,8 +54,7 @@ _hash_next(IndexScanDesc scan, ScanDirection dir)
5554
offnum=ItemPointerGetOffsetNumber(current);
5655
_hash_checkpage(rel,buf,LH_BUCKET_PAGE |LH_OVERFLOW_PAGE);
5756
page=BufferGetPage(buf);
58-
hitem= (HashItem)PageGetItem(page,PageGetItemId(page,offnum));
59-
itup=&hitem->hash_itup;
57+
itup= (IndexTuple)PageGetItem(page,PageGetItemId(page,offnum));
6058
scan->xs_ctup.t_self=itup->t_tid;
6159

6260
return true;
@@ -126,7 +124,6 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
126124
Pagepage;
127125
HashPageOpaqueopaque;
128126
HashMetaPagemetap;
129-
HashItemhitem;
130127
IndexTupleitup;
131128
ItemPointercurrent;
132129
OffsetNumberoffnum;
@@ -218,8 +215,7 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
218215
offnum=ItemPointerGetOffsetNumber(current);
219216
_hash_checkpage(rel,buf,LH_BUCKET_PAGE |LH_OVERFLOW_PAGE);
220217
page=BufferGetPage(buf);
221-
hitem= (HashItem)PageGetItem(page,PageGetItemId(page,offnum));
222-
itup=&hitem->hash_itup;
218+
itup= (IndexTuple)PageGetItem(page,PageGetItemId(page,offnum));
223219
scan->xs_ctup.t_self=itup->t_tid;
224220

225221
return true;
@@ -248,7 +244,6 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
248244
OffsetNumbermaxoff;
249245
OffsetNumberoffnum;
250246
BlockNumberblkno;
251-
HashItemhitem;
252247
IndexTupleitup;
253248

254249
current=&(scan->currentItemData);
@@ -345,8 +340,7 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
345340
}
346341

347342
/* get ready to check this tuple */
348-
hitem= (HashItem)PageGetItem(page,PageGetItemId(page,offnum));
349-
itup=&hitem->hash_itup;
343+
itup= (IndexTuple)PageGetItem(page,PageGetItemId(page,offnum));
350344
}while (!_hash_checkqual(scan,itup));
351345

352346
/* if we made it to here, we've found a valid tuple */

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.45 2006/01/14 22:03:35 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.46 2006/01/25 23:26:11 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -60,38 +60,6 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
6060
return true;
6161
}
6262

63-
/*
64-
* _hash_formitem -- construct a hash index entry
65-
*/
66-
HashItem
67-
_hash_formitem(IndexTupleitup)
68-
{
69-
intnbytes_hitem;
70-
HashItemhitem;
71-
Sizetuplen;
72-
73-
/* disallow nulls in hash keys */
74-
if (IndexTupleHasNulls(itup))
75-
ereport(ERROR,
76-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
77-
errmsg("hash indexes cannot contain null keys")));
78-
79-
/*
80-
* make a copy of the index tuple (XXX do we still need to copy?)
81-
*
82-
* HashItemData used to have more fields than IndexTupleData, but no
83-
* longer...
84-
*/
85-
tuplen=IndexTupleSize(itup);
86-
nbytes_hitem=tuplen+
87-
(sizeof(HashItemData)-sizeof(IndexTupleData));
88-
89-
hitem= (HashItem)palloc(nbytes_hitem);
90-
memcpy(&(hitem->hash_itup),itup,tuplen);
91-
92-
returnhitem;
93-
}
94-
9563
/*
9664
* _hash_datum2hashkey -- given a Datum, call the index's hash procedure
9765
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp