Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 095d109

Browse files
committed
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
1 parent 489ca33 commit 095d109

File tree

5 files changed

+8
-18
lines changed

5 files changed

+8
-18
lines changed

contrib/dblink/dblink.c

-1
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,6 @@ createNewConnection(const char *name, remoteConn *rconn)
25742574
}
25752575

25762576
hentry->rconn = rconn;
2577-
strlcpy(hentry->name, name, sizeof(hentry->name));
25782577
}
25792578

25802579
static void

src/backend/commands/async.c

+8-12
Original file line numberDiff line numberDiff line change
@@ -2305,15 +2305,13 @@ AddEventToPendingNotifies(Notification *n)
23052305
foreach(l, pendingNotifies->events)
23062306
{
23072307
Notification *oldn = (Notification *) lfirst(l);
2308-
NotificationHash *hentry;
23092308
bool found;
23102309

2311-
hentry = (NotificationHash *) hash_search(pendingNotifies->hashtab,
2312-
&oldn,
2313-
HASH_ENTER,
2314-
&found);
2310+
(void) hash_search(pendingNotifies->hashtab,
2311+
&oldn,
2312+
HASH_ENTER,
2313+
&found);
23152314
Assert(!found);
2316-
hentry->event = oldn;
23172315
}
23182316
}
23192317

@@ -2323,15 +2321,13 @@ AddEventToPendingNotifies(Notification *n)
23232321
/* Add event to the hash table if needed */
23242322
if (pendingNotifies->hashtab != NULL)
23252323
{
2326-
NotificationHash *hentry;
23272324
bool found;
23282325

2329-
hentry = (NotificationHash *) hash_search(pendingNotifies->hashtab,
2330-
&n,
2331-
HASH_ENTER,
2332-
&found);
2326+
(void) hash_search(pendingNotifies->hashtab,
2327+
&n,
2328+
HASH_ENTER,
2329+
&found);
23332330
Assert(!found);
2334-
hentry->event = n;
23352331
}
23362332
}
23372333

src/backend/commands/tablecmds.c

-3
Original file line numberDiff line numberDiff line change
@@ -2104,10 +2104,7 @@ ExecuteTruncateGuts(List *explicit_rels,
21042104
/* Find or create cached entry for the foreign table */
21052105
ft_info = hash_search(ft_htab, &serverid, HASH_ENTER, &found);
21062106
if (!found)
2107-
{
2108-
ft_info->serverid = serverid;
21092107
ft_info->rels = NIL;
2110-
}
21112108

21122109
/*
21132110
* Save the foreign table in the entry of the server that the

src/backend/replication/logical/applyparallelworker.c

-1
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ pa_allocate_worker(TransactionId xid)
509509
winfo->in_use = true;
510510
winfo->serialize_changes = false;
511511
entry->winfo = winfo;
512-
entry->xid = xid;
513512
}
514513

515514
/*

src/backend/replication/logical/relation.c

-1
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
657657
int i;
658658

659659
/* Remote relation is copied as-is from the root entry. */
660-
entry = &part_entry->relmapentry;
661660
entry->remoterel.remoteid = remoterel->remoteid;
662661
entry->remoterel.nspname = pstrdup(remoterel->nspname);
663662
entry->remoterel.relname = pstrdup(remoterel->relname);

0 commit comments

Comments
 (0)