25
25
*/
26
26
#include "postgres.h"
27
27
28
+ #include "access/tupdesc.h"
28
29
#include "catalog/pg_type_d.h"
29
30
#include "libpq/libpq.h"
30
31
#include "libpq/pqformat.h"
31
32
#include "replication/basebackup.h"
32
33
#include "replication/basebackup_sink.h"
34
+ #include "tcop/dest.h"
33
35
#include "utils/timestamp.h"
34
36
35
37
typedef struct bbsink_copystream
@@ -336,35 +338,24 @@ SendCopyDone(void)
336
338
static void
337
339
SendXlogRecPtrResult (XLogRecPtr ptr , TimeLineID tli )
338
340
{
341
+ DestReceiver * dest ;
342
+ TupleDesc tupdesc ;
339
343
StringInfoData buf ;
340
344
char str [MAXFNAMELEN ];
341
345
Size len ;
342
346
343
- pq_beginmessage (& buf , 'T' ); /* RowDescription */
344
- pq_sendint16 (& buf , 2 ); /* 2 fields */
345
-
346
- /* Field headers */
347
- pq_sendstring (& buf , "recptr" );
348
- pq_sendint32 (& buf , 0 ); /* table oid */
349
- pq_sendint16 (& buf , 0 ); /* attnum */
350
- pq_sendint32 (& buf , TEXTOID ); /* type oid */
351
- pq_sendint16 (& buf , -1 );
352
- pq_sendint32 (& buf , 0 );
353
- pq_sendint16 (& buf , 0 );
354
-
355
- pq_sendstring (& buf , "tli" );
356
- pq_sendint32 (& buf , 0 ); /* table oid */
357
- pq_sendint16 (& buf , 0 ); /* attnum */
347
+ dest = CreateDestReceiver (DestRemoteSimple );
358
348
349
+ tupdesc = CreateTemplateTupleDesc (2 );
350
+ TupleDescInitBuiltinEntry (tupdesc , (AttrNumber ) 1 , "recptr" , TEXTOID , -1 , 0 );
359
351
/*
360
352
* int8 may seem like a surprising data type for this, but in theory int4
361
353
* would not be wide enough for this, as TimeLineID is unsigned.
362
354
*/
363
- pq_sendint32 (& buf , INT8OID ); /* type oid */
364
- pq_sendint16 (& buf , 8 );
365
- pq_sendint32 (& buf , 0 );
366
- pq_sendint16 (& buf , 0 );
367
- pq_endmessage (& buf );
355
+ TupleDescInitBuiltinEntry (tupdesc , (AttrNumber ) 2 , "tli" , INT8OID , -1 , 0 );
356
+
357
+ /* send RowDescription */
358
+ dest -> rStartup (dest , CMD_SELECT , tupdesc );
368
359
369
360
/* Data row */
370
361
pq_beginmessage (& buf , 'D' );
@@ -391,41 +382,22 @@ SendXlogRecPtrResult(XLogRecPtr ptr, TimeLineID tli)
391
382
static void
392
383
SendTablespaceList (List * tablespaces )
393
384
{
385
+ DestReceiver * dest ;
386
+ TupleDesc tupdesc ;
394
387
StringInfoData buf ;
395
388
ListCell * lc ;
396
389
397
- /* Construct and send the directory information */
398
- pq_beginmessage (& buf , 'T' ); /* RowDescription */
399
- pq_sendint16 (& buf , 3 ); /* 3 fields */
400
-
401
- /* First field - spcoid */
402
- pq_sendstring (& buf , "spcoid" );
403
- pq_sendint32 (& buf , 0 ); /* table oid */
404
- pq_sendint16 (& buf , 0 ); /* attnum */
405
- pq_sendint32 (& buf , OIDOID ); /* type oid */
406
- pq_sendint16 (& buf , 4 ); /* typlen */
407
- pq_sendint32 (& buf , 0 ); /* typmod */
408
- pq_sendint16 (& buf , 0 ); /* format code */
409
-
410
- /* Second field - spclocation */
411
- pq_sendstring (& buf , "spclocation" );
412
- pq_sendint32 (& buf , 0 );
413
- pq_sendint16 (& buf , 0 );
414
- pq_sendint32 (& buf , TEXTOID );
415
- pq_sendint16 (& buf , -1 );
416
- pq_sendint32 (& buf , 0 );
417
- pq_sendint16 (& buf , 0 );
418
-
419
- /* Third field - size */
420
- pq_sendstring (& buf , "size" );
421
- pq_sendint32 (& buf , 0 );
422
- pq_sendint16 (& buf , 0 );
423
- pq_sendint32 (& buf , INT8OID );
424
- pq_sendint16 (& buf , 8 );
425
- pq_sendint32 (& buf , 0 );
426
- pq_sendint16 (& buf , 0 );
427
- pq_endmessage (& buf );
390
+ dest = CreateDestReceiver (DestRemoteSimple );
391
+
392
+ tupdesc = CreateTemplateTupleDesc (3 );
393
+ TupleDescInitBuiltinEntry (tupdesc , (AttrNumber ) 1 , "spcoid" , OIDOID , -1 , 0 );
394
+ TupleDescInitBuiltinEntry (tupdesc , (AttrNumber ) 2 , "spclocation" , TEXTOID , -1 , 0 );
395
+ TupleDescInitBuiltinEntry (tupdesc , (AttrNumber ) 3 , "size" , INT8OID , -1 , 0 );
428
396
397
+ /* send RowDescription */
398
+ dest -> rStartup (dest , CMD_SELECT , tupdesc );
399
+
400
+ /* Construct and send the directory information */
429
401
foreach (lc , tablespaces )
430
402
{
431
403
tablespaceinfo * ti = lfirst (lc );
0 commit comments