summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Naylor2023-11-30 08:25:57 +0000
committerJohn Naylor2023-11-30 08:25:57 +0000
commit095d109ccd76ca4c46c4ea2be30d63d70361c5f9 (patch)
tree70d43b54aec0ea4e0d3a2521ca7dfa58c9f1ff1b
parent489ca33081c8f590a314d4a09d9bee56a81f1a85 (diff)
Remove redundant setting of hashkey after insertion
It's not necessary to fill the key field in most cases, since hash_search has already done that. Some existing call sites have an assert or comment that this contract has been fulfilled, but those are quite old and that practice seems unnecessary here. While at it, remove a nearby redundant assignment that a smart compiler will elide anyway. Zhao Junwang, with some adjustments by me Reviewed by Nathan Bossart, with additional feedback from Tom Lane Discussion: http://postgr.es/m/CAEG8a3%2BUPF%3DR2QGPgJMF2mKh8xPd1H2TmfH77zPuVUFdBpiGUA%40mail.gmail.com
-rw-r--r--contrib/dblink/dblink.c1
-rw-r--r--src/backend/commands/async.c20
-rw-r--r--src/backend/commands/tablecmds.c3
-rw-r--r--src/backend/replication/logical/applyparallelworker.c1
-rw-r--r--src/backend/replication/logical/relation.c1
5 files changed, 8 insertions, 18 deletions
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 195b278f55..27bd0d31fd 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -2574,7 +2574,6 @@ createNewConnection(const char *name, remoteConn *rconn)
}
hentry->rconn = rconn;
- strlcpy(hentry->name, name, sizeof(hentry->name));
}
static void
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 2651d8904b..264f25a8f9 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -2305,15 +2305,13 @@ AddEventToPendingNotifies(Notification *n)
foreach(l, pendingNotifies->events)
{
Notification *oldn = (Notification *) lfirst(l);
- NotificationHash *hentry;
bool found;
- hentry = (NotificationHash *) hash_search(pendingNotifies->hashtab,
- &oldn,
- HASH_ENTER,
- &found);
+ (void) hash_search(pendingNotifies->hashtab,
+ &oldn,
+ HASH_ENTER,
+ &found);
Assert(!found);
- hentry->event = oldn;
}
}
@@ -2323,15 +2321,13 @@ AddEventToPendingNotifies(Notification *n)
/* Add event to the hash table if needed */
if (pendingNotifies->hashtab != NULL)
{
- NotificationHash *hentry;
bool found;
- hentry = (NotificationHash *) hash_search(pendingNotifies->hashtab,
- &n,
- HASH_ENTER,
- &found);
+ (void) hash_search(pendingNotifies->hashtab,
+ &n,
+ HASH_ENTER,
+ &found);
Assert(!found);
- hentry->event = n;
}
}
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 323d9bf870..7206da7c53 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -2104,10 +2104,7 @@ ExecuteTruncateGuts(List *explicit_rels,
/* Find or create cached entry for the foreign table */
ft_info = hash_search(ft_htab, &serverid, HASH_ENTER, &found);
if (!found)
- {
- ft_info->serverid = serverid;
ft_info->rels = NIL;
- }
/*
* Save the foreign table in the entry of the server that the
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c
index 9b37736f8e..b84a8a6db2 100644
--- a/src/backend/replication/logical/applyparallelworker.c
+++ b/src/backend/replication/logical/applyparallelworker.c
@@ -509,7 +509,6 @@ pa_allocate_worker(TransactionId xid)
winfo->in_use = true;
winfo->serialize_changes = false;
entry->winfo = winfo;
- entry->xid = xid;
}
/*
diff --git a/src/backend/replication/logical/relation.c b/src/backend/replication/logical/relation.c
index d62eefed13..a581ac9a4d 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -657,7 +657,6 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
int i;
/* Remote relation is copied as-is from the root entry. */
- entry = &part_entry->relmapentry;
entry->remoterel.remoteid = remoterel->remoteid;
entry->remoterel.nspname = pstrdup(remoterel->nspname);
entry->remoterel.relname = pstrdup(remoterel->relname);