Skip to content

Commit 366f424

Browse files
committed
sql: consolidate logic for TTL rate limit notice
Release note: None
1 parent ceb320e commit 366f424

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

pkg/sql/alter_table.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -768,13 +768,6 @@ func (n *alterTableNode) startExec(params runParams) error {
768768
return err
769769
}
770770

771-
paramIsDelete := t.StorageParams.GetVal("ttl_delete_rate_limit") != nil
772-
paramIsSelect := t.StorageParams.GetVal("ttl_select_rate_limit") != nil
773-
774-
if paramIsDelete || paramIsSelect {
775-
printTTLRateLimitNotice(params.ctx, params.p)
776-
}
777-
778771
case *tree.AlterTableResetStorageParams:
779772
setter := tablestorageparam.NewSetter(n.tableDesc, false /* isNewObject */)
780773
if err := storageparam.Reset(

pkg/sql/create_table.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,13 +1431,6 @@ func NewTableDesc(
14311431
return nil, err
14321432
}
14331433

1434-
paramIsDelete := n.StorageParams.GetVal("ttl_delete_rate_limit") != nil
1435-
paramIsSelect := n.StorageParams.GetVal("ttl_select_rate_limit") != nil
1436-
1437-
if paramIsDelete || paramIsSelect {
1438-
printTTLRateLimitNotice(ctx, evalCtx.ClientNoticeSender)
1439-
}
1440-
14411434
setter.TableDesc.RowLevelTTL = setter.UpdatedRowLevelTTL
14421435

14431436
indexEncodingVersion := descpb.StrictIndexColumnIDGuaranteesVersion

pkg/sql/storageparam/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ go_library(
66
importpath = "github.com/cockroachdb/cockroach/pkg/sql/storageparam",
77
visibility = ["//visibility:public"],
88
deps = [
9+
"//pkg/docs",
910
"//pkg/server/telemetry",
1011
"//pkg/sql/paramparse",
1112
"//pkg/sql/pgwire/pgcode",

pkg/sql/storageparam/storage_param.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package storageparam
1010
import (
1111
"context"
1212

13+
"github.com/cockroachdb/cockroach/pkg/docs"
1314
"github.com/cockroachdb/cockroach/pkg/server/telemetry"
1415
"github.com/cockroachdb/cockroach/pkg/sql/paramparse"
1516
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
@@ -150,6 +151,7 @@ func StorageParamPreChecks(
150151
}
151152
keys = append(keys, resetParams...)
152153

154+
hasTTLRateLimit := false
153155
for _, key := range keys {
154156
if key == `schema_locked` {
155157
// We only allow setting/resetting `schema_locked` storage parameter in
@@ -168,6 +170,17 @@ func StorageParamPreChecks(
168170
"its own without other parameters in a single-statement implicit transaction.", key)
169171
}
170172
}
173+
if key == `ttl_select_rate_limit` || key == `ttl_delete_rate_limit` {
174+
hasTTLRateLimit = true
175+
}
176+
}
177+
178+
if hasTTLRateLimit {
179+
evalCtx.ClientNoticeSender.BufferClientNotice(ctx, errors.WithDetail(
180+
pgnotice.Newf("The TTL rate limit is per node per table."),
181+
"See the documentation for additional details: "+docs.URL("row-level-ttl#ttl-storage-parameters"),
182+
))
171183
}
184+
172185
return nil
173186
}

0 commit comments

Comments
 (0)