Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd9b0767

Browse files
author
Amit Kapila
committed
Fix the warnings introduced in commitce0fdbf.
Author: Amit KapilaReviewed-by: Tom LaneDiscussion:https://postgr.es/m/1610789.1613170207@sss.pgh.pa.us
1 parent637668f commitd9b0767

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

‎src/backend/commands/subscriptioncmds.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,8 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
715715
* the origin might be already removed. For these reasons,
716716
* passing missing_ok = true.
717717
*/
718-
ReplicationOriginNameForTablesync(sub->oid,relid,originname);
718+
ReplicationOriginNameForTablesync(sub->oid,relid,originname,
719+
sizeof(originname));
719720
replorigin_drop_by_name(originname, true, false);
720721
}
721722

@@ -749,7 +750,8 @@ AlterSubscription_refresh(Subscription *sub, bool copy_data)
749750
* dropped slots and fail. For these reasons, we allow
750751
* missing_ok = true for the drop.
751752
*/
752-
ReplicationSlotNameForTablesync(sub->oid,sub_remove_rels[off].relid,syncslotname);
753+
ReplicationSlotNameForTablesync(sub->oid,sub_remove_rels[off].relid,
754+
syncslotname,sizeof(syncslotname));
753755
ReplicationSlotDropAtPubNode(wrconn,syncslotname, true);
754756
}
755757
}
@@ -1174,7 +1176,8 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
11741176
* worker so passing missing_ok = true. This can happen for the states
11751177
* before SUBREL_STATE_FINISHEDCOPY.
11761178
*/
1177-
ReplicationOriginNameForTablesync(subid,relid,originname);
1179+
ReplicationOriginNameForTablesync(subid,relid,originname,
1180+
sizeof(originname));
11781181
replorigin_drop_by_name(originname, true, false);
11791182
}
11801183

@@ -1254,7 +1257,8 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
12541257
{
12551258
charsyncslotname[NAMEDATALEN]= {0};
12561259

1257-
ReplicationSlotNameForTablesync(subid,relid,syncslotname);
1260+
ReplicationSlotNameForTablesync(subid,relid,syncslotname,
1261+
sizeof(syncslotname));
12581262
ReplicationSlotDropAtPubNode(wrconn,syncslotname, true);
12591263
}
12601264
}
@@ -1532,7 +1536,8 @@ ReportSlotConnectionError(List *rstates, Oid subid, char *slotname, char *err)
15321536
{
15331537
charsyncslotname[NAMEDATALEN]= {0};
15341538

1535-
ReplicationSlotNameForTablesync(subid,relid,syncslotname);
1539+
ReplicationSlotNameForTablesync(subid,relid,syncslotname,
1540+
sizeof(syncslotname));
15361541
elog(WARNING,"could not drop tablesync replication slot \"%s\"",
15371542
syncslotname);
15381543
}

‎src/backend/replication/logical/tablesync.c‎

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ process_syncing_tables_for_sync(XLogRecPtr current_lsn)
314314
*/
315315
ReplicationSlotNameForTablesync(MyLogicalRepWorker->subid,
316316
MyLogicalRepWorker->relid,
317-
syncslotname);
317+
syncslotname,
318+
sizeof(syncslotname));
318319

319320
/*
320321
* It is important to give an error if we are unable to drop the slot,
@@ -462,7 +463,8 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
462463
*/
463464
ReplicationOriginNameForTablesync(MyLogicalRepWorker->subid,
464465
rstate->relid,
465-
originname);
466+
originname,
467+
sizeof(originname));
466468
replorigin_drop_by_name(originname, true, false);
467469

468470
/*
@@ -871,27 +873,20 @@ copy_table(Relation rel)
871873
* pg_%u_sync_%u_UINT64_FORMAT (3 + 10 + 6 + 10 + 20 + '\0'), the maximum
872874
* length of slot_name will be 50.
873875
*
874-
* The returned slot name is either:
875-
* - stored in the supplied buffer (syncslotname), or
876-
* - palloc'ed in current memory context (if syncslotname = NULL).
876+
* The returned slot name is stored in the supplied buffer (syncslotname) with
877+
* the given size.
877878
*
878879
* Note: We don't use the subscription slot name as part of tablesync slot name
879880
* because we are responsible for cleaning up these slots and it could become
880881
* impossible to recalculate what name to cleanup if the subscription slot name
881882
* had changed.
882883
*/
883-
char*
884+
void
884885
ReplicationSlotNameForTablesync(Oidsuboid,Oidrelid,
885-
charsyncslotname[NAMEDATALEN])
886+
char*syncslotname,intszslot)
886887
{
887-
if (syncslotname)
888-
sprintf(syncslotname,"pg_%u_sync_%u_"UINT64_FORMAT,suboid,relid,
889-
GetSystemIdentifier());
890-
else
891-
syncslotname=psprintf("pg_%u_sync_%u_"UINT64_FORMAT,suboid,relid,
892-
GetSystemIdentifier());
893-
894-
returnsyncslotname;
888+
snprintf(syncslotname,szslot,"pg_%u_sync_%u_"UINT64_FORMAT,suboid,
889+
relid,GetSystemIdentifier());
895890
}
896891

897892
/*
@@ -901,9 +896,9 @@ ReplicationSlotNameForTablesync(Oid suboid, Oid relid,
901896
*/
902897
void
903898
ReplicationOriginNameForTablesync(Oidsuboid,Oidrelid,
904-
charoriginname[NAMEDATALEN])
899+
char*originname,intszorgname)
905900
{
906-
snprintf(originname,NAMEDATALEN,"pg_%u_%u",suboid,relid);
901+
snprintf(originname,szorgname,"pg_%u_%u",suboid,relid);
907902
}
908903

909904
/*
@@ -951,9 +946,11 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
951946
}
952947

953948
/* Calculate the name of the tablesync slot. */
954-
slotname=ReplicationSlotNameForTablesync(MySubscription->oid,
955-
MyLogicalRepWorker->relid,
956-
NULL/* use palloc */ );
949+
slotname= (char*)palloc(NAMEDATALEN);
950+
ReplicationSlotNameForTablesync(MySubscription->oid,
951+
MyLogicalRepWorker->relid,
952+
slotname,
953+
NAMEDATALEN);
957954

958955
/*
959956
* Here we use the slot name instead of the subscription name as the
@@ -972,7 +969,8 @@ LogicalRepSyncTableStart(XLogRecPtr *origin_startpos)
972969
/* Assign the origin tracking record name. */
973970
ReplicationOriginNameForTablesync(MySubscription->oid,
974971
MyLogicalRepWorker->relid,
975-
originname);
972+
originname,
973+
sizeof(originname));
976974

977975
if (MyLogicalRepWorker->relstate==SUBREL_STATE_DATASYNC)
978976
{

‎src/include/replication/slot.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ extern bool ReplicationSlotsCountDBSlots(Oid dboid, int *nslots, int *nactive);
212212
externvoidReplicationSlotsDropDBSlots(Oiddboid);
213213
externvoidInvalidateObsoleteReplicationSlots(XLogSegNooldestSegno);
214214
externReplicationSlot*SearchNamedReplicationSlot(constchar*name);
215-
externchar*ReplicationSlotNameForTablesync(Oidsuboid,Oidrelid,char*syncslotname);
215+
externvoidReplicationSlotNameForTablesync(Oidsuboid,Oidrelid,char*syncslotname,intszslot);
216216
externvoidReplicationSlotDropAtPubNode(WalReceiverConn*wrconn,char*slotname,boolmissing_ok);
217217

218218
externvoidStartupReplicationSlots(void);

‎src/include/replication/worker_internal.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ extern void logicalrep_worker_wakeup_ptr(LogicalRepWorker *worker);
8282

8383
externintlogicalrep_sync_worker_count(Oidsubid);
8484

85-
externvoidReplicationOriginNameForTablesync(Oidsuboid,Oidrelid,char*originname);
85+
externvoidReplicationOriginNameForTablesync(Oidsuboid,Oidrelid,
86+
char*originname,intszorgname);
8687
externchar*LogicalRepSyncTableStart(XLogRecPtr*origin_startpos);
8788

8889
voidprocess_syncing_tables(XLogRecPtrcurrent_lsn);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp