@@ -753,6 +753,8 @@ do_backup_instance(void)
753
753
int
754
754
do_backup (void )
755
755
{
756
+ bool is_ptrack_support ;
757
+
756
758
/* PGDATA and BACKUP_MODE are always required */
757
759
if (pgdata == NULL )
758
760
elog (ERROR , "required parameter not specified: PGDATA "
@@ -779,19 +781,15 @@ do_backup(void)
779
781
current .checksum_version = get_data_checksum_version (true);
780
782
current .stream = stream_wal ;
781
783
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 ();
786
785
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" );
795
793
}
796
794
797
795
/* archiving check */
@@ -1147,7 +1145,6 @@ pg_ptrack_clear(void)
1147
1145
1148
1146
params [0 ] = palloc (64 );
1149
1147
params [1 ] = palloc (64 );
1150
-
1151
1148
res_db = pgut_execute (backup_conn , "SELECT datname, oid, dattablespace FROM pg_database" ,
1152
1149
0 , NULL );
1153
1150
@@ -1156,7 +1153,7 @@ pg_ptrack_clear(void)
1156
1153
PGconn * tmp_conn ;
1157
1154
1158
1155
dbname = PQgetvalue (res_db , i , 0 );
1159
- if (! strcmp (dbname , "template0" ))
1156
+ if (strcmp (dbname , "template0" ) == 0 )
1160
1157
continue ;
1161
1158
1162
1159
dbOid = atoi (PQgetvalue (res_db , i , 1 ));
@@ -1167,7 +1164,7 @@ pg_ptrack_clear(void)
1167
1164
1168
1165
sprintf (params [0 ], "%i" , dbOid );
1169
1166
sprintf (params [1 ], "%i" , tblspcOid );
1170
- res = pgut_execute (tmp_conn , "SELECT pg_drop_ptrack_init_file ($1, $2)" ,
1167
+ res = pgut_execute (tmp_conn , "SELECT pg_ptrack_get_and_clear_db ($1, $2)" ,
1171
1168
2 , (const char * * )params );
1172
1169
PQclear (res );
1173
1170
@@ -2076,12 +2073,6 @@ parse_backup_filelist_filenames(parray *files, const char *root)
2076
2073
}
2077
2074
}
2078
2075
}
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
- }
2085
2076
}
2086
2077
}
2087
2078
@@ -2444,12 +2435,16 @@ get_last_ptrack_lsn(void)
2444
2435
2445
2436
{
2446
2437
PGresult * res ;
2438
+ uint32 xlogid ;
2439
+ uint32 xrecoff ;
2447
2440
XLogRecPtr lsn ;
2448
2441
2449
2442
res = pgut_execute (backup_conn , "select pg_ptrack_control_lsn()" , 0 , NULL );
2450
2443
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 ;
2453
2448
2454
2449
PQclear (res );
2455
2450
return lsn ;
0 commit comments