diff --git a/internal/datastore/postgres/revisions.go b/internal/datastore/postgres/revisions.go index 9ab0b7012b..5cc0f1cf28 100644 --- a/internal/datastore/postgres/revisions.go +++ b/internal/datastore/postgres/revisions.go @@ -33,9 +33,8 @@ const ( // %[4] Quantization period (in nanoseconds) // %[5] Name of snapshot column querySelectRevision = ` - WITH selected AS (SELECT COALESCE( - (SELECT %[1]s FROM %[2]s WHERE %[3]s >= TO_TIMESTAMP(FLOOR(EXTRACT(EPOCH FROM NOW() AT TIME ZONE 'utc') * 1000000000 / %[4]d) * %[4]d / 1000000000) AT TIME ZONE 'utc' ORDER BY %[3]s ASC LIMIT 1), - NULL + WITH selected AS (SELECT ( + (SELECT %[1]s FROM %[2]s WHERE %[3]s >= TO_TIMESTAMP(FLOOR(EXTRACT(EPOCH FROM NOW() AT TIME ZONE 'utc') * 1000000000 / %[4]d) * %[4]d / 1000000000) AT TIME ZONE 'utc' ORDER BY %[3]s ASC LIMIT 1) ) as xid) SELECT selected.xid, COALESCE((SELECT %[5]s FROM %[2]s WHERE %[1]s = selected.xid), (SELECT pg_current_snapshot())),