Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
5997386a
Commit
5997386a
authored
Jan 25, 2006
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the no-longer-useful HashItem/HashItemData level of structure.
Same motivation as for BTItem.
parent
c389760c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
34 additions
and
98 deletions
+34
-98
src/backend/access/hash/hash.c
src/backend/access/hash/hash.c
+7
-15
src/backend/access/hash/hashinsert.c
src/backend/access/hash/hashinsert.c
+9
-14
src/backend/access/hash/hashovfl.c
src/backend/access/hash/hashovfl.c
+6
-7
src/backend/access/hash/hashpage.c
src/backend/access/hash/hashpage.c
+5
-9
src/backend/access/hash/hashsearch.c
src/backend/access/hash/hashsearch.c
+4
-10
src/backend/access/hash/hashutil.c
src/backend/access/hash/hashutil.c
+1
-33
src/include/access/hash.h
src/include/access/hash.h
+2
-10
No files found.
src/backend/access/hash/hash.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.8
2 2005/11/06 19:29:00
tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.8
3 2006/01/25 23:26:11
tgl Exp $
*
* NOTES
* This file contains only the public interface routines.
...
...
@@ -91,7 +91,6 @@ hashbuildCallback(Relation index,
{
HashBuildState
*
buildstate
=
(
HashBuildState
*
)
state
;
IndexTuple
itup
;
HashItem
hitem
;
/* form an index tuple and point it at the heap tuple */
itup
=
index_form_tuple
(
RelationGetDescr
(
index
),
values
,
isnull
);
...
...
@@ -104,13 +103,10 @@ hashbuildCallback(Relation index,
return
;
}
hitem
=
_hash_formitem
(
itup
);
_hash_doinsert
(
index
,
hitem
);
_hash_doinsert
(
index
,
itup
);
buildstate
->
indtuples
+=
1
;
pfree
(
hitem
);
pfree
(
itup
);
}
...
...
@@ -132,7 +128,6 @@ hashinsert(PG_FUNCTION_ARGS)
Relation
heapRel
=
(
Relation
)
PG_GETARG_POINTER
(
4
);
bool
checkUnique
=
PG_GETARG_BOOL
(
5
);
#endif
HashItem
hitem
;
IndexTuple
itup
;
/* generate an index tuple */
...
...
@@ -154,11 +149,8 @@ hashinsert(PG_FUNCTION_ARGS)
PG_RETURN_BOOL
(
false
);
}
hitem
=
_hash_formitem
(
itup
);
_hash_doinsert
(
rel
,
hitem
);
_hash_doinsert
(
rel
,
itup
);
pfree
(
hitem
);
pfree
(
itup
);
PG_RETURN_BOOL
(
true
);
...
...
@@ -565,12 +557,12 @@ loop_top:
maxoffno
=
PageGetMaxOffsetNumber
(
page
);
while
(
offno
<=
maxoffno
)
{
HashItem
hitem
;
IndexTuple
itup
;
ItemPointer
htup
;
hitem
=
(
HashItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offno
));
htup
=
&
(
hitem
->
hash_itup
.
t_tid
);
itup
=
(
IndexTuple
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offno
));
htup
=
&
(
itup
->
t_tid
);
if
(
callback
(
htup
,
callback_state
))
{
/* delete the item from the page */
...
...
src/backend/access/hash/hashinsert.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.4
0 2005/11/06 19:29:00
tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashinsert.c,v 1.4
1 2006/01/25 23:26:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -20,23 +20,21 @@
static
OffsetNumber
_hash_pgaddtup
(
Relation
rel
,
Buffer
buf
,
Size
itemsize
,
HashItem
hitem
);
Size
itemsize
,
IndexTuple
itup
);
/*
* _hash_doinsert() -- Handle insertion of a single
HashItem in the tab
le.
* _hash_doinsert() -- Handle insertion of a single
index tup
le.
*
* This routine is called by the public interface routines, hashbuild
* and hashinsert. By here, hashitem is completely filled in.
* The datum to be used as a "key" is in the hashitem.
* and hashinsert. By here, itup is completely filled in.
*/
void
_hash_doinsert
(
Relation
rel
,
HashItem
hitem
)
_hash_doinsert
(
Relation
rel
,
IndexTuple
itup
)
{
Buffer
buf
;
Buffer
metabuf
;
HashMetaPage
metap
;
IndexTuple
itup
;
BlockNumber
blkno
;
Page
page
;
HashPageOpaque
pageopaque
;
...
...
@@ -51,7 +49,6 @@ _hash_doinsert(Relation rel, HashItem hitem)
* Compute the hash key for the item. We do this first so as not to need
* to hold any locks while running the hash function.
*/
itup
=
&
(
hitem
->
hash_itup
);
if
(
rel
->
rd_rel
->
relnatts
!=
1
)
elog
(
ERROR
,
"hash indexes support only one index key"
);
datum
=
index_getattr
(
itup
,
1
,
RelationGetDescr
(
rel
),
&
isnull
);
...
...
@@ -59,9 +56,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
hashkey
=
_hash_datum2hashkey
(
rel
,
datum
);
/* compute item size too */
itemsz
=
IndexTupleDSize
(
hitem
->
hash_itup
)
+
(
sizeof
(
HashItemData
)
-
sizeof
(
IndexTupleData
));
itemsz
=
IndexTupleDSize
(
*
itup
);
itemsz
=
MAXALIGN
(
itemsz
);
/* be safe, PageAddItem will do this but we
* need to be consistent */
...
...
@@ -157,7 +152,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
}
/* found page with enough space, so add the item here */
(
void
)
_hash_pgaddtup
(
rel
,
buf
,
itemsz
,
hitem
);
(
void
)
_hash_pgaddtup
(
rel
,
buf
,
itemsz
,
itup
);
/* write and release the modified page */
_hash_wrtbuf
(
rel
,
buf
);
...
...
@@ -199,7 +194,7 @@ static OffsetNumber
_hash_pgaddtup
(
Relation
rel
,
Buffer
buf
,
Size
itemsize
,
HashItem
hitem
)
IndexTuple
itup
)
{
OffsetNumber
itup_off
;
Page
page
;
...
...
@@ -208,7 +203,7 @@ _hash_pgaddtup(Relation rel,
page
=
BufferGetPage
(
buf
);
itup_off
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
page
));
if
(
PageAddItem
(
page
,
(
Item
)
hitem
,
itemsize
,
itup_off
,
LP_USED
)
if
(
PageAddItem
(
page
,
(
Item
)
itup
,
itemsize
,
itup_off
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
...
...
src/backend/access/hash/hashovfl.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.
49 2005/11/22 18:17:05 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashovfl.c,v 1.
50 2006/01/25 23:26:11 tgl
Exp $
*
* NOTES
* Overflow pages look like ordinary relation pages.
...
...
@@ -561,7 +561,7 @@ _hash_squeezebucket(Relation rel,
HashPageOpaque
ropaque
;
OffsetNumber
woffnum
;
OffsetNumber
roffnum
;
HashItem
hitem
;
IndexTuple
itup
;
Size
itemsz
;
/*
...
...
@@ -608,10 +608,9 @@ _hash_squeezebucket(Relation rel,
/* this test is needed in case page is empty on entry */
if
(
roffnum
<=
PageGetMaxOffsetNumber
(
rpage
))
{
hitem
=
(
HashItem
)
PageGetItem
(
rpage
,
PageGetItemId
(
rpage
,
roffnum
));
itemsz
=
IndexTupleDSize
(
hitem
->
hash_itup
)
+
(
sizeof
(
HashItemData
)
-
sizeof
(
IndexTupleData
));
itup
=
(
IndexTuple
)
PageGetItem
(
rpage
,
PageGetItemId
(
rpage
,
roffnum
));
itemsz
=
IndexTupleDSize
(
*
itup
);
itemsz
=
MAXALIGN
(
itemsz
);
/*
...
...
@@ -645,7 +644,7 @@ _hash_squeezebucket(Relation rel,
* we have found room so insert on the "write" page.
*/
woffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
wpage
));
if
(
PageAddItem
(
wpage
,
(
Item
)
hitem
,
itemsz
,
woffnum
,
LP_USED
)
if
(
PageAddItem
(
wpage
,
(
Item
)
itup
,
itemsz
,
woffnum
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
...
...
src/backend/access/hash/hashpage.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.5
4 2005/11/22 18:17:05 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.5
5 2006/01/25 23:26:11 tgl
Exp $
*
* NOTES
* Postgres hash pages look like ordinary relation pages. The opaque
...
...
@@ -249,7 +249,7 @@ _hash_metapinit(Relation rel)
*/
data_width
=
get_typavgwidth
(
RelationGetDescr
(
rel
)
->
attrs
[
0
]
->
atttypid
,
RelationGetDescr
(
rel
)
->
attrs
[
0
]
->
atttypmod
);
item_width
=
MAXALIGN
(
sizeof
(
HashItem
Data
))
+
MAXALIGN
(
data_width
)
+
item_width
=
MAXALIGN
(
sizeof
(
IndexTuple
Data
))
+
MAXALIGN
(
data_width
)
+
sizeof
(
ItemIdData
);
/* include the line pointer */
ffactor
=
(
BLCKSZ
*
3
/
4
)
/
item_width
;
/* keep to a sane range */
...
...
@@ -539,7 +539,6 @@ _hash_splitbucket(Relation rel,
BlockNumber
nblkno
;
bool
null
;
Datum
datum
;
HashItem
hitem
;
HashPageOpaque
oopaque
;
HashPageOpaque
nopaque
;
IndexTuple
itup
;
...
...
@@ -618,8 +617,7 @@ _hash_splitbucket(Relation rel,
* It is annoying to call the hash function while holding locks, but
* releasing and relocking the page for each tuple is unappealing too.
*/
hitem
=
(
HashItem
)
PageGetItem
(
opage
,
PageGetItemId
(
opage
,
ooffnum
));
itup
=
&
(
hitem
->
hash_itup
);
itup
=
(
IndexTuple
)
PageGetItem
(
opage
,
PageGetItemId
(
opage
,
ooffnum
));
datum
=
index_getattr
(
itup
,
1
,
itupdesc
,
&
null
);
Assert
(
!
null
);
...
...
@@ -633,9 +631,7 @@ _hash_splitbucket(Relation rel,
* current page in the new bucket, we must allocate a new overflow
* page and place the tuple on that page instead.
*/
itemsz
=
IndexTupleDSize
(
hitem
->
hash_itup
)
+
(
sizeof
(
HashItemData
)
-
sizeof
(
IndexTupleData
));
itemsz
=
IndexTupleDSize
(
*
itup
);
itemsz
=
MAXALIGN
(
itemsz
);
if
(
PageGetFreeSpace
(
npage
)
<
itemsz
)
...
...
@@ -650,7 +646,7 @@ _hash_splitbucket(Relation rel,
}
noffnum
=
OffsetNumberNext
(
PageGetMaxOffsetNumber
(
npage
));
if
(
PageAddItem
(
npage
,
(
Item
)
hitem
,
itemsz
,
noffnum
,
LP_USED
)
if
(
PageAddItem
(
npage
,
(
Item
)
itup
,
itemsz
,
noffnum
,
LP_USED
)
==
InvalidOffsetNumber
)
elog
(
ERROR
,
"failed to add index item to
\"
%s
\"
"
,
RelationGetRelationName
(
rel
));
...
...
src/backend/access/hash/hashsearch.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.4
2 2005/11/06 19:29:00
tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashsearch.c,v 1.4
3 2006/01/25 23:26:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -37,7 +37,6 @@ _hash_next(IndexScanDesc scan, ScanDirection dir)
Page
page
;
OffsetNumber
offnum
;
ItemPointer
current
;
HashItem
hitem
;
IndexTuple
itup
;
/* we still have the buffer pinned and read-locked */
...
...
@@ -55,8 +54,7 @@ _hash_next(IndexScanDesc scan, ScanDirection dir)
offnum
=
ItemPointerGetOffsetNumber
(
current
);
_hash_checkpage
(
rel
,
buf
,
LH_BUCKET_PAGE
|
LH_OVERFLOW_PAGE
);
page
=
BufferGetPage
(
buf
);
hitem
=
(
HashItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
itup
=
&
hitem
->
hash_itup
;
itup
=
(
IndexTuple
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
scan
->
xs_ctup
.
t_self
=
itup
->
t_tid
;
return
true
;
...
...
@@ -126,7 +124,6 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
Page
page
;
HashPageOpaque
opaque
;
HashMetaPage
metap
;
HashItem
hitem
;
IndexTuple
itup
;
ItemPointer
current
;
OffsetNumber
offnum
;
...
...
@@ -218,8 +215,7 @@ _hash_first(IndexScanDesc scan, ScanDirection dir)
offnum
=
ItemPointerGetOffsetNumber
(
current
);
_hash_checkpage
(
rel
,
buf
,
LH_BUCKET_PAGE
|
LH_OVERFLOW_PAGE
);
page
=
BufferGetPage
(
buf
);
hitem
=
(
HashItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
itup
=
&
hitem
->
hash_itup
;
itup
=
(
IndexTuple
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
scan
->
xs_ctup
.
t_self
=
itup
->
t_tid
;
return
true
;
...
...
@@ -248,7 +244,6 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
OffsetNumber
maxoff
;
OffsetNumber
offnum
;
BlockNumber
blkno
;
HashItem
hitem
;
IndexTuple
itup
;
current
=
&
(
scan
->
currentItemData
);
...
...
@@ -345,8 +340,7 @@ _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir)
}
/* get ready to check this tuple */
hitem
=
(
HashItem
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
itup
=
&
hitem
->
hash_itup
;
itup
=
(
IndexTuple
)
PageGetItem
(
page
,
PageGetItemId
(
page
,
offnum
));
}
while
(
!
_hash_checkqual
(
scan
,
itup
));
/* if we made it to here, we've found a valid tuple */
...
...
src/backend/access/hash/hashutil.c
View file @
5997386a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.4
5 2006/01/14 22:03:35
tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.4
6 2006/01/25 23:26:11
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -60,38 +60,6 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup)
return
true
;
}
/*
* _hash_formitem -- construct a hash index entry
*/
HashItem
_hash_formitem
(
IndexTuple
itup
)
{
int
nbytes_hitem
;
HashItem
hitem
;
Size
tuplen
;
/* disallow nulls in hash keys */
if
(
IndexTupleHasNulls
(
itup
))
ereport
(
ERROR
,
(
errcode
(
ERRCODE_FEATURE_NOT_SUPPORTED
),
errmsg
(
"hash indexes cannot contain null keys"
)));
/*
* make a copy of the index tuple (XXX do we still need to copy?)
*
* HashItemData used to have more fields than IndexTupleData, but no
* longer...
*/
tuplen
=
IndexTupleSize
(
itup
);
nbytes_hitem
=
tuplen
+
(
sizeof
(
HashItemData
)
-
sizeof
(
IndexTupleData
));
hitem
=
(
HashItem
)
palloc
(
nbytes_hitem
);
memcpy
(
&
(
hitem
->
hash_itup
),
itup
,
tuplen
);
return
hitem
;
}
/*
* _hash_datum2hashkey -- given a Datum, call the index's hash procedure
*/
...
...
src/include/access/hash.h
View file @
5997386a
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/access/hash.h,v 1.6
4 2005/11/06 19:29:0
1 tgl Exp $
* $PostgreSQL: pgsql/src/include/access/hash.h,v 1.6
5 2006/01/25 23:26:1
1 tgl Exp $
*
* NOTES
* modeled after Margo Seltzer's hash implementation for unix.
...
...
@@ -158,13 +158,6 @@ typedef struct HashMetaPageData
typedef
HashMetaPageData
*
HashMetaPage
;
typedef
struct
HashItemData
{
IndexTupleData
hash_itup
;
}
HashItemData
;
typedef
HashItemData
*
HashItem
;
/*
* Maximum size of a hash index item (it's okay to have only one per page)
*/
...
...
@@ -267,7 +260,7 @@ extern Datum hash_any(register const unsigned char *k, register int keylen);
/* private routines */
/* hashinsert.c */
extern
void
_hash_doinsert
(
Relation
rel
,
HashItem
hitem
);
extern
void
_hash_doinsert
(
Relation
rel
,
IndexTuple
itup
);
/* hashovfl.c */
extern
Buffer
_hash_addovflpage
(
Relation
rel
,
Buffer
metabuf
,
Buffer
buf
);
...
...
@@ -305,7 +298,6 @@ extern bool _hash_step(IndexScanDesc scan, Buffer *bufP, ScanDirection dir);
/* hashutil.c */
extern
bool
_hash_checkqual
(
IndexScanDesc
scan
,
IndexTuple
itup
);
extern
HashItem
_hash_formitem
(
IndexTuple
itup
);
extern
uint32
_hash_datum2hashkey
(
Relation
rel
,
Datum
key
);
extern
Bucket
_hash_hashkey2bucket
(
uint32
hashkey
,
uint32
maxbucket
,
uint32
highmask
,
uint32
lowmask
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment