|
17 | 17 | #include "libpq/pqformat.h"
|
18 | 18 | #include "mb/pg_wchar.h"
|
19 | 19 | #include "replication/backup_manifest.h"
|
| 20 | +#include "replication/basebackup_sink.h" |
20 | 21 | #include "utils/builtins.h"
|
21 | 22 | #include "utils/json.h"
|
22 | 23 |
|
@@ -310,9 +311,8 @@ AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr,
|
310 | 311 | * Finalize the backup manifest, and send it to the client.
|
311 | 312 | */
|
312 | 313 | void
|
313 |
| -SendBackupManifest(backup_manifest_info *manifest) |
| 314 | +SendBackupManifest(backup_manifest_info *manifest, bbsink *sink) |
314 | 315 | {
|
315 |
| - StringInfoData protobuf; |
316 | 316 | uint8 checksumbuf[PG_SHA256_DIGEST_LENGTH];
|
317 | 317 | char checksumstringbuf[PG_SHA256_DIGEST_STRING_LENGTH];
|
318 | 318 | size_t manifest_bytes_done = 0;
|
@@ -352,38 +352,28 @@ SendBackupManifest(backup_manifest_info *manifest)
|
352 | 352 | (errcode_for_file_access(),
|
353 | 353 | errmsg("could not rewind temporary file")));
|
354 | 354 |
|
355 |
| - /* Send CopyOutResponse message */ |
356 |
| - pq_beginmessage(&protobuf, 'H'); |
357 |
| - pq_sendbyte(&protobuf, 0); /* overall format */ |
358 |
| - pq_sendint16(&protobuf, 0); /* natts */ |
359 |
| - pq_endmessage(&protobuf); |
360 | 355 |
|
361 | 356 | /*
|
362 |
| - * Send CopyData messages. |
363 |
| - * |
364 |
| - * We choose to read back the data from the temporary file in chunks of |
365 |
| - * size BLCKSZ; this isn't necessary, but buffile.c uses that as the I/O |
366 |
| - * size, so it seems to make sense to match that value here. |
| 357 | + * Send the backup manifest. |
367 | 358 | */
|
| 359 | + bbsink_begin_manifest(sink); |
368 | 360 | while (manifest_bytes_done < manifest->manifest_size)
|
369 | 361 | {
|
370 |
| - char manifestbuf[BLCKSZ]; |
371 | 362 | size_t bytes_to_read;
|
372 | 363 | size_t rc;
|
373 | 364 |
|
374 |
| - bytes_to_read = Min(sizeof(manifestbuf), |
| 365 | + bytes_to_read = Min(sink->bbs_buffer_length, |
375 | 366 | manifest->manifest_size - manifest_bytes_done);
|
376 |
| - rc = BufFileRead(manifest->buffile, manifestbuf, bytes_to_read); |
| 367 | + rc = BufFileRead(manifest->buffile, sink->bbs_buffer, |
| 368 | + bytes_to_read); |
377 | 369 | if (rc != bytes_to_read)
|
378 | 370 | ereport(ERROR,
|
379 | 371 | (errcode_for_file_access(),
|
380 | 372 | errmsg("could not read from temporary file: %m")));
|
381 |
| - pq_putmessage('d', manifestbuf, bytes_to_read); |
| 373 | + bbsink_manifest_contents(sink, bytes_to_read); |
382 | 374 | manifest_bytes_done += bytes_to_read;
|
383 | 375 | }
|
384 |
| - |
385 |
| - /* No more data, so send CopyDone message */ |
386 |
| - pq_putemptymessage('c'); |
| 376 | + bbsink_end_manifest(sink); |
387 | 377 |
|
388 | 378 | /* Release resources */
|
389 | 379 | BufFileClose(manifest->buffile);
|
|
0 commit comments