@ -491,20 +491,20 @@ static void
check_publications ( WalReceiverConn * wrconn , List * publications )
check_publications ( WalReceiverConn * wrconn , List * publications )
{
{
WalRcvExecResult * res ;
WalRcvExecResult * res ;
StringInfo cmd ;
StringInfoData cmd ;
TupleTableSlot * slot ;
TupleTableSlot * slot ;
List * publicationsCopy = NIL ;
List * publicationsCopy = NIL ;
Oid tableRow [ 1 ] = { TEXTOID } ;
Oid tableRow [ 1 ] = { TEXTOID } ;
cmd = makeStringInfo ( ) ;
initStringInfo ( & cmd ) ;
appendStringInfoString ( cmd , " SELECT t.pubname FROM \n "
appendStringInfoString ( & cmd , " SELECT t.pubname FROM \n "
" pg_catalog.pg_publication t WHERE \n "
" pg_catalog.pg_publication t WHERE \n "
" t.pubname IN ( " ) ;
" t.pubname IN ( " ) ;
GetPublicationsStr ( publications , cmd , true ) ;
GetPublicationsStr ( publications , & cmd , true ) ;
appendStringInfoChar ( cmd , ' ) ' ) ;
appendStringInfoChar ( & cmd , ' ) ' ) ;
res = walrcv_exec ( wrconn , cmd - > data , 1 , tableRow ) ;
res = walrcv_exec ( wrconn , cmd . data , 1 , tableRow ) ;
destroyStringInfo ( cmd ) ;
pfree ( cmd . data ) ;
if ( res - > status ! = WALRCV_OK_TUPLES )
if ( res - > status ! = WALRCV_OK_TUPLES )
ereport ( ERROR ,
ereport ( ERROR ,
@ -535,15 +535,17 @@ check_publications(WalReceiverConn *wrconn, List *publications)
if ( list_length ( publicationsCopy ) )
if ( list_length ( publicationsCopy ) )
{
{
/* Prepare the list of non-existent publication(s) for error message. */
/* Prepare the list of non-existent publication(s) for error message. */
StringInfo pubnames = makeStringInfo ( ) ;
StringInfoData pubnames ;
initStringInfo ( & pubnames ) ;
GetPublicationsStr ( publicationsCopy , pubnames , false ) ;
GetPublicationsStr ( publicationsCopy , & pubnames , false ) ;
ereport ( WARNING ,
ereport ( WARNING ,
errcode ( ERRCODE_UNDEFINED_OBJECT ) ,
errcode ( ERRCODE_UNDEFINED_OBJECT ) ,
errmsg_plural ( " publication %s does not exist on the publisher " ,
errmsg_plural ( " publication %s does not exist on the publisher " ,
" publications %s do not exist on the publisher " ,
" publications %s do not exist on the publisher " ,
list_length ( publicationsCopy ) ,
list_length ( publicationsCopy ) ,
pubnames - > data ) ) ;
pubnames . data ) ) ;
}
}
}
}
@ -2885,12 +2887,13 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
int server_version = walrcv_server_version ( wrconn ) ;
int server_version = walrcv_server_version ( wrconn ) ;
bool check_columnlist = ( server_version > = 150000 ) ;
bool check_columnlist = ( server_version > = 150000 ) ;
int column_count = check_columnlist ? 4 : 3 ;
int column_count = check_columnlist ? 4 : 3 ;
StringInfo pub_names = makeStringInfo ( ) ;
StringInfoData pub_names ;
initStringInfo ( & cmd ) ;
initStringInfo ( & cmd ) ;
initStringInfo ( & pub_names ) ;
/* Build the pub_names comma-separated string. */
/* Build the pub_names comma-separated string. */
GetPublicationsStr ( publications , pub_names , true ) ;
GetPublicationsStr ( publications , & pub_names , true ) ;
/* Get the list of relations from the publisher */
/* Get the list of relations from the publisher */
if ( server_version > = 160000 )
if ( server_version > = 160000 )
@ -2917,7 +2920,7 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
" FROM pg_publication \n "
" FROM pg_publication \n "
" WHERE pubname IN ( %s )) AS gpt \n "
" WHERE pubname IN ( %s )) AS gpt \n "
" ON gpt.relid = c.oid \n " ,
" ON gpt.relid = c.oid \n " ,
pub_names - > data ) ;
pub_names . data ) ;
/* From version 19, inclusion of sequences in the target is supported */
/* From version 19, inclusion of sequences in the target is supported */
if ( server_version > = 190000 )
if ( server_version > = 190000 )
@ -2926,7 +2929,7 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
" SELECT DISTINCT s.schemaname, s.sequencename, " CppAsString2 ( RELKIND_SEQUENCE ) " :: \" char \" AS relkind, NULL::int2vector AS attrs \n "
" SELECT DISTINCT s.schemaname, s.sequencename, " CppAsString2 ( RELKIND_SEQUENCE ) " :: \" char \" AS relkind, NULL::int2vector AS attrs \n "
" FROM pg_catalog.pg_publication_sequences s \n "
" FROM pg_catalog.pg_publication_sequences s \n "
" WHERE s.pubname IN ( %s ) " ,
" WHERE s.pubname IN ( %s ) " ,
pub_names - > data ) ;
pub_names . data ) ;
}
}
else
else
{
{
@ -2939,10 +2942,10 @@ fetch_relation_list(WalReceiverConn *wrconn, List *publications)
appendStringInfo ( & cmd , " FROM pg_catalog.pg_publication_tables t \n "
appendStringInfo ( & cmd , " FROM pg_catalog.pg_publication_tables t \n "
" WHERE t.pubname IN ( %s ) " ,
" WHERE t.pubname IN ( %s ) " ,
pub_names - > data ) ;
pub_names . data ) ;
}
}
destroyStringInfo ( pub_names ) ;
pfree ( pub_names . data ) ;
res = walrcv_exec ( wrconn , cmd . data , column_count , tableRow ) ;
res = walrcv_exec ( wrconn , cmd . data , column_count , tableRow ) ;
pfree ( cmd . data ) ;
pfree ( cmd . data ) ;