Skip to content

Commit

Permalink
Fixed compact deletion sql statement
Browse files Browse the repository at this point in the history
  • Loading branch information
afritzler committed May 28, 2021
1 parent 57753e6 commit f3130cc
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions pkg/drivers/pgsql/pgsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ func New(ctx context.Context, dataSourceName string, tlsInfo tls.Config, connPoo
}
dialect.CompactSQL = `
DELETE FROM kine AS kv
USING (
SELECT kp.prev_revision AS id
FROM kine AS kp
WHERE
kp.name != 'compact_rev_key' AND
kp.prev_revision != 0 AND
kp.id <= $1
UNION
SELECT kd.id AS id
FROM kine AS kd
WHERE
kd.deleted != 0 AND
kd.id <= $2
) AS ks
WHERE kv.id = ks.id`
WHERE
kv.id IN (
SELECT kp.prev_revision AS id
FROM kine AS kp
WHERE
kp.name != 'compact_rev_key' AND
kp.prev_revision != 0 AND
kp.id <= $1
UNION
SELECT kd.id AS id
FROM kine AS kd
WHERE
kd.deleted != 0 AND
kd.id <= $2
)`
dialect.TranslateErr = func(err error) error {
if err, ok := err.(*pq.Error); ok && err.Code == "23505" {
return server.ErrKeyExists
Expand Down

0 comments on commit f3130cc

Please sign in to comment.