33 * basebackup_copy.c
44 * send basebackup archives using COPY OUT
55 *
6- * We have two different ways of doing this.
6+ * We send a result set with information about the tabelspaces to be included
7+ * in the backup before starting COPY OUT. Then, we start a single COPY OUT
8+ * operation and transmits all the archives and the manifest if present during
9+ * the course of that single COPY OUT. Each CopyData message begins with a
10+ * type byte, allowing us to signal the start of a new archive, or the
11+ * manifest, by some means other than ending the COPY stream. This also allows
12+ * for future protocol extensions, since we can include arbitrary information
13+ * in the message stream as long as we're certain that the client will know
14+ * what to do with it.
715 *
8- * 'copytblspc' is an older method still supported for compatibility
9- * with releases prior to v15. In this method, a separate COPY OUT
10- * operation is used for each tablespace. The manifest, if it is sent,
11- * uses an additional COPY OUT operation.
12- *
13- * 'copystream' sends a starts a single COPY OUT operation and transmits
14- * all the archives and the manifest if present during the course of that
15- * single COPY OUT. Each CopyData message begins with a type byte,
16- * allowing us to signal the start of a new archive, or the manifest,
17- * by some means other than ending the COPY stream. This also allows
18- * this protocol to be extended more easily, since we can include
19- * arbitrary information in the message stream as long as we're certain
20- * that the client will know what to do with it.
21- *
22- * Regardless of which method is used, we sent a result set with
23- * information about the tabelspaces to be included in the backup before
24- * starting COPY OUT. This result has the same format in every method.
16+ * An older method that sent each archive using a separate COPY OUT
17+ * operation is no longer supported.
2518 *
2619 * Portions Copyright (c) 2010-2022, PostgreSQL Global Development Group
2720 *
@@ -87,20 +80,7 @@ static void bbsink_copystream_end_backup(bbsink *sink, XLogRecPtr endptr,
8780 TimeLineID endtli );
8881static void bbsink_copystream_cleanup (bbsink * sink );
8982
90- static void bbsink_copytblspc_begin_backup (bbsink * sink );
91- static void bbsink_copytblspc_begin_archive (bbsink * sink ,
92- const char * archive_name );
93- static void bbsink_copytblspc_archive_contents (bbsink * sink , size_t len );
94- static void bbsink_copytblspc_end_archive (bbsink * sink );
95- static void bbsink_copytblspc_begin_manifest (bbsink * sink );
96- static void bbsink_copytblspc_manifest_contents (bbsink * sink , size_t len );
97- static void bbsink_copytblspc_end_manifest (bbsink * sink );
98- static void bbsink_copytblspc_end_backup (bbsink * sink , XLogRecPtr endptr ,
99- TimeLineID endtli );
100- static void bbsink_copytblspc_cleanup (bbsink * sink );
101-
10283static void SendCopyOutResponse (void );
103- static void SendCopyData (const char * data , size_t len );
10484static void SendCopyDone (void );
10585static void SendXlogRecPtrResult (XLogRecPtr ptr , TimeLineID tli );
10686static void SendTablespaceList (List * tablespaces );
@@ -118,18 +98,6 @@ const bbsink_ops bbsink_copystream_ops = {
11898 .cleanup = bbsink_copystream_cleanup
11999};
120100
121- const bbsink_ops bbsink_copytblspc_ops = {
122- .begin_backup = bbsink_copytblspc_begin_backup ,
123- .begin_archive = bbsink_copytblspc_begin_archive ,
124- .archive_contents = bbsink_copytblspc_archive_contents ,
125- .end_archive = bbsink_copytblspc_end_archive ,
126- .begin_manifest = bbsink_copytblspc_begin_manifest ,
127- .manifest_contents = bbsink_copytblspc_manifest_contents ,
128- .end_manifest = bbsink_copytblspc_end_manifest ,
129- .end_backup = bbsink_copytblspc_end_backup ,
130- .cleanup = bbsink_copytblspc_cleanup
131- };
132-
133101/*
134102 * Create a new 'copystream' bbsink.
135103 */
@@ -338,115 +306,6 @@ bbsink_copystream_cleanup(bbsink *sink)
338306 /* Nothing to do. */
339307}
340308
341- /*
342- * Create a new 'copytblspc' bbsink.
343- */
344- bbsink *
345- bbsink_copytblspc_new (void )
346- {
347- bbsink * sink = palloc0 (sizeof (bbsink ));
348-
349- * ((const bbsink_ops * * ) & sink -> bbs_ops ) = & bbsink_copytblspc_ops ;
350-
351- return sink ;
352- }
353-
354- /*
355- * Begin backup.
356- */
357- static void
358- bbsink_copytblspc_begin_backup (bbsink * sink )
359- {
360- bbsink_state * state = sink -> bbs_state ;
361-
362- /* Create a suitable buffer. */
363- sink -> bbs_buffer = palloc (sink -> bbs_buffer_length );
364-
365- /* Tell client the backup start location. */
366- SendXlogRecPtrResult (state -> startptr , state -> starttli );
367-
368- /* Send client a list of tablespaces. */
369- SendTablespaceList (state -> tablespaces );
370-
371- /* Send a CommandComplete message */
372- pq_puttextmessage ('C' , "SELECT" );
373- }
374-
375- /*
376- * Each archive is set as a separate stream of COPY data, and thus begins
377- * with a CopyOutResponse message.
378- */
379- static void
380- bbsink_copytblspc_begin_archive (bbsink * sink , const char * archive_name )
381- {
382- SendCopyOutResponse ();
383- }
384-
385- /*
386- * Each chunk of data within the archive is sent as a CopyData message.
387- */
388- static void
389- bbsink_copytblspc_archive_contents (bbsink * sink , size_t len )
390- {
391- SendCopyData (sink -> bbs_buffer , len );
392- }
393-
394- /*
395- * The archive is terminated by a CopyDone message.
396- */
397- static void
398- bbsink_copytblspc_end_archive (bbsink * sink )
399- {
400- SendCopyDone ();
401- }
402-
403- /*
404- * The backup manifest is sent as a separate stream of COPY data, and thus
405- * begins with a CopyOutResponse message.
406- */
407- static void
408- bbsink_copytblspc_begin_manifest (bbsink * sink )
409- {
410- SendCopyOutResponse ();
411- }
412-
413- /*
414- * Each chunk of manifest data is sent using a CopyData message.
415- */
416- static void
417- bbsink_copytblspc_manifest_contents (bbsink * sink , size_t len )
418- {
419- SendCopyData (sink -> bbs_buffer , len );
420- }
421-
422- /*
423- * When we've finished sending the manifest, send a CopyDone message.
424- */
425- static void
426- bbsink_copytblspc_end_manifest (bbsink * sink )
427- {
428- SendCopyDone ();
429- }
430-
431- /*
432- * Send end-of-backup wire protocol messages.
433- */
434- static void
435- bbsink_copytblspc_end_backup (bbsink * sink , XLogRecPtr endptr ,
436- TimeLineID endtli )
437- {
438- SendXlogRecPtrResult (endptr , endtli );
439- }
440-
441- /*
442- * Cleanup.
443- */
444- static void
445- bbsink_copytblspc_cleanup (bbsink * sink )
446- {
447- /* Nothing to do. */
448- }
449-
450309/*
451310 * Send a CopyOutResponse message.
452311 */
@@ -461,15 +320,6 @@ SendCopyOutResponse(void)
461320 pq_endmessage (& buf );
462321}
463322
464- /*
465- * Send a CopyData message.
466- */
467- static void
468- SendCopyData (const char * data , size_t len )
469- {
470- pq_putmessage ('d' , data , len );
471- }
472-
473323/*
474324 * Send a CopyDone message.
475325 */
0 commit comments