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

Commitda41d71

Browse files
committed
simplehash: Allow for use in frontend code.
Commit4899504 removed the largestbarrier to use of simplehash in frontend code, but there's one moreproblem: it uses elog(ERROR, ...) or elog(LOG, ...) in a couple ofplaces. Work around that by changing those to pg_log_error() andpg_log_info() when FRONTEND is defined.Patch by me, reviewed by Andres Freund.Discussion:http://postgr.es/m/CA+Tgmob8oyh02NrZW=xCScB+5GyJ-jVowE3+TWTUmPF=FsGWTA@mail.gmail.com
1 parent4899504 commitda41d71

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

‎src/include/lib/simplehash.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ sh_pow2(uint64 num)
236236
return ((uint64)1) <<sh_log2(num);
237237
}
238238

239+
#ifdefFRONTEND
240+
#definesh_error(...) pg_log_error(__VA_ARGS__)
241+
#definesh_log(...) pg_log_info(__VA_ARGS__)
242+
#else
243+
#definesh_error(...) elog(ERROR, __VA_ARGS__)
244+
#definesh_log(...) elog(LOG, __VA_ARGS__)
245+
#endif
246+
239247
#endif
240248

241249
/*
@@ -258,8 +266,8 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint32 newsize)
258266
* Verify that allocation of ->data is possible on this platform, without
259267
* overflowing Size.
260268
*/
261-
if ((((uint64)sizeof(SH_ELEMENT_TYPE))*size) >=MaxAllocHugeSize)
262-
elog(ERROR,"hash table too large");
269+
if ((((uint64)sizeof(SH_ELEMENT_TYPE))*size) >=SIZE_MAX /2)
270+
sh_error("hash table too large");
263271

264272
/* now set size */
265273
tb->size=size;
@@ -549,7 +557,7 @@ SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
549557
{
550558
if (tb->size==SH_MAX_SIZE)
551559
{
552-
elog(ERROR,"hash table size exceeded");
560+
sh_error("hash table size exceeded");
553561
}
554562

555563
/*
@@ -1001,7 +1009,7 @@ SH_STAT(SH_TYPE * tb)
10011009
avg_collisions=0;
10021010
}
10031011

1004-
elog(LOG,"size: "UINT64_FORMAT", members: %u, filled: %f, total chain: %u, max chain: %u, avg chain: %f, total_collisions: %u, max_collisions: %i, avg_collisions: %f",
1012+
sh_log("size: "UINT64_FORMAT", members: %u, filled: %f, total chain: %u, max chain: %u, avg chain: %f, total_collisions: %u, max_collisions: %i, avg_collisions: %f",
10051013
tb->size,tb->members,fillfactor,total_chain_length,max_chain_length,avg_chain_length,
10061014
total_collisions,max_collisions,avg_collisions);
10071015
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp