@@ -1030,12 +1030,20 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup,
10301030 uint32 lsn_lo ;
10311031 params [0 ] = label ;
10321032
1033+ #if PG_VERSION_NUM >= 150000
1034+ elog (INFO , "wait for pg_backup_start()" );
1035+ #else
10331036 elog (INFO , "wait for pg_start_backup()" );
1037+ #endif
10341038
10351039 /* 2nd argument is 'fast'*/
10361040 params [1 ] = smooth ? "false" : "true" ;
10371041 res = pgut_execute (conn ,
1042+ #if PG_VERSION_NUM >= 150000
1043+ "SELECT pg_catalog.pg_backup_start($1, $2)" ,
1044+ #else
10381045 "SELECT pg_catalog.pg_start_backup($1, $2, false)" ,
1046+ #endif
10391047 2 ,
10401048 params );
10411049
@@ -1575,6 +1583,14 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
15751583 " labelfile,"
15761584 " spcmapfile"
15771585 " FROM pg_catalog.pg_stop_backup(false, false)" ,
1586+ stop_backup_on_master_after15_query [] =
1587+ "SELECT"
1588+ " pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
1589+ " current_timestamp(0)::timestamptz,"
1590+ " lsn,"
1591+ " labelfile,"
1592+ " spcmapfile"
1593+ " FROM pg_catalog.pg_backup_stop(false)" ,
15781594 /*
15791595 * In case of backup from replica we do not trust minRecPoint
15801596 * and stop_backup LSN, so we use latest replayed LSN as STOP LSN.
@@ -1586,12 +1602,26 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
15861602 " pg_catalog.pg_last_wal_replay_lsn(),"
15871603 " labelfile,"
15881604 " spcmapfile"
1589- " FROM pg_catalog.pg_stop_backup(false, false)" ;
1605+ " FROM pg_catalog.pg_stop_backup(false, false)" ,
1606+ stop_backup_on_replica_after15_query [] =
1607+ "SELECT"
1608+ " pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
1609+ " current_timestamp(0)::timestamptz,"
1610+ " pg_catalog.pg_last_wal_replay_lsn(),"
1611+ " labelfile,"
1612+ " spcmapfile"
1613+ " FROM pg_catalog.pg_backup_stop(false)" ;
15901614
15911615 const char * const stop_backup_query =
1592- is_started_on_replica ?
1616+ server_version >= 150000 ?
1617+ (is_started_on_replica ?
1618+ stop_backup_on_replica_after15_query :
1619+ stop_backup_on_master_after15_query
1620+ ) :
1621+ (is_started_on_replica ?
15931622 stop_backup_on_replica_query :
1594- stop_backup_on_master_query ;
1623+ stop_backup_on_master_query
1624+ );
15951625 bool sent = false;
15961626
15971627 /* Make proper timestamp format for parse_time(recovery_time) */
@@ -1606,7 +1636,11 @@ pg_stop_backup_send(PGconn *conn, int server_version, bool is_started_on_replica
16061636 */
16071637 sent = pgut_send (conn , stop_backup_query , 0 , NULL , WARNING );
16081638 if (!sent )
1639+ #if PG_VERSION_NUM >= 150000
1640+ elog (ERROR , "Failed to send pg_backup_stop query" );
1641+ #else
16091642 elog (ERROR , "Failed to send pg_stop_backup query" );
1643+ #endif
16101644
16111645 /* After we have sent pg_stop_backup, we don't need this callback anymore */
16121646 pgut_atexit_pop (backup_stopbackup_callback , & stop_callback_params );
@@ -1652,7 +1686,11 @@ pg_stop_backup_consume(PGconn *conn, int server_version,
16521686 if (interrupted )
16531687 {
16541688 pgut_cancel (conn );
1689+ #if PG_VERSION_NUM >= 150000
1690+ elog (ERROR , "interrupted during waiting for pg_backup_stop" );
1691+ #else
16551692 elog (ERROR , "interrupted during waiting for pg_stop_backup" );
1693+ #endif
16561694 }
16571695
16581696 if (pg_stop_backup_timeout == 1 )
@@ -1665,7 +1703,11 @@ pg_stop_backup_consume(PGconn *conn, int server_version,
16651703 if (pg_stop_backup_timeout > timeout )
16661704 {
16671705 pgut_cancel (conn );
1706+ #if PG_VERSION_NUM >= 150000
1707+ elog (ERROR , "pg_backup_stop doesn't answer in %d seconds, cancel it" , timeout );
1708+ #else
16681709 elog (ERROR , "pg_stop_backup doesn't answer in %d seconds, cancel it" , timeout );
1710+ #endif
16691711 }
16701712 }
16711713 else
@@ -1677,7 +1719,11 @@ pg_stop_backup_consume(PGconn *conn, int server_version,
16771719
16781720 /* Check successfull execution of pg_stop_backup() */
16791721 if (!query_result )
1722+ #if PG_VERSION_NUM >= 150000
1723+ elog (ERROR , "pg_backup_stop() failed" );
1724+ #else
16801725 elog (ERROR , "pg_stop_backup() failed" );
1726+ #endif
16811727 else
16821728 {
16831729 switch (PQresultStatus (query_result ))
0 commit comments