Skip to content

Commit aca6558

Browse files
committed
sql: move AuditConfig to ExecCfg
There was no need for this to live in the sessioninit cache. It just caused an extra dependency. Release note: None
1 parent 4a3e787 commit aca6558

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

pkg/server/server_sql.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,9 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
955955
SessionInitCache: sessioninit.NewCache(
956956
serverCacheMemoryMonitor.MakeBoundAccount(), cfg.stopper,
957957
),
958+
AuditConfig: &auditlogging.AuditConfigLock{
959+
Config: auditlogging.EmptyAuditConfig(),
960+
},
958961
ClientCertExpirationCache: security.NewClientCertExpirationCache(
959962
ctx, cfg.Settings, cfg.stopper, &timeutil.DefaultTimeSource{}, rootSQLMemoryMonitor,
960963
),
@@ -1351,7 +1354,7 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
13511354
vmoduleSetting.SetOnChange(&cfg.Settings.SV, fn)
13521355
fn(ctx)
13531356

1354-
auditlogging.ConfigureRoleBasedAuditClusterSettings(ctx, execCfg.SessionInitCache.AuditConfig, execCfg.Settings, &execCfg.Settings.SV)
1357+
auditlogging.ConfigureRoleBasedAuditClusterSettings(ctx, execCfg.AuditConfig, execCfg.Settings, &execCfg.Settings.SV)
13551358

13561359
return &SQLServer{
13571360
ambientCtx: cfg.BaseConfig.AmbientCtx,

pkg/sql/exec_util.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import (
6161
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
6262
"github.com/cockroachdb/cockroach/pkg/spanconfig"
6363
"github.com/cockroachdb/cockroach/pkg/sql/appstatspb"
64+
"github.com/cockroachdb/cockroach/pkg/sql/auditlogging"
6465
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
6566
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
6667
"github.com/cockroachdb/cockroach/pkg/sql/catalog/lease"
@@ -1320,6 +1321,10 @@ type ExecutorConfig struct {
13201321
// and per-role default settings.
13211322
SessionInitCache *sessioninit.Cache
13221323

1324+
// AuditConfig is the cluster's audit configuration. See the
1325+
// 'sql.log.user_audit' cluster setting to see how this is configured.
1326+
AuditConfig *auditlogging.AuditConfigLock
1327+
13231328
// ProtectedTimestampProvider encapsulates the protected timestamp subsystem.
13241329
ProtectedTimestampProvider protectedts.Provider
13251330

pkg/sql/planner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (p *planner) LeaseMgr() *lease.Manager {
624624
}
625625

626626
func (p *planner) AuditConfig() *auditlogging.AuditConfigLock {
627-
return p.execCfg.SessionInitCache.AuditConfig
627+
return p.execCfg.AuditConfig
628628
}
629629

630630
func (p *planner) Txn() *kv.Txn {

pkg/sql/sessioninit/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ go_library(
1313
"//pkg/security/username",
1414
"//pkg/settings",
1515
"//pkg/settings/cluster",
16-
"//pkg/sql/auditlogging",
1716
"//pkg/sql/catalog",
1817
"//pkg/sql/catalog/descpb",
1918
"//pkg/sql/catalog/descs",

pkg/sql/sessioninit/cache.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/cockroachdb/cockroach/pkg/security/username"
2020
"github.com/cockroachdb/cockroach/pkg/settings"
2121
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
22-
"github.com/cockroachdb/cockroach/pkg/sql/auditlogging"
2322
"github.com/cockroachdb/cockroach/pkg/sql/catalog"
2423
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb"
2524
"github.com/cockroachdb/cockroach/pkg/sql/catalog/descs"
@@ -59,10 +58,6 @@ type Cache struct {
5958
// populateCacheGroup is used to ensure that there is at most one in-flight
6059
// request for populating each cache entry.
6160

62-
// AuditConfig is the cluster's audit configuration. See the 'sql.log.user_audit'
63-
// cluster setting to see how this is configured.
64-
AuditConfig *auditlogging.AuditConfigLock
65-
6661
populateCacheGroup *singleflight.Group
6762
stopper *stop.Stopper
6863
}
@@ -102,9 +97,6 @@ func NewCache(account mon.BoundAccount, stopper *stop.Stopper) *Cache {
10297
boundAccount: account,
10398
populateCacheGroup: singleflight.NewGroup("load-value", "key"),
10499
stopper: stopper,
105-
AuditConfig: &auditlogging.AuditConfigLock{
106-
Config: auditlogging.EmptyAuditConfig(),
107-
},
108100
}
109101
}
110102

0 commit comments

Comments
 (0)