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

Commit38c83c9

Browse files
committed
Refactor receivelog.c parameters
Much cruft had accumulated over time with a large number of parameterspassed down between functions very deep. With this refactoring, insteadintroduce a StreamCtl structure that holds the parameters, and pass arounda pointer to this structure instead. This makes it much easier to add orremove fields that are needed deeper down in the implementation withouthaving to modify every function header in the file.Patch by me after much nagging from AndresReviewed by Craig Ringer and Daniel Gustafsson
1 parent73e7e49 commit38c83c9

File tree

4 files changed

+136
-136
lines changed

4 files changed

+136
-136
lines changed

‎src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,20 @@ typedef struct
372372
staticint
373373
LogStreamerMain(logstreamer_param*param)
374374
{
375-
if (!ReceiveXlogStream(param->bgconn,param->startptr,param->timeline,
376-
param->sysidentifier,param->xlogdir,
377-
reached_end_position,standby_message_timeout,
378-
NULL, false, true))
375+
StreamCtlstream;
376+
377+
MemSet(&stream,sizeof(stream),0);
378+
stream.startpos=param->startptr;
379+
stream.timeline=param->timeline;
380+
stream.sysidentifier=param->sysidentifier;
381+
stream.stream_stop=reached_end_position;
382+
stream.standby_message_timeout=standby_message_timeout;
383+
stream.synchronous= false;
384+
stream.mark_done= true;
385+
stream.basedir=param->xlogdir;
386+
stream.partial_suffix=NULL;
387+
388+
if (!ReceiveXlogStream(param->bgconn,&stream))
379389

380390
/*
381391
* Any errors will already have been reported in the function process,

‎src/bin/pg_basebackup/pg_receivexlog.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ FindStreamingStart(uint32 *tli)
276276
staticvoid
277277
StreamLog(void)
278278
{
279-
XLogRecPtrstartpos,
280-
serverpos;
281-
TimeLineIDstarttli,
282-
servertli;
279+
XLogRecPtrserverpos;
280+
TimeLineIDservertli;
281+
StreamCtlstream;
282+
283+
MemSet(&stream,0,sizeof(stream));
283284

284285
/*
285286
* Connect in replication mode to the server
@@ -311,30 +312,35 @@ StreamLog(void)
311312
/*
312313
* Figure out where to start streaming.
313314
*/
314-
startpos=FindStreamingStart(&starttli);
315-
if (startpos==InvalidXLogRecPtr)
315+
stream.startpos=FindStreamingStart(&stream.timeline);
316+
if (stream.startpos==InvalidXLogRecPtr)
316317
{
317-
startpos=serverpos;
318-
starttli=servertli;
318+
stream.startpos=serverpos;
319+
stream.timeline=servertli;
319320
}
320321

321322
/*
322323
* Always start streaming at the beginning of a segment
323324
*/
324-
startpos-=startpos %XLOG_SEG_SIZE;
325+
stream.startpos-=stream.startpos %XLOG_SEG_SIZE;
325326

326327
/*
327328
* Start the replication
328329
*/
329330
if (verbose)
330331
fprintf(stderr,
331332
_("%s: starting log streaming at %X/%X (timeline %u)\n"),
332-
progname, (uint32) (startpos >>32), (uint32)startpos,
333-
starttli);
333+
progname, (uint32) (stream.startpos >>32), (uint32)stream.startpos,
334+
stream.timeline);
335+
336+
stream.stream_stop=stop_streaming;
337+
stream.standby_message_timeout=standby_message_timeout;
338+
stream.synchronous=synchronous;
339+
stream.mark_done= false;
340+
stream.basedir=basedir;
341+
stream.partial_suffix=".partial";
334342

335-
ReceiveXlogStream(conn,startpos,starttli,NULL,basedir,
336-
stop_streaming,standby_message_timeout,".partial",
337-
synchronous, false);
343+
ReceiveXlogStream(conn,&stream);
338344

339345
PQfinish(conn);
340346
conn=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp