mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-30 21:47:19 +02:00
Fix frontend version of sh_error() in simplehash.h.
The code does not expect sh_error() to return, but the patch that made this header usable in frontend didn't get that memo. While here, plaster unlikely() on the tests that decide whether to invoke sh_error(), and add our standard copyright notice. Noted by Andres Freund. Back-patch to v13 where this frontend support came in. Discussion: https://postgr.es/m/0D54435C-1199-4361-9D74-2FBDCF8EA164@anarazel.de
This commit is contained in:
parent
4760060235
commit
2e01d050d9
@ -55,6 +55,11 @@
|
|||||||
* presence is relevant to determine whether a lookup needs to continue
|
* presence is relevant to determine whether a lookup needs to continue
|
||||||
* looking or is done - buckets following a deleted element are shifted
|
* looking or is done - buckets following a deleted element are shifted
|
||||||
* backwards, unless they're empty or already at their optimal position.
|
* backwards, unless they're empty or already at their optimal position.
|
||||||
|
*
|
||||||
|
* Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
|
||||||
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
|
*
|
||||||
|
* src/include/lib/simplehash.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "port/pg_bitutils.h"
|
#include "port/pg_bitutils.h"
|
||||||
@ -218,7 +223,8 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
|
|||||||
#define SIMPLEHASH_H
|
#define SIMPLEHASH_H
|
||||||
|
|
||||||
#ifdef FRONTEND
|
#ifdef FRONTEND
|
||||||
#define sh_error(...) pg_log_error(__VA_ARGS__)
|
#define sh_error(...) \
|
||||||
|
do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0)
|
||||||
#define sh_log(...) pg_log_info(__VA_ARGS__)
|
#define sh_log(...) pg_log_info(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define sh_error(...) elog(ERROR, __VA_ARGS__)
|
#define sh_error(...) elog(ERROR, __VA_ARGS__)
|
||||||
@ -247,7 +253,7 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
|
|||||||
* Verify that allocation of ->data is possible on this platform, without
|
* Verify that allocation of ->data is possible on this platform, without
|
||||||
* overflowing Size.
|
* overflowing Size.
|
||||||
*/
|
*/
|
||||||
if ((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2)
|
if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2))
|
||||||
sh_error("hash table too large");
|
sh_error("hash table too large");
|
||||||
|
|
||||||
/* now set size */
|
/* now set size */
|
||||||
@ -532,10 +538,8 @@ restart:
|
|||||||
*/
|
*/
|
||||||
if (unlikely(tb->members >= tb->grow_threshold))
|
if (unlikely(tb->members >= tb->grow_threshold))
|
||||||
{
|
{
|
||||||
if (tb->size == SH_MAX_SIZE)
|
if (unlikely(tb->size == SH_MAX_SIZE))
|
||||||
{
|
|
||||||
sh_error("hash table size exceeded");
|
sh_error("hash table size exceeded");
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When optimizing, it can be very useful to print these out.
|
* When optimizing, it can be very useful to print these out.
|
||||||
|
Loading…
Reference in New Issue
Block a user