pgsql: Avoid type cheats for invalid dsa_handles and dshash_table_handl

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid type cheats for invalid dsa_handles and dshash_table_handl
Date: 2023-01-25 16:48:42
Message-ID: E1pKiwz-005RTp-Q0@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid type cheats for invalid dsa_handles and dshash_table_handles.

Invent separate macros for "invalid" values of these types, so that
we needn't embed knowledge of their representations into calling code.
These are all zeroes anyway ATM, so this is not fixing any live bug,
but it makes the code cleaner and more future-proof.

I (tgl) also chose to move DSM_HANDLE_INVALID into dsm_impl.h,
since it seems like it should live beside the typedef for dsm_handle.

Hou Zhijie, Nathan Bossart, Kyotaro Horiguchi, Tom Lane

Discussion: https://postgr.es/m/OS0PR01MB5716860B1454C34E5B179B6694C99@OS0PR01MB5716.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3b4ac33254e1291f0b3c94f1cb770137c418ce2e

Modified Files
--------------
src/backend/replication/logical/launcher.c | 8 ++++----
src/backend/storage/ipc/dsm.c | 5 ++---
src/backend/utils/mmgr/dsa.c | 4 ++--
src/include/lib/dshash.h | 3 +++
src/include/storage/dsm.h | 3 ---
src/include/storage/dsm_impl.h | 3 +++
src/include/utils/dsa.h | 4 ++++
7 files changed, 18 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2023-01-25 17:49:45 Re: pgsql: Rename contrib module basic_archive to basic_wal_module
Previous Message Michael Paquier 2023-01-25 11:02:25 pgsql: doc: Fix network_ops -> inet_ops in SpGiST operator class list