mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
Use int64 for number of entries in pg_stat_statements
Commit 13b935cd changed hash_get_num_entries to return int64 instead
of long. This fixes a few more users of hash_get_num_entries which
were missed in the original commit.
PGSS_FILE_HEADER is left unchanged since this only affects as of yet
unreleased versions of PostgreSQL. Backpatch to v19 where the int64
change was performed.
Author: Karina Litskevich <litskevichkarina@gmail.com>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/CACiT8iYTkc33YWaA2D3t51Y5s=GqBO7T1zX7bkpSmet2njcLLw@mail.gmail.com
Backpatch-through: 19
This commit is contained in:
@@ -506,7 +506,7 @@ static void
|
||||
pgss_shmem_request(void *arg)
|
||||
{
|
||||
ShmemRequestHash(.name = "pg_stat_statements hash",
|
||||
.nelems = pgss_max,
|
||||
.nelems = (int64) pgss_max,
|
||||
.hash_info.keysize = sizeof(pgssHashKey),
|
||||
.hash_info.entrysize = sizeof(pgssEntry),
|
||||
.hash_flags = HASH_ELEM | HASH_BLOBS,
|
||||
@@ -533,9 +533,8 @@ pgss_shmem_init(void *arg)
|
||||
FILE *file = NULL;
|
||||
FILE *qfile = NULL;
|
||||
uint32 header;
|
||||
int32 num;
|
||||
int64 num;
|
||||
int32 pgver;
|
||||
int32 i;
|
||||
int buffer_size;
|
||||
char *buffer = NULL;
|
||||
|
||||
@@ -612,14 +611,14 @@ pgss_shmem_init(void *arg)
|
||||
|
||||
if (fread(&header, sizeof(uint32), 1, file) != 1 ||
|
||||
fread(&pgver, sizeof(uint32), 1, file) != 1 ||
|
||||
fread(&num, sizeof(int32), 1, file) != 1)
|
||||
fread(&num, sizeof(int64), 1, file) != 1)
|
||||
goto read_error;
|
||||
|
||||
if (header != PGSS_FILE_HEADER ||
|
||||
pgver != PGSS_PG_MAJOR_VERSION)
|
||||
goto data_error;
|
||||
|
||||
for (i = 0; i < num; i++)
|
||||
for (int64 i = 0; i < num; i++)
|
||||
{
|
||||
pgssEntry temp;
|
||||
pgssEntry *entry;
|
||||
@@ -737,7 +736,7 @@ pgss_shmem_shutdown(int code, Datum arg)
|
||||
char *qbuffer = NULL;
|
||||
Size qbuffer_size = 0;
|
||||
HASH_SEQ_STATUS hash_seq;
|
||||
int32 num_entries;
|
||||
int64 num_entries;
|
||||
pgssEntry *entry;
|
||||
|
||||
/* Don't try to dump during a crash. */
|
||||
@@ -761,7 +760,7 @@ pgss_shmem_shutdown(int code, Datum arg)
|
||||
if (fwrite(&PGSS_PG_MAJOR_VERSION, sizeof(uint32), 1, file) != 1)
|
||||
goto error;
|
||||
num_entries = hash_get_num_entries(pgss_hash);
|
||||
if (fwrite(&num_entries, sizeof(int32), 1, file) != 1)
|
||||
if (fwrite(&num_entries, sizeof(int64), 1, file) != 1)
|
||||
goto error;
|
||||
|
||||
qbuffer = qtext_load_file(&qbuffer_size);
|
||||
@@ -2086,7 +2085,7 @@ entry_alloc(pgssHashKey *key, Size query_offset, int query_len, int encoding,
|
||||
bool found;
|
||||
|
||||
/* Make space if needed */
|
||||
while (hash_get_num_entries(pgss_hash) >= pgss_max)
|
||||
while (hash_get_num_entries(pgss_hash) >= (int64) pgss_max)
|
||||
entry_dealloc();
|
||||
|
||||
/* Find or create an entry with desired hash code */
|
||||
|
||||
Reference in New Issue
Block a user