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

Remove erroneous cast to size_t in BID_HASH_FUNC#10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ololobus merged 1 commit intopostgrespro:masterfromfunny-falcon:patch-1
May 24, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletionsengine.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -654,7 +654,7 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
ForkNumber forknum, BlockNumber blocknum)
{
PtBlockIdbid;
size_thash;
uint64hash;
size_tslot1;
size_tslot2;
XLogRecPtrnew_lsn;
Expand All@@ -676,8 +676,8 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode,
bid.blocknum = blocknum;

hash = BID_HASH_FUNC(bid);
slot1 = hash % PtrackContentNblocks;
slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks;
slot1 =(size_t)(hash % PtrackContentNblocks);
slot2 = (size_t)(((hash << 32) | (hash >> 32)) % PtrackContentNblocks);

if (RecoveryInProgress())
new_lsn = GetXLogReplayRecPtr(NULL);
Expand Down
2 changes: 1 addition & 1 deletionengine.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,7 +86,7 @@ typedef PtrackMapHdr * PtrackMap;
/* Block address 'bid' to hash. To get slot position in map should be divided
* with '% PtrackContentNblocks' */
#define BID_HASH_FUNC(bid) \
(size_t)(DatumGetUInt64(hash_any_extended((unsigned char *)&bid, sizeof(bid), 0)))
(DatumGetUInt64(hash_any_extended((unsigned char *)&bid, sizeof(bid), 0)))
Copy link
Contributor

@ololobusololobusMay 24, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, thissize_t seems to be not correct, since it is 32 bit wide on 32 bit systems, which is not what we want here. However, next we assign this value tohash variable, which again has asize_t type, so this change alone does not has much sense, doesn't it? Probably we should change all appearances ofsize_t used for hash map reference touint64 for portability?

Copy link
ContributorAuthor

@funny-falconfunny-falconMay 24, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yep, I recognizehash variable as well. I've just push-forced branch.


/*
* Per process pointer to shared ptrack_map
Expand Down
6 changes: 3 additions & 3 deletionsptrack.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -487,7 +487,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)

while (true)
{
size_thash;
uint64hash;
size_tslot1;
size_tslot2;
XLogRecPtrupdate_lsn1;
Expand DownExpand Up@@ -535,7 +535,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
}

hash = BID_HASH_FUNC(ctx->bid);
slot1 = hash % PtrackContentNblocks;
slot1 =(size_t)(hash % PtrackContentNblocks);

update_lsn1 = pg_atomic_read_u64(&ptrack_map->entries[slot1]);

Expand All@@ -547,7 +547,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS)
/* Only probe the second slot if the first one is marked */
if (update_lsn1 >= ctx->lsn)
{
slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks;
slot2 = (size_t)(((hash << 32) | (hash >> 32)) % PtrackContentNblocks);
update_lsn2 = pg_atomic_read_u64(&ptrack_map->entries[slot2]);

if (update_lsn2 != InvalidXLogRecPtr)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp