@@ -753,6 +753,8 @@ do_backup_instance(void)
753753int
754754do_backup (void )
755755{
756+ bool is_ptrack_support ;
757+
756758/* PGDATA and BACKUP_MODE are always required */
757759if (pgdata == NULL )
758760elog (ERROR ,"required parameter not specified: PGDATA "
@@ -779,19 +781,15 @@ do_backup(void)
779781current .checksum_version = get_data_checksum_version (true);
780782current .stream = stream_wal ;
781783
782- /* ptrack backup checks */
783- if (current .backup_mode == BACKUP_MODE_DIFF_PTRACK )
784- {
785- bool is_ptrack_support = pg_ptrack_support ();
784+ is_ptrack_support = pg_ptrack_support ();
786785
787- if (!is_ptrack_support )
788- elog (ERROR ,"This PostgreSQL instance does not support ptrack" );
789- else
790- {
791- is_ptrack_enable = pg_ptrack_enable ();
792- if (!is_ptrack_enable )
793- elog (ERROR ,"Ptrack is disabled" );
794- }
786+ if (!is_ptrack_support )
787+ elog (ERROR ,"This PostgreSQL instance does not support ptrack" );
788+ else
789+ {
790+ is_ptrack_enable = pg_ptrack_enable ();
791+ if (!is_ptrack_enable )
792+ elog (ERROR ,"Ptrack is disabled" );
795793}
796794
797795/* archiving check */
@@ -1147,7 +1145,6 @@ pg_ptrack_clear(void)
11471145
11481146params [0 ]= palloc (64 );
11491147params [1 ]= palloc (64 );
1150-
11511148res_db = pgut_execute (backup_conn ,"SELECT datname, oid, dattablespace FROM pg_database" ,
115211490 ,NULL );
11531150
@@ -1156,7 +1153,7 @@ pg_ptrack_clear(void)
11561153PGconn * tmp_conn ;
11571154
11581155dbname = PQgetvalue (res_db ,i ,0 );
1159- if (! strcmp (dbname ,"template0" ))
1156+ if (strcmp (dbname ,"template0" )== 0 )
11601157continue ;
11611158
11621159dbOid = atoi (PQgetvalue (res_db ,i ,1 ));
@@ -1167,7 +1164,7 @@ pg_ptrack_clear(void)
11671164
11681165sprintf (params [0 ],"%i" ,dbOid );
11691166sprintf (params [1 ],"%i" ,tblspcOid );
1170- res = pgut_execute (tmp_conn ,"SELECTpg_drop_ptrack_init_file ($1, $2)" ,
1167+ res = pgut_execute (tmp_conn ,"SELECTpg_ptrack_get_and_clear_db ($1, $2)" ,
117111682 , (const char * * )params );
11721169PQclear (res );
11731170
@@ -2076,12 +2073,6 @@ parse_backup_filelist_filenames(parray *files, const char *root)
20762073}
20772074}
20782075}
2079-
2080- if (strcmp (filename ,"pg_internal.init" )== 0 )
2081- {
2082- elog (INFO ,"filename %s, path %s, dbOid %u, tblspcOid %u is_datafile %s" ,
2083- filename ,file -> path ,file -> dbOid ,file -> tblspcOid ,file -> is_datafile ?"true" :"false" );
2084- }
20852076 }
20862077}
20872078
@@ -2444,12 +2435,16 @@ get_last_ptrack_lsn(void)
24442435
24452436{
24462437PGresult * res ;
2438+ uint32 xlogid ;
2439+ uint32 xrecoff ;
24472440XLogRecPtr lsn ;
24482441
24492442res = pgut_execute (backup_conn ,"select pg_ptrack_control_lsn()" ,0 ,NULL );
24502443
2451- lsn = atoi (PQgetvalue (res ,0 ,0 ));
2452- elog (INFO ,"get_last_ptrack_lsn(): lsn %lu" ,lsn );
2444+ /* Extract timeline and LSN from results of pg_start_backup() */
2445+ XLogDataFromLSN (PQgetvalue (res ,0 ,0 ),& xlogid ,& xrecoff );
2446+ /* Calculate LSN */
2447+ lsn = (XLogRecPtr ) ((uint64 )xlogid <<32 ) |xrecoff ;
24532448
24542449PQclear (res );
24552450return lsn ;