Skip to content

Commit

Permalink
Merge pull request #1991 from josephschorr/remove-unnneeded-coalesce
Browse files Browse the repository at this point in the history
Remove apparently unneeded COALESCE call
  • Loading branch information
vroldanbet authored Jul 23, 2024
2 parents fc0d606 + a713d3f commit f1dca2c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions internal/datastore/postgres/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())),
Expand Down

0 comments on commit f1dca2c

Please sign in to comment.