* Secrets: fix MariaDB syntax error due to unsupported CTE syntax (#111610) * parametrize guid/created columns and re-generate test fixtures --------- Co-authored-by: Matheus Macabu <macabu.matheus@gmail.com>
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
WITH to_update AS (
|
||||
SELECT guid FROM (
|
||||
SELECT
|
||||
guid,
|
||||
ROW_NUMBER() OVER (ORDER BY created ASC) AS rn
|
||||
FROM {{ .Ident "secret_secure_value" }}
|
||||
WHERE
|
||||
UPDATE
|
||||
{{ .Ident "secret_secure_value" }}
|
||||
SET
|
||||
{{ .Ident "lease_token" }} = {{ .Arg .LeaseToken }},
|
||||
{{ .Ident "lease_created" }} = {{ .Arg .Now }}
|
||||
WHERE {{ .Ident "guid" }} IN (
|
||||
SELECT {{ .Ident "guid" }} FROM (
|
||||
SELECT
|
||||
{{ .Ident "guid" }},
|
||||
ROW_NUMBER() OVER (ORDER BY {{ .Ident "created" }} ASC) AS rn
|
||||
FROM {{ .Ident "secret_secure_value" }}
|
||||
WHERE
|
||||
{{ .Ident "active" }} = FALSE AND
|
||||
{{ .Arg .Now }} - {{ .Ident "created" }} > {{ .Arg .MinAge }} AND
|
||||
{{ .Arg .Now }} - {{ .Ident "lease_created" }} > {{ .Arg .LeaseTTL }}
|
||||
) AS sub
|
||||
WHERE rn <= {{ .Arg .MaxBatchSize }}
|
||||
)
|
||||
UPDATE
|
||||
{{ .Ident "secret_secure_value" }}
|
||||
SET
|
||||
{{ .Ident "lease_token" }} = {{ .Arg .LeaseToken }},
|
||||
{{ .Ident "lease_created" }} = {{ .Arg .Now }}
|
||||
WHERE guid IN (SELECT guid FROM to_update)
|
||||
;
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user