Pass Size as a 2nd argument for snprintf() in tablesync.c.
authorAmit Kapila <akapila@postgresql.org>
Wed, 21 Sep 2022 04:50:37 +0000 (10:20 +0530)
committerAmit Kapila <akapila@postgresql.org>
Wed, 21 Sep 2022 04:50:37 +0000 (10:20 +0530)
Previously the following snprintf() wrappers:

* ReplicationSlotNameForTablesync()
* ReplicationOriginNameForTablesync()

... used int as a second argument of snprintf() while the actual type of it
is size_t. Although it doesn't fail at present better replace it with Size
for consistency with the rest of the system.

Author: Aleksander Alekseev
Reviewed-By: Peter Smith
Discussion: https://postgr.es/m/CAHut%2BPsa8hhfSE6ozUK-ih7GkQziAVAf4f3bqiXEj2nQiu-43g%40mail.gmail.com

src/backend/replication/logical/tablesync.c
src/include/replication/slot.h
src/include/replication/worker_internal.h

index 831d42016c1539a0167e615456b237973f546b0e..8eff69c7decd588778b070fa344043d9102d3149 100644 (file)
@@ -1187,7 +1187,7 @@ copy_table(Relation rel)
  */
 void
 ReplicationSlotNameForTablesync(Oid suboid, Oid relid,
-                               char *syncslotname, int szslot)
+                               char *syncslotname, Size szslot)
 {
    snprintf(syncslotname, szslot, "pg_%u_sync_%u_" UINT64_FORMAT, suboid,
             relid, GetSystemIdentifier());
@@ -1200,7 +1200,7 @@ ReplicationSlotNameForTablesync(Oid suboid, Oid relid,
  */
 void
 ReplicationOriginNameForTablesync(Oid suboid, Oid relid,
-                                 char *originname, int szorgname)
+                                 char *originname, Size szorgname)
 {
    snprintf(originname, szorgname, "pg_%u_%u", suboid, relid);
 }
index 81e31f002a3763521e6236e8fa12fe6cb4ed629a..8d5e764aef57f54e6cc1d319d5bdb90b570daeda 100644 (file)
@@ -218,7 +218,7 @@ extern void ReplicationSlotsDropDBSlots(Oid dboid);
 extern bool InvalidateObsoleteReplicationSlots(XLogSegNo oldestSegno);
 extern ReplicationSlot *SearchNamedReplicationSlot(const char *name, bool need_lock);
 extern int ReplicationSlotIndex(ReplicationSlot *slot);
-extern void ReplicationSlotNameForTablesync(Oid suboid, Oid relid, char *syncslotname, int szslot);
+extern void ReplicationSlotNameForTablesync(Oid suboid, Oid relid, char *syncslotname, Size szslot);
 extern void ReplicationSlotDropAtPubNode(WalReceiverConn *wrconn, char *slotname, bool missing_ok);
 
 extern void StartupReplicationSlots(void);
index 901845abc2c096fa2419018f980b0dffb645acc6..f82bc518c32addc457d31b5565d3663a9eb4596a 100644 (file)
@@ -93,7 +93,7 @@ extern void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker);
 extern int logicalrep_sync_worker_count(Oid subid);
 
 extern void ReplicationOriginNameForTablesync(Oid suboid, Oid relid,
-                                             char *originname, int szorgname);
+                                             char *originname, Size szorgname);
 extern char *LogicalRepSyncTableStart(XLogRecPtr *origin_startpos);
 
 extern bool AllTablesyncsReady(void);