@@ -779,6 +779,11 @@ pg_stop_backup(pgBackup *backup)
779
779
PGresult * res ;
780
780
uint32 xlogid ;
781
781
uint32 xrecoff ;
782
+
783
+ /*
784
+ * We will use this values if there are no transactions between start_lsn
785
+ * and stop_lsn.
786
+ */
782
787
time_t recovery_time ;
783
788
TransactionId recovery_xid ;
784
789
@@ -789,19 +794,17 @@ pg_stop_backup(pgBackup *backup)
789
794
790
795
if (from_replica )
791
796
res = 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)" ,
793
800
0 , NULL );
794
801
else
795
802
res = 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()" ,
797
806
0 , NULL );
798
807
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
-
805
808
/*
806
809
* Extract timeline and LSN from results of pg_stop_backup()
807
810
*/
@@ -817,7 +820,7 @@ pg_stop_backup(pgBackup *backup)
817
820
FILE * fp ;
818
821
pgFile * file ;
819
822
820
- Assert (PQnfields (res ) >= 3 );
823
+ Assert (PQnfields (res ) >= 5 );
821
824
822
825
pgBackupGetPath (& current , path , lengthof (path ), DATABASE_DIR );
823
826
join_path_components (backup_label , path , PG_BACKUP_LABEL_FILE );
@@ -863,12 +866,22 @@ pg_stop_backup(pgBackup *backup)
863
866
elog (ERROR ,
864
867
"result of txid_snapshot_xmax() is invalid: %s" ,
865
868
PQerrorMessage (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 ));
866
873
}
867
874
else
875
+ {
868
876
if (sscanf (PQgetvalue (res , 0 , 1 ), XID_FMT , & recovery_xid ) != 1 )
869
877
elog (ERROR ,
870
878
"result of txid_snapshot_xmax() is invalid: %s" ,
871
879
PQerrorMessage (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
+ }
872
885
873
886
PQclear (res );
874
887
0 commit comments