Compilation issues for HASH_STATISTICS and HASH_DEBUG options
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>
From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: "'pgsql-hackers@lists.postgresql.org'" <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-14T11:48:35Z
Lists: pgsql-hackers
Attachments
- 0001-Fix-broken-code-for-HASH_DEBUG-and-HASH_STATISTICS.patch (application/octet-stream) patch 0001
Dear hackers,
I found that postgres could not be built if a complier option HASH_STATISTICS is
set [1]. Also, I found HASH_DEBUG option caused warnings [2]. Usage of the are
mentioned at the code comments in dynahash.c.
I'm not sure whether we would keep supporting them because no one may not have
used anymore now.
Anyway, I tried to fix the error/warnings. Please see attached.
[1]:
```
dynahash.c: In function ‘hash_update_hash_key’:
dynahash.c:1178:9: error: ‘hctl’ undeclared (first use in this function)
1178 | hctl->accesses++;
| ^~~~
```
[2]:
```
dynahash.c: In function ‘init_htab’:
dynahash.c:779:68: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 12 has type ‘uint32’ {aka ‘unsigned int’} [-Wformat=]
779 | fprintf(stderr, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%ld\n%s%u\n%s%x\n%s%x\n%s%ld\n",
| ~~^
| |
| long int
| %d
......
784 | "MAX BUCKET ", hctl->max_bucket,
| ~~~~~~~~~~~~~~~~
| |
|
dynahash.c:779:86: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 18 has type ‘long int’ [-Wformat=]
779 | fprintf(stderr, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%ld\n%s%u\n%s%x\n%s%x\n%s%ld\n",
| ~^
| |
| unsigned in
| %lx
......
787 | "NSEGS ", hctl->nsegs);
| ~~~~~~~~~~~
| |
| long int
dynahash.c:779:90: warning: format ‘%s’ expects a matching ‘char *’ argument [-Wformat=]
779 | fprintf(stderr, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%ld\n%s%u\n%s%x\n%s%x\n%s%ld\n",
| ~^
| |
| char *
dynahash.c:779:93: warning: format ‘%ld’ expects a matching ‘long int’ argument [-Wformat=]
779 | fprintf(stderr, "init_htab:\n%s%p\n%s%ld\n%s%ld\n%s%d\n%s%ld\n%s%u\n%s%x\n%s%x\n%s%ld\n",
| ~~^
| |
| long int
```
Best regards,
Hayato Kuroda
FUJITSU LIMITED
Commits
-
Remove HASH_DEBUG output from dynahash.c
- a98ccf727ebb 19 (unreleased) landed
-
Use elog(DEBUG4) for dynahash.c statistics output
- 05fcb9667c37 19 (unreleased) landed
-
Fix invalid format string in HASH_DEBUG code
- 2c7c08a090f2 14.20 landed
- 199a347d29e5 15.15 landed
- d809494cdfc5 16.11 landed
- 04b384b3efb2 17.7 landed
- 1571c7ca5dc9 18.0 landed
- 296cba276081 19 (unreleased) landed
-
Fix failing -D HASH_STATISTICS builds
- efe705b05cc1 17.7 landed
- e4ba326295c5 18.0 landed
- ca38912512a9 19 (unreleased) landed
-
Refactor initial hash lookup in dynahash.c
- cc5ef90edd80 17.0 cited
-
Remove large fill factor support from dynahash.c.
- be0a6666656e 14.0 cited
-
Remove broken and useless entry-count printing in HASH_DEBUG code.
- 9d4e56699957 10.0 cited
-
Partition the freelist for shared dynahash tables.
- 44ca4022f3f9 9.6.0 cited