v10-0001-Assert-no-duplicate-keys-in-shm_toc_insert.patch
text/x-patch
Filename: v10-0001-Assert-no-duplicate-keys-in-shm_toc_insert.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v10-0001
Subject: Assert no duplicate keys in shm_toc_insert()
| File | + | − |
|---|---|---|
| src/backend/storage/ipc/shm_toc.c | 7 | 0 |
From 671ac63b3f443b22b4e268c7f6d1f48ee15e99df Mon Sep 17 00:00:00 2001 From: Melanie Plageman <melanieplageman@gmail.com> Date: Mon, 6 Apr 2026 15:16:05 -0400 Subject: [PATCH v10 1/2] Assert no duplicate keys in shm_toc_insert() shm_toc_insert() accepts duplicate keys, and a duplicate would go undetected. Add an assertion to catch this. Keys are defined throughout the executor, so it is useful of having a way to detect collisions. --- src/backend/storage/ipc/shm_toc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/backend/storage/ipc/shm_toc.c b/src/backend/storage/ipc/shm_toc.c index e74a0b97ac0..f3bbb24bfdd 100644 --- a/src/backend/storage/ipc/shm_toc.c +++ b/src/backend/storage/ipc/shm_toc.c @@ -201,6 +201,13 @@ shm_toc_insert(shm_toc *toc, uint64 key, void *address) } Assert(offset < total_bytes); + +#ifdef USE_ASSERT_CHECKING + /* Verify no duplicate keys */ + for (Size i = 0; i < nentry; i++) + Assert(vtoc->toc_entry[i].key != key); +#endif + vtoc->toc_entry[nentry].key = key; vtoc->toc_entry[nentry].offset = offset; -- 2.43.0