0001-Use-direct-hash-lookup-in-logicalrep_partmap_invalid.patch
text/x-patch
Filename: 0001-Use-direct-hash-lookup-in-logicalrep_partmap_invalid.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: unified
Series: patch 0001
| File | + | − |
|---|---|---|
| src/backend/replication/logical/relation.c | 9 | 14 |
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index 0b1d80b5b0f..f6e2a9a6422 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -544,20 +544,14 @@ logicalrep_partmap_invalidate_cb(Datum arg, Oid reloid)
if (reloid != InvalidOid)
{
- HASH_SEQ_STATUS status;
-
- hash_seq_init(&status, LogicalRepPartMap);
-
- /* TODO, use inverse lookup hashtable? */
- while ((entry = (LogicalRepPartMapEntry *) hash_seq_search(&status)) != NULL)
- {
- if (entry->relmapentry.localreloid == reloid)
- {
- entry->relmapentry.localrelvalid = false;
- hash_seq_term(&status);
- break;
- }
- }
+ /*
+ * LogicalRepPartMap is keyed by partition OID, which matches
+ * entry->relmapentry.localreloid (see logicalrep_partition_open), so
+ * we can invalidate via a direct hash lookup.
+ */
+ entry = hash_search(LogicalRepPartMap, &reloid, HASH_FIND, NULL);
+ if (entry != NULL)
+ entry->relmapentry.localrelvalid = false;
}
else
{
@@ -676,6 +670,7 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
*/
if (found && entry->localrelvalid)
{
+ Assert(entry->localreloid == partOid);
entry->localrel = partrel;
return entry;
}