@@ -779,6 +779,11 @@ pg_stop_backup(pgBackup *backup)
779779PGresult * res ;
780780uint32 xlogid ;
781781uint32 xrecoff ;
782+
783+ /*
784+ * We will use this values if there are no transactions between start_lsn
785+ * and stop_lsn.
786+ */
782787time_t recovery_time ;
783788TransactionId recovery_xid ;
784789
@@ -789,19 +794,17 @@ pg_stop_backup(pgBackup *backup)
789794
790795if (from_replica )
791796res = pgut_execute (backup_conn ,
792- "SELECT *, txid_snapshot_xmax(txid_current_snapshot()) FROM pg_stop_backup(false)" ,
797+ "SELECT *, txid_snapshot_xmax(txid_current_snapshot()),"
798+ " current_timestamp(0)::timestamp"
799+ " FROM pg_stop_backup(false)" ,
7938000 ,NULL );
794801else
795802res = pgut_execute (backup_conn ,
796- "SELECT *, txid_snapshot_xmax(txid_current_snapshot()) FROM pg_stop_backup()" ,
803+ "SELECT *, txid_snapshot_xmax(txid_current_snapshot()),"
804+ " current_timestamp(0)::timestamp"
805+ " FROM pg_stop_backup()" ,
7978060 ,NULL );
798807
799- /*
800- * We will use this value if there are no transactions between start_lsn
801- * and stop_lsn.
802- */
803- recovery_time = time (NULL );
804-
805808/*
806809 * Extract timeline and LSN from results of pg_stop_backup()
807810 */
@@ -817,7 +820,7 @@ pg_stop_backup(pgBackup *backup)
817820FILE * fp ;
818821pgFile * file ;
819822
820- Assert (PQnfields (res ) >=3 );
823+ Assert (PQnfields (res ) >=5 );
821824
822825pgBackupGetPath (& current ,path ,lengthof (path ),DATABASE_DIR );
823826join_path_components (backup_label ,path ,PG_BACKUP_LABEL_FILE );
@@ -863,12 +866,22 @@ pg_stop_backup(pgBackup *backup)
863866elog (ERROR ,
864867"result of txid_snapshot_xmax() is invalid: %s" ,
865868PQerrorMessage (backup_conn ));
869+ if (!parse_time (PQgetvalue (res ,0 ,4 ),& recovery_time ))
870+ elog (ERROR ,
871+ "result of current_timestamp is invalid: %s" ,
872+ PQerrorMessage (backup_conn ));
866873}
867874else
875+ {
868876if (sscanf (PQgetvalue (res ,0 ,1 ),XID_FMT ,& recovery_xid )!= 1 )
869877elog (ERROR ,
870878"result of txid_snapshot_xmax() is invalid: %s" ,
871879PQerrorMessage (backup_conn ));
880+ if (!parse_time (PQgetvalue (res ,0 ,2 ),& recovery_time ))
881+ elog (ERROR ,
882+ "result of current_timestamp is invalid: %s" ,
883+ PQerrorMessage (backup_conn ));
884+ }
872885
873886PQclear (res );
874887