Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b91f6f4

Browse files
committed
Return NULL in pg_get_snapshot_timestamp function instead of 1/01/1970
1 parent 28b2e3b commit b91f6f4

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

src/backend/storage/file/fd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3960,6 +3960,7 @@ sfs_snapshot_file_size(const char *fname, bool isdir, int elevel)
39603960
int64
39613961
sfs_get_snapshot_size(SnapshotId snap_id)
39623962
{
3963+
sfs_check_snapshot(snap_id);
39633964
sfs_snapshot_size = 0;
39643965
sfs_current_snapshot = snap_id;
39653966
walk_data_dir(sfs_snapshot_file_size, LOG);
@@ -3991,13 +3992,14 @@ sfs_snapshot_file_time(const char *fname, bool isdir, int elevel)
39913992
}
39923993
}
39933994

3994-
TimestampTz
3995+
time_t
39953996
sfs_get_snapshot_timestamp(SnapshotId snap_id)
39963997
{
3998+
sfs_check_snapshot(snap_id);
39973999
sfs_snapshot_time = -1;
39984000
sfs_current_snapshot = snap_id;
39994001
walk_data_dir(sfs_snapshot_file_time, LOG);
4000-
return time_t_to_timestamptz((time_t)sfs_snapshot_time);
4002+
return sfs_snapshot_time;
40014003
}
40024004

40034005
void

src/backend/storage/file/snapfs.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ Datum pg_get_backend_snapshot(PG_FUNCTION_ARGS)
293293
Datum pg_get_snapshot_timestamp(PG_FUNCTION_ARGS)
294294
{
295295
SnapshotId snap_id = PG_GETARG_INT32(0);
296-
PG_RETURN_TIMESTAMPTZ(sfs_get_snapshot_timestamp(snap_id));
296+
time_t t = sfs_get_snapshot_timestamp(snap_id);
297+
if (t == (time_t)-1)
298+
PG_RETURN_NULL();
299+
else
300+
PG_RETURN_TIMESTAMPTZ(time_t_to_timestamptz(t));
297301
}
298302

src/backend/utils/misc/guc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ static struct config_int ConfigureNamesInt[] =
30703070
gettext_noop("Sets active snapfs snapshot."),
30713071
NULL,
30723072
},
3073-
&sfs_active_snapshot,
3073+
(int*)&sfs_active_snapshot,
30743074
-1, -1, INT_MAX,
30753075
NULL, NULL, NULL
30763076
},

src/include/storage/snapfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern int64 sfs_get_snapshot_size(SnapshotId sid);
5454
/*
5555
* Get snapshot timestamp (time of first database modification in this snapshot)
5656
*/
57-
extern TimestampTz sfs_get_snapshot_timestamp(SnapshotId sid);
57+
extern time_t sfs_get_snapshot_timestamp(SnapshotId sid);
5858

5959
/*
6060
* Iternal functions and variables

0 commit comments

Comments
 (0)