diff --git a/docs/generated/eventlog.md b/docs/generated/eventlog.md
index 122138045989..60e59e456ed7 100644
--- a/docs/generated/eventlog.md
+++ b/docs/generated/eventlog.md
@@ -647,8 +647,8 @@ An event of type `alter_database_add_region` is recorded when a region is added
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the database. | yes |
-| `RegionName` | The region being added. | yes |
+| `DatabaseName` | The name of the database. | no |
+| `RegionName` | The region being added. | no |
#### Common fields
@@ -671,8 +671,8 @@ AlterDatabaseAddRegion is recorded when a region is added to a database.
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the database. | yes |
-| `RegionName` | The region being dropped. | yes |
+| `DatabaseName` | The name of the database. | no |
+| `RegionName` | The region being dropped. | no |
#### Common fields
@@ -695,8 +695,8 @@ An event of type `alter_database_placement` is recorded when the database placem
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the database. | yes |
-| `Placement` | The new placement policy. | yes |
+| `DatabaseName` | The name of the database. | no |
+| `Placement` | The new placement policy. | no |
#### Common fields
@@ -719,8 +719,8 @@ An event of type `alter_database_primary_region` is recorded when a primary regi
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the database. | yes |
-| `PrimaryRegionName` | The new primary region. | yes |
+| `DatabaseName` | The name of the database. | no |
+| `PrimaryRegionName` | The new primary region. | no |
#### Common fields
@@ -766,8 +766,8 @@ An event of type `alter_database_survival_goal` is recorded when the survival go
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the database. | yes |
-| `SurvivalGoal` | The new survival goal | yes |
+| `DatabaseName` | The name of the database. | no |
+| `SurvivalGoal` | The new survival goal | no |
#### Common fields
@@ -791,7 +791,7 @@ altered.
| Field | Description | Sensitive |
|--|--|--|
-| `FunctionName` | Name of the affected function. | yes |
+| `FunctionName` | Name of the affected function. | no |
#### Common fields
@@ -814,8 +814,8 @@ An event of type `alter_index` is recorded when an index is altered.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected index. | yes |
-| `IndexName` | The name of the affected index. | yes |
+| `TableName` | The name of the table containing the affected index. | no |
+| `IndexName` | The name of the affected index. | no |
| `MutationID` | The mutation ID for the asynchronous job that is processing the index update. | no |
@@ -839,8 +839,8 @@ AlterIndex is recorded when an index visibility is altered.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected index. | yes |
-| `IndexName` | The name of the affected index. | yes |
+| `TableName` | The name of the table containing the affected index. | no |
+| `IndexName` | The name of the affected index. | no |
| `NotVisible` | Set true if index is not visible. NOTE: THIS FIELD IS DEPRECATED in favor of invisibility. | no |
| `Invisibility` | The new invisibility of the affected index. | no |
@@ -865,7 +865,7 @@ An event of type `alter_sequence` is recorded when a sequence is altered.
| Field | Description | Sensitive |
|--|--|--|
-| `SequenceName` | The name of the affected sequence. | yes |
+| `SequenceName` | The name of the affected sequence. | no |
#### Common fields
@@ -888,9 +888,9 @@ An event of type `alter_table` is recorded when a table is altered.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the affected table. | yes |
+| `TableName` | The name of the affected table. | no |
| `MutationID` | The mutation ID for the asynchronous job that is processing the index update, if any. | no |
-| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | yes |
+| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | no |
#### Common fields
@@ -913,7 +913,7 @@ EventAlterType is recorded when a user-defined type is altered.
| Field | Description | Sensitive |
|--|--|--|
-| `TypeName` | The name of the affected type. | yes |
+| `TypeName` | The name of the affected type. | no |
#### Common fields
@@ -936,8 +936,8 @@ An event of type `comment_on_column` is recorded when a column is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected column. | yes |
-| `ColumnName` | The affected column. | yes |
+| `TableName` | The name of the table containing the affected column. | no |
+| `ColumnName` | The affected column. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -962,8 +962,8 @@ An event of type `comment_on_constraint` is recorded when an constraint is comme
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected constraint. | yes |
-| `ConstraintName` | The name of the affected constraint. | yes |
+| `TableName` | The name of the table containing the affected constraint. | no |
+| `ConstraintName` | The name of the affected constraint. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -988,7 +988,7 @@ CommentOnTable is recorded when a database is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the affected database. | yes |
+| `DatabaseName` | The name of the affected database. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -1013,8 +1013,8 @@ An event of type `comment_on_index` is recorded when an index is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected index. | yes |
-| `IndexName` | The name of the affected index. | yes |
+| `TableName` | The name of the table containing the affected index. | no |
+| `IndexName` | The name of the affected index. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -1038,7 +1038,7 @@ An event of type `comment_on_index` is recorded when an index is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `SchemaName` | Name of the affected schema. | yes |
+| `SchemaName` | Name of the affected schema. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -1063,7 +1063,7 @@ An event of type `comment_on_table` is recorded when a table is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the affected table. | yes |
+| `TableName` | The name of the affected table. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -1088,7 +1088,7 @@ An event of type `comment_on_type` is recorded when a type is commented.
| Field | Description | Sensitive |
|--|--|--|
-| `TypeName` | The name of the affected type. | yes |
+| `TypeName` | The name of the affected type. | no |
| `Comment` | The new comment. | yes |
| `NullComment` | Set to true if the comment was removed entirely. | no |
@@ -1113,7 +1113,7 @@ An event of type `create_database` is recorded when a database is created.
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the new database. | yes |
+| `DatabaseName` | The name of the new database. | no |
#### Common fields
@@ -1136,7 +1136,7 @@ An event of type `create_function` is recorded when a user-defined function is c
| Field | Description | Sensitive |
|--|--|--|
-| `FunctionName` | Name of the created function. | yes |
+| `FunctionName` | Name of the created function. | no |
| `IsReplace` | If the new function is a replace of an existing function. | no |
@@ -1160,8 +1160,8 @@ An event of type `create_index` is recorded when an index is created.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the new index. | yes |
-| `IndexName` | The name of the new index. | yes |
+| `TableName` | The name of the table containing the new index. | no |
+| `IndexName` | The name of the new index. | no |
| `MutationID` | The mutation ID for the asynchronous job that is processing the index update. | no |
@@ -1185,8 +1185,8 @@ An event of type `create_schema` is recorded when a schema is created.
| Field | Description | Sensitive |
|--|--|--|
-| `SchemaName` | The name of the new schema. | yes |
-| `Owner` | The name of the owner for the new schema. | yes |
+| `SchemaName` | The name of the new schema. | no |
+| `Owner` | The name of the owner for the new schema. | no |
#### Common fields
@@ -1209,8 +1209,8 @@ An event of type `create_sequence` is recorded when a sequence is created.
| Field | Description | Sensitive |
|--|--|--|
-| `SequenceName` | The name of the new sequence. | yes |
-| `Owner` | The name of the owner for the new sequence. | yes |
+| `SequenceName` | The name of the new sequence. | no |
+| `Owner` | The name of the owner for the new sequence. | no |
#### Common fields
@@ -1237,7 +1237,7 @@ Events of this type are only collected when the cluster setting
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table for which the statistics were created. | yes |
+| `TableName` | The name of the table for which the statistics were created. | no |
#### Common fields
@@ -1260,8 +1260,8 @@ An event of type `create_table` is recorded when a table is created.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the new table. | yes |
-| `Owner` | The name of the owner for the new table. | yes |
+| `TableName` | The name of the new table. | no |
+| `Owner` | The name of the owner for the new table. | no |
#### Common fields
@@ -1284,8 +1284,8 @@ An event of type `create_type` is recorded when a user-defined type is created.
| Field | Description | Sensitive |
|--|--|--|
-| `TypeName` | The name of the new type. | yes |
-| `Owner` | The name of the owner for the new type. | yes |
+| `TypeName` | The name of the new type. | no |
+| `Owner` | The name of the owner for the new type. | no |
#### Common fields
@@ -1308,8 +1308,8 @@ An event of type `create_view` is recorded when a view is created.
| Field | Description | Sensitive |
|--|--|--|
-| `ViewName` | The name of the new view. | yes |
-| `Owner` | The name of the owner of the new view. | yes |
+| `ViewName` | The name of the new view. | no |
+| `Owner` | The name of the owner of the new view. | no |
| `ViewQuery` | The SQL selection clause used to define the view. | yes |
@@ -1333,8 +1333,8 @@ An event of type `drop_database` is recorded when a database is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The name of the affected database. | yes |
-| `DroppedSchemaObjects` | The names of the schemas dropped by a cascade operation. | yes |
+| `DatabaseName` | The name of the affected database. | no |
+| `DroppedSchemaObjects` | The names of the schemas dropped by a cascade operation. | no |
#### Common fields
@@ -1357,7 +1357,7 @@ An event of type `drop_function` is recorded when a user-defined function is dro
| Field | Description | Sensitive |
|--|--|--|
-| `FunctionName` | Name of the created function. | yes |
+| `FunctionName` | Name of the dropped function. | no |
#### Common fields
@@ -1380,10 +1380,10 @@ An event of type `drop_index` is recorded when an index is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the table containing the affected index. | yes |
-| `IndexName` | The name of the affected index. | yes |
+| `TableName` | The name of the table containing the affected index. | no |
+| `IndexName` | The name of the affected index. | no |
| `MutationID` | The mutation ID for the asynchronous job that is processing the index update. | no |
-| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | yes |
+| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | no |
#### Common fields
@@ -1406,7 +1406,7 @@ An event of type `drop_schema` is recorded when a schema is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `SchemaName` | The name of the affected schema. | yes |
+| `SchemaName` | The name of the affected schema. | no |
#### Common fields
@@ -1429,7 +1429,7 @@ An event of type `drop_sequence` is recorded when a sequence is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `SequenceName` | The name of the affected sequence. | yes |
+| `SequenceName` | The name of the affected sequence. | no |
#### Common fields
@@ -1452,8 +1452,8 @@ An event of type `drop_table` is recorded when a table is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the affected table. | yes |
-| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | yes |
+| `TableName` | The name of the affected table. | no |
+| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | no |
#### Common fields
@@ -1476,7 +1476,7 @@ An event of type `drop_type` is recorded when a user-defined type is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `TypeName` | The name of the affected type. | yes |
+| `TypeName` | The name of the affected type. | no |
#### Common fields
@@ -1499,8 +1499,8 @@ An event of type `drop_view` is recorded when a view is dropped.
| Field | Description | Sensitive |
|--|--|--|
-| `ViewName` | The name of the affected view. | yes |
-| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | yes |
+| `ViewName` | The name of the affected view. | no |
+| `CascadeDroppedViews` | The names of the views dropped as a result of a cascade operation. | no |
#### Common fields
@@ -1587,8 +1587,8 @@ An event of type `rename_database` is recorded when a database is renamed.
| Field | Description | Sensitive |
|--|--|--|
-| `DatabaseName` | The old name of the affected database. | yes |
-| `NewDatabaseName` | The new name of the affected database. | yes |
+| `DatabaseName` | The old name of the affected database. | no |
+| `NewDatabaseName` | The new name of the affected database. | no |
#### Common fields
@@ -1611,8 +1611,8 @@ An event of type `rename_function` is recorded when a user-defined function is r
| Field | Description | Sensitive |
|--|--|--|
-| `FunctionName` | The old name of the affected function. | yes |
-| `NewFunctionName` | The new name of the affected function. | yes |
+| `FunctionName` | The old name of the affected function. | no |
+| `NewFunctionName` | The new name of the affected function. | no |
#### Common fields
@@ -1635,8 +1635,8 @@ An event of type `rename_schema` is recorded when a schema is renamed.
| Field | Description | Sensitive |
|--|--|--|
-| `SchemaName` | The old name of the affected schema. | yes |
-| `NewSchemaName` | The new name of the affected schema. | yes |
+| `SchemaName` | The old name of the affected schema. | no |
+| `NewSchemaName` | The new name of the affected schema. | no |
#### Common fields
@@ -1659,8 +1659,8 @@ An event of type `rename_table` is recorded when a table, sequence or view is re
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The old name of the affected table. | yes |
-| `NewTableName` | The new name of the affected table. | yes |
+| `TableName` | The old name of the affected table. | no |
+| `NewTableName` | The new name of the affected table. | no |
#### Common fields
@@ -1683,8 +1683,8 @@ An event of type `rename_type` is recorded when a user-defined type is renamed.
| Field | Description | Sensitive |
|--|--|--|
-| `TypeName` | The old name of the affected type. | yes |
-| `NewTypeName` | The new name of the affected type. | yes |
+| `TypeName` | The old name of the affected type. | no |
+| `NewTypeName` | The new name of the affected type. | no |
#### Common fields
@@ -1708,7 +1708,7 @@ encounters a problem and is reversed.
| Field | Description | Sensitive |
|--|--|--|
-| `Error` | The error encountered that caused the schema change to be reversed. The specific format of the error is variable and can change across releases without warning. | yes |
+| `Error` | The error encountered that caused the schema change to be reversed. The specific format of the error is variable and can change across releases without warning. | partially |
| `SQLSTATE` | The SQLSTATE code for the error. | no |
| `LatencyNanos` | The amount of time the schema change job took before being reverted. | no |
@@ -1730,9 +1730,9 @@ An event of type `set_schema` is recorded when a table, view, sequence or type's
| Field | Description | Sensitive |
|--|--|--|
-| `DescriptorName` | The old name of the affected descriptor. | yes |
-| `NewDescriptorName` | The new name of the affected descriptor. | yes |
-| `DescriptorType` | The descriptor type being changed (table, view, sequence, type). | yes |
+| `DescriptorName` | The old name of the affected descriptor. | no |
+| `NewDescriptorName` | The new name of the affected descriptor. | no |
+| `DescriptorType` | The descriptor type being changed (table, view, sequence, type). | no |
#### Common fields
@@ -1755,7 +1755,7 @@ An event of type `truncate_table` is recorded when a table is truncated.
| Field | Description | Sensitive |
|--|--|--|
-| `TableName` | The name of the affected table. | yes |
+| `TableName` | The name of the affected table. | no |
#### Common fields
@@ -1784,7 +1784,7 @@ patch releases without advance notice.
|--|--|--|
| `ParentID` | | no |
| `ParentSchemaID` | | no |
-| `Name` | | yes |
+| `Name` | | no |
| `Force` | | no |
| `ForceNotice` | | yes |
@@ -1815,7 +1815,7 @@ patch releases without advance notice.
|--|--|--|
| `ParentID` | | no |
| `ParentSchemaID` | | no |
-| `Name` | | yes |
+| `Name` | | no |
| `Force` | | no |
| `ForceNotice` | | yes |
@@ -1873,7 +1873,7 @@ patch releases without advance notice.
|--|--|--|
| `ParentID` | | no |
| `ParentSchemaID` | | no |
-| `Name` | | yes |
+| `Name` | | no |
| `PreviousID` | | no |
| `Force` | | no |
| `FailedValidation` | | no |
diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt
index b1fe3e24708f..5eee965fc0a2 100644
--- a/docs/generated/settings/settings-for-tenants.txt
+++ b/docs/generated/settings/settings-for-tenants.txt
@@ -271,6 +271,7 @@ sql.insights.anomaly_detection.memory_limit byte size 1.0 MiB the maximum amount
sql.insights.execution_insights_capacity integer 1000 the size of the per-node store of execution insights application
sql.insights.high_retry_count.threshold integer 10 the number of retries a slow statement must have undergone for its high retry count to be highlighted as a potential problem application
sql.insights.latency_threshold duration 100ms amount of time after which an executing statement is considered slow. Use 0 to disable. application
+sql.log.redact_names.enabled boolean false if set, schema object identifers are redacted in SQL statements that appear in event logs application
sql.log.slow_query.experimental_full_table_scans.enabled boolean false when set to true, statements that perform a full table/index scan will be logged to the slow query log even if they do not meet the latency threshold. Must have the slow query log enabled for this setting to have any effect. application
sql.log.slow_query.internal_queries.enabled boolean false when set to true, internal queries which exceed the slow query log threshold are logged to a separate log. Must have the slow query log enabled for this setting to have any effect. application
sql.log.slow_query.latency_threshold duration 0s when set to non-zero, log statements whose service latency exceeds the threshold to a secondary logger on each node application
diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html
index 9f52ffe7e320..4b251df5a3a6 100644
--- a/docs/generated/settings/settings.html
+++ b/docs/generated/settings/settings.html
@@ -222,6 +222,7 @@
sql.insights.execution_insights_capacity
| integer | 1000 | the size of the per-node store of execution insights | Serverless/Dedicated/Self-Hosted |
sql.insights.high_retry_count.threshold
| integer | 10 | the number of retries a slow statement must have undergone for its high retry count to be highlighted as a potential problem | Serverless/Dedicated/Self-Hosted |
sql.insights.latency_threshold
| duration | 100ms | amount of time after which an executing statement is considered slow. Use 0 to disable. | Serverless/Dedicated/Self-Hosted |
+sql.log.redact_names.enabled
| boolean | false | if set, schema object identifers are redacted in SQL statements that appear in event logs | Serverless/Dedicated/Self-Hosted |
sql.log.slow_query.experimental_full_table_scans.enabled
| boolean | false | when set to true, statements that perform a full table/index scan will be logged to the slow query log even if they do not meet the latency threshold. Must have the slow query log enabled for this setting to have any effect. | Serverless/Dedicated/Self-Hosted |
sql.log.slow_query.internal_queries.enabled
| boolean | false | when set to true, internal queries which exceed the slow query log threshold are logged to a separate log. Must have the slow query log enabled for this setting to have any effect. | Serverless/Dedicated/Self-Hosted |
sql.log.slow_query.latency_threshold
| duration | 0s | when set to non-zero, log statements whose service latency exceeds the threshold to a secondary logger on each node | Serverless/Dedicated/Self-Hosted |
diff --git a/pkg/ccl/auditloggingccl/audit_logging_test.go b/pkg/ccl/auditloggingccl/audit_logging_test.go
index d77ffa35f04d..e17d4e47a796 100644
--- a/pkg/ccl/auditloggingccl/audit_logging_test.go
+++ b/pkg/ccl/auditloggingccl/audit_logging_test.go
@@ -355,7 +355,7 @@ func TestReducedAuditConfig(t *testing.T) {
// Run a query on the new connection. The new connection will cause the reduced audit config to be re-computed.
// The user now has a corresponding audit setting. We use a new query here to differentiate.
- testRunner2.Exec(t, `GRANT SELECT ON TABLE u TO root`)
+ testRunner2.Exec(t, `ALTER TABLE u ADD COLUMN y STRING DEFAULT 'foo'`)
log.FlushFiles()
@@ -363,14 +363,12 @@ func TestReducedAuditConfig(t *testing.T) {
0,
math.MaxInt64,
10000,
- regexp.MustCompile(`GRANT SELECT ON TABLE ‹u› TO root`),
+ regexp.MustCompile(`ALTER TABLE u ADD COLUMN y STRING DEFAULT ‹'foo'›`),
log.WithMarkedSensitiveData,
)
-
if err != nil {
t.Fatal(err)
}
-
if len(entries) != 1 {
t.Fatal(errors.Newf("unexpected number of entries; expected: %d found: %d", 1, len(entries)))
}
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_1_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_1_of_7.explain
index e004791b05b1..dfa9c82a26cd 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_1_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_1_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 1 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
└── Stage 1 of 1 in PostCommitNonRevertiblePhase
├── 12 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_2_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_2_of_7.explain
index 090408371ce1..63365b471e98 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_2_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_2_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 2 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_3_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_3_of_7.explain
index f07bff2e4bd4..5f86a0bf63ae 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_3_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_3_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 3 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_4_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_4_of_7.explain
index 5d26a70294d2..6973bfe02335 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_4_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_4_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 4 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_5_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_5_of_7.explain
index 69b92b84f871..957f1eba14b5 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_5_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_5_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 5 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_6_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_6_of_7.explain
index 7d27954d0a92..f12c1b193714 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_6_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_6_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 6 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_7_of_7.explain b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_7_of_7.explain
index 555ca23a54c6..36f4d0fab3b9 100644
--- a/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_7_of_7.explain
+++ b/pkg/ccl/schemachangerccl/testdata/end_to_end/create_index/create_index__rollback_7_of_7.explain
@@ -8,7 +8,7 @@ CREATE INDEX idx
PARTITION BY LIST (id) (PARTITION p1 VALUES IN (1));
EXPLAIN (DDL) rollback at post-commit stage 7 of 7;
----
-Schema change plan for rolling back CREATE INDEX ‹idx› ON ‹defaultdb›.public.‹t› (‹id›, ‹name›) STORING (‹money›) PARTITION BY LIST (‹id›) (PARTITION ‹p1› VALUES IN (‹1›));
+Schema change plan for rolling back CREATE INDEX idx ON defaultdb.public.t (id, name) STORING (money) PARTITION BY LIST (id) (PARTITION p1 VALUES IN (‹1›));
└── PostCommitNonRevertiblePhase
├── Stage 1 of 2 in PostCommitNonRevertiblePhase
│ ├── 11 elements transitioning toward ABSENT
diff --git a/pkg/sql/admin_audit_log_test.go b/pkg/sql/admin_audit_log_test.go
index 3ee178afd823..897f040a059a 100644
--- a/pkg/sql/admin_audit_log_test.go
+++ b/pkg/sql/admin_audit_log_test.go
@@ -139,7 +139,7 @@ func TestAdminAuditLogTransaction(t *testing.T) {
db.Exec(t, `SET CLUSTER SETTING sql.log.admin_audit.enabled = true;`)
db.Exec(t, `
BEGIN;
-CREATE TABLE t();
+CREATE TABLE t(a INT8 PRIMARY KEY DEFAULT 2);
SELECT * FROM t;
SELECT 1;
COMMIT;
@@ -155,11 +155,11 @@ COMMIT;
},
{
"select-*-from-table-query",
- `"EventType":"admin_query","Statement":"SELECT * FROM ‹\"\"›.‹\"\"›.‹t›"`,
+ `"EventType":"admin_query","Statement":"SELECT * FROM \"\".\"\".t"`,
},
{
"create-table-query",
- `"EventType":"admin_query","Statement":"CREATE TABLE ‹defaultdb›.public.‹t› ()"`,
+ `"EventType":"admin_query","Statement":"CREATE TABLE defaultdb.public.t (a INT8 PRIMARY KEY DEFAULT ‹2›)"`,
},
}
@@ -222,7 +222,7 @@ func TestAdminAuditLogMultipleTransactions(t *testing.T) {
if _, err := testuser.Exec(`
BEGIN;
-CREATE TABLE t();
+CREATE TABLE t(a INT8 PRIMARY KEY DEFAULT 2);
SELECT * FROM t;
SELECT 1;
COMMIT;
@@ -240,11 +240,11 @@ COMMIT;
},
{
"select-*-from-table-query",
- `"EventType":"admin_query","Statement":"SELECT * FROM ‹\"\"›.‹\"\"›.‹t›"`,
+ `"EventType":"admin_query","Statement":"SELECT * FROM \"\".\"\".t"`,
},
{
"create-table-query",
- `"EventType":"admin_query","Statement":"CREATE TABLE ‹defaultdb›.public.‹t› ()"`,
+ `"EventType":"admin_query","Statement":"CREATE TABLE defaultdb.public.t (a INT8 PRIMARY KEY DEFAULT ‹2›)"`,
},
}
diff --git a/pkg/sql/catalog/internal/validate/schema_changer_state.go b/pkg/sql/catalog/internal/validate/schema_changer_state.go
index 088c7116d2a9..8a07ed65e7f3 100644
--- a/pkg/sql/catalog/internal/validate/schema_changer_state.go
+++ b/pkg/sql/catalog/internal/validate/schema_changer_state.go
@@ -113,7 +113,7 @@ func validateSchemaChangerState(d catalog.Descriptor, vea catalog.ValidationErro
statementRanks.Add(int(s.StatementRank))
if _, ok := statementsExpected[s.StatementRank]; !ok {
report(errors.Errorf("unexpected statement %d (%s)",
- s.StatementRank, s.Statement.Statement))
+ s.StatementRank, s.Statement.RedactedStatement))
}
}
diff --git a/pkg/sql/catalog/internal/validate/schema_changer_state_test.go b/pkg/sql/catalog/internal/validate/schema_changer_state_test.go
index 92aa75ba88b8..f58807dfe573 100644
--- a/pkg/sql/catalog/internal/validate/schema_changer_state_test.go
+++ b/pkg/sql/catalog/internal/validate/schema_changer_state_test.go
@@ -100,7 +100,8 @@ func TestValidateSchemaChangerState(t *testing.T) {
RelevantStatements: []scpb.DescriptorState_Statement{
{
Statement: scpb.Statement{
- Statement: "ALTER TABLE a RENAME TO b",
+ Statement: "ALTER TABLE a RENAME TO b",
+ RedactedStatement: "ALTER TABLE a RENAME TO b",
},
StatementRank: 0,
},
diff --git a/pkg/sql/catalog/redact/redact.go b/pkg/sql/catalog/redact/redact.go
index a75cefe69a55..91b588b40e9b 100644
--- a/pkg/sql/catalog/redact/redact.go
+++ b/pkg/sql/catalog/redact/redact.go
@@ -82,7 +82,7 @@ func redactTableDescriptor(d *descpb.TableDescriptor) (errs []error) {
if scs := d.DeclarativeSchemaChangerState; scs != nil {
for i := range scs.RelevantStatements {
stmt := &scs.RelevantStatements[i]
- stmt.Statement.Statement = stmt.Statement.RedactedStatement
+ stmt.Statement.Statement = stmt.Statement.RedactedStatement.StripMarkers()
}
for i := range scs.Targets {
t := &scs.Targets[i]
@@ -219,7 +219,7 @@ func redactFunctionDescriptor(desc *descpb.FunctionDescriptor) (errs []error) {
if scs := desc.DeclarativeSchemaChangerState; scs != nil {
for i := range scs.RelevantStatements {
stmt := &scs.RelevantStatements[i]
- stmt.Statement.Statement = stmt.Statement.RedactedStatement
+ stmt.Statement.Statement = stmt.Statement.RedactedStatement.StripMarkers()
}
for i := range scs.Targets {
t := &scs.Targets[i]
diff --git a/pkg/sql/conn_executor_exec.go b/pkg/sql/conn_executor_exec.go
index 287e684a5d6e..952b16e4cb42 100644
--- a/pkg/sql/conn_executor_exec.go
+++ b/pkg/sql/conn_executor_exec.go
@@ -2211,7 +2211,7 @@ func (ex *connExecutor) handleTxnRowsGuardrails(
*alreadyLogged = shouldLog
}
if shouldLog {
- commonSQLEventDetails := ex.planner.getCommonSQLEventDetails(defaultRedactionOptions)
+ commonSQLEventDetails := ex.planner.getCommonSQLEventDetails()
var event logpb.EventPayload
if ex.executorType == executorTypeInternal {
if isRead {
diff --git a/pkg/sql/event_log.go b/pkg/sql/event_log.go
index bca393a0ca71..dce5e8867d2d 100644
--- a/pkg/sql/event_log.go
+++ b/pkg/sql/event_log.go
@@ -21,7 +21,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/isql"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scbuild"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scrun"
- "github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/log/eventpb"
@@ -156,33 +155,10 @@ type eventLogOptions struct {
// If verboseTraceLevel is non-zero, its value is used as value for
// the vmodule filter. See exec_log for an example use.
verboseTraceLevel log.Level
-
- // Additional redaction options, if necessary.
- rOpts redactionOptions
-}
-
-// redactionOptions contains instructions on how to redact the SQL
-// events.
-type redactionOptions struct {
- omitSQLNameRedaction bool
}
-func (ro *redactionOptions) toFlags() tree.FmtFlags {
- if ro.omitSQLNameRedaction {
- return tree.FmtOmitNameRedaction
- }
- return tree.FmtSimple
-}
-
-var defaultRedactionOptions = redactionOptions{
- omitSQLNameRedaction: false,
-}
-
-func (p *planner) getCommonSQLEventDetails(opt redactionOptions) eventpb.CommonSQLEventDetails {
- redactableStmt := formatStmtKeyAsRedactableString(
- p.extendedEvalCtx.VirtualSchemas, p.stmt.AST,
- p.extendedEvalCtx.Context.Annotations, opt.toFlags(), p,
- )
+func (p *planner) getCommonSQLEventDetails() eventpb.CommonSQLEventDetails {
+ redactableStmt := p.FormatAstAsRedactableString(p.stmt.AST, p.extendedEvalCtx.Context.Annotations)
commonSQLEventDetails := eventpb.CommonSQLEventDetails{
Statement: redactableStmt,
Tag: p.stmt.AST.StatementTag(),
@@ -210,7 +186,7 @@ func (p *planner) logEventsWithOptions(
p.extendedEvalCtx.ExecCfg, p.InternalSQLTxn(),
1+depth,
opts,
- p.getCommonSQLEventDetails(opts.rOpts),
+ p.getCommonSQLEventDetails(),
entries...)
}
diff --git a/pkg/sql/event_log_test.go b/pkg/sql/event_log_test.go
index e3b0cadfe572..fe8f0851ef10 100644
--- a/pkg/sql/event_log_test.go
+++ b/pkg/sql/event_log_test.go
@@ -147,21 +147,21 @@ func TestPerfLogging(t *testing.T) {
{
query: `INSERT INTO t VALUES (1, pg_sleep(0.256), 'x')`,
errRe: ``,
- logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*‹t› VALUES \(‹1›, pg_sleep\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root"`,
+ logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*\.t VALUES \(‹1›, pg_sleep\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root"`,
logExpected: true,
channel: channel.SQL_PERF,
},
{
query: `INSERT INTO t VALUES (1, pg_sleep(0.256), 'x')`,
errRe: `duplicate key`,
- logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*‹t› VALUES \(‹1›, ‹pg_sleep›\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root"`,
+ logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*\.t VALUES \(‹1›, pg_sleep\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root"`,
logExpected: true,
channel: channel.SQL_PERF,
},
{
query: `INSERT INTO t VALUES (2, pg_sleep(0.256), 'x')`,
errRe: ``,
- logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*‹t› VALUES \(‹2›, pg_sleep\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root","ExecMode":"exec","NumRows":1`,
+ logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*\.t VALUES \(‹2›, pg_sleep\(‹0.256›\), ‹'x'›\)","Tag":"INSERT","User":"root","ExecMode":"exec","NumRows":1`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -175,7 +175,7 @@ func TestPerfLogging(t *testing.T) {
{
query: `INSERT INTO t VALUES (4, pg_sleep(0.256), repeat('x', 1024))`,
errRe: ``,
- logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*‹t› VALUES \(‹4›, pg_sleep\(‹0.256›\), repeat\(‹'x'›, ‹1024›\)\)","Tag":"INSERT","User":"root","ExecMode":"exec","NumRows":1`,
+ logRe: `"EventType":"slow_query","Statement":"INSERT INTO .*\.t VALUES \(‹4›, pg_sleep\(‹0.256›\), repeat\(‹'x'›, ‹1024›\)\)","Tag":"INSERT","User":"root","ExecMode":"exec","NumRows":1`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -189,7 +189,7 @@ func TestPerfLogging(t *testing.T) {
{
query: `SELECT *, pg_sleep(0.064) FROM t`,
errRe: ``,
- logRe: `"EventType":"slow_query","Statement":"SELECT \*, pg_sleep\(‹0.064›\) FROM .*‹t›","Tag":"SELECT","User":"root","ExecMode":"exec","NumRows":4`,
+ logRe: `"EventType":"slow_query","Statement":"SELECT \*, pg_sleep\(‹0.064›\) FROM .*\.t","Tag":"SELECT","User":"root","ExecMode":"exec","NumRows":4`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -504,14 +504,14 @@ func TestPerfLogging(t *testing.T) {
{
query: `SELECT * FROM t WHERE i = 6`,
errRe: ``,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› = ‹6›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i = ‹6›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
logExpected: false,
channel: channel.SQL_PERF,
},
{
query: `SELECT * FROM t WHERE i IN (6, 7, 8)`,
errRe: ``,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› IN \(‹6›, ‹7›, ‹8›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":3`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i IN \(‹6›, ‹7›, ‹8›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":3`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -520,7 +520,7 @@ func TestPerfLogging(t *testing.T) {
cleanup: `COMMIT`,
query: `SELECT * FROM t WHERE i = 6; SELECT * FROM t WHERE i = 7; SELECT * FROM t WHERE i = 8;`,
errRe: ``,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› = ‹8›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":3`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i = ‹8›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":3`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -529,14 +529,14 @@ func TestPerfLogging(t *testing.T) {
cleanup: `RESET transaction_rows_read_log`,
query: `SELECT * FROM t WHERE i IN (6, 7)`,
errRe: ``,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› IN \(‹6›, ‹7›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":2`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i IN \(‹6›, ‹7›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":2`,
logExpected: true,
channel: channel.SQL_PERF,
},
{
query: `SELECT * FROM t WHERE i IN (6, 7, 8, 9)`,
errRe: `pq: txn has read 4 rows, which is above the limit: TxnID .* SessionID .*`,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› IN \(‹6›, ‹7›, ‹8›, ‹9›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":4`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i IN \(‹6›, ‹7›, ‹8›, ‹9›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":4`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -545,7 +545,7 @@ func TestPerfLogging(t *testing.T) {
cleanup: `ROLLBACK`,
query: `SELECT * FROM t WHERE i IN (6, 7); SELECT * FROM t WHERE i IN (8, 9)`,
errRe: `pq: txn has read 4 rows, which is above the limit: TxnID .* SessionID .*`,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› IN \(‹8›, ‹9›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":4`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i IN \(‹8›, ‹9›\)","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*,"NumRows":4`,
logExpected: true,
channel: channel.SQL_PERF,
},
@@ -554,7 +554,7 @@ func TestPerfLogging(t *testing.T) {
cleanup: `RESET transaction_rows_read_err`,
query: `SELECT * FROM t WHERE i = 6 OR i = 7`,
errRe: `pq: txn has read 2 rows, which is above the limit: TxnID .* SessionID .*`,
- logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*‹t› WHERE ‹i› = ‹6› OR ‹i› = ‹7›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
+ logRe: `"EventType":"txn_rows_read_limit","Statement":"SELECT \* FROM .*\.t WHERE i = ‹6› OR ‹i› = ‹7›","Tag":"SELECT","User":"root","TxnID":.*,"SessionID":.*`,
logExpected: false,
channel: channel.SQL_PERF,
},
diff --git a/pkg/sql/exec_log.go b/pkg/sql/exec_log.go
index 1ecb31dd94ab..7acd58e11fe4 100644
--- a/pkg/sql/exec_log.go
+++ b/pkg/sql/exec_log.go
@@ -436,7 +436,7 @@ func (p *planner) maybeLogStatementInternal(
SchemaChangerMode: p.curPlan.instrumentation.schemaChangerMode.String(),
}
- p.logOperationalEventsOnlyExternally(ctx, sampledQuery)
+ p.logEventsOnlyExternally(ctx, sampledQuery)
}
}
@@ -532,17 +532,3 @@ func (p *planner) logEventsOnlyExternally(ctx context.Context, entries ...logpb.
eventLogOptions{dst: LogExternally},
entries...)
}
-
-// logOperationalEventsOnlyExternally is a helper that sets redaction
-// options to omit SQL Name redaction. This is used when logging to
-// the telemetry channel when we want additional metadata available.
-func (p *planner) logOperationalEventsOnlyExternally(
- ctx context.Context, entries ...logpb.EventPayload,
-) {
- // The API contract for logEventsWithOptions() is that it returns
- // no error when system.eventlog is not written to.
- _ = p.logEventsWithOptions(ctx,
- 2, /* depth: we want to use the caller location */
- eventLogOptions{dst: LogExternally, rOpts: redactionOptions{omitSQLNameRedaction: true}},
- entries...)
-}
diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go
index d43e7de8b3c7..b5cb8de5439b 100644
--- a/pkg/sql/exec_util.go
+++ b/pkg/sql/exec_util.go
@@ -3894,19 +3894,35 @@ func scrubStmtStatKey(vt VirtualTabler, key string, ns eval.ClientNoticeSender)
return f.CloseAndGetString(), true
}
+var redactNamesInSQLStatementLog = settings.RegisterBoolSetting(
+ settings.ApplicationLevel,
+ "sql.log.redact_names.enabled",
+ "if set, schema object identifers are redacted in SQL statements that appear in event logs",
+ false,
+ settings.WithPublic,
+)
+
+// FormatAstAsRedactableString implements scbuild.AstFormatter
+func (p *planner) FormatAstAsRedactableString(
+ statement tree.Statement, annotations *tree.Annotations,
+) redact.RedactableString {
+ fs := tree.FmtSimple | tree.FmtAlwaysQualifyTableNames | tree.FmtMarkRedactionNode
+ if !redactNamesInSQLStatementLog.Get(&p.extendedEvalCtx.Settings.SV) {
+ fs = fs | tree.FmtOmitNameRedaction
+ }
+ return formatStmtKeyAsRedactableString(statement, annotations, fs)
+}
+
// formatStmtKeyAsRedactableString given an AST node this function will fully
// qualify names using annotations to format it out into a redactable string.
+// Object names are not redacted, but constants and datums are.
func formatStmtKeyAsRedactableString(
- vt VirtualTabler,
- rootAST tree.Statement,
- ann *tree.Annotations,
- fs tree.FmtFlags,
- ns eval.ClientNoticeSender,
+ rootAST tree.Statement, ann *tree.Annotations, fs tree.FmtFlags,
) redact.RedactableString {
f := tree.NewFmtCtx(
- tree.FmtAlwaysQualifyTableNames|tree.FmtMarkRedactionNode|fs,
+ fs,
tree.FmtAnnotations(ann),
- tree.FmtReformatTableNames(hideNonVirtualTableNameFunc(vt, ns)))
+ )
f.FormatNode(rootAST)
formattedRedactableStatementString := f.CloseAndGetString()
return redact.RedactableString(formattedRedactableStatementString)
diff --git a/pkg/sql/opt/exec/execbuilder/testdata/show_trace b/pkg/sql/opt/exec/execbuilder/testdata/show_trace
index 9f944fd6af09..aae387398e24 100644
--- a/pkg/sql/opt/exec/execbuilder/testdata/show_trace
+++ b/pkg/sql/opt/exec/execbuilder/testdata/show_trace
@@ -165,7 +165,7 @@ query TT
$trace_query
----
sql query rows affected: 0
-commit sql txn CPut /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:1 not_visible:false invisibility:0 > next_index_id:2 privileges: users: owner_proto:"root" version:3 > next_mutation_id:1 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false refresh_view_required:false declarative_schema_changer_state:<...> > metadata:<...> target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:DROPPED current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:PUBLIC current_statuses:PUBLIC target_ranks:0 target_ranks:1 target_ranks:2 target_ranks:3 target_ranks:4 target_ranks:5 target_ranks:6 target_ranks:7 target_ranks:8 target_ranks:9 target_ranks:10 target_ranks:11 target_ranks:12 target_ranks:13 target_ranks:14 target_ranks:15 target_ranks:16 target_ranks:17 target_ranks:18 target_ranks:19 target_ranks:20 target_ranks:21 target_ranks:22 target_ranks:23 target_ranks:24 target_ranks:25 target_ranks:26 target_ranks:27 target_ranks:28 target_ranks:29 target_ranks:30 relevant_statements: > authorization: name_mapping: > drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 import_start_wall_time:0 schema_locked:false import_epoch:0 import_type:IMPORT_WITH_START_TIME_ONLY >
+commit sql txn CPut /Table/3/1/109/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:false default_expr:"unique_rowid()" hidden:true inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:4 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:1 not_visible:false invisibility:0 > next_index_id:2 privileges: users: owner_proto:"root" version:3 > next_mutation_id:1 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false refresh_view_required:false declarative_schema_changer_state:<...> > metadata:<...> target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > is_nullable:true element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:DROPPED current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:ABSENT current_statuses:PUBLIC current_statuses:PUBLIC target_ranks:0 target_ranks:1 target_ranks:2 target_ranks:3 target_ranks:4 target_ranks:5 target_ranks:6 target_ranks:7 target_ranks:8 target_ranks:9 target_ranks:10 target_ranks:11 target_ranks:12 target_ranks:13 target_ranks:14 target_ranks:15 target_ranks:16 target_ranks:17 target_ranks:18 target_ranks:19 target_ranks:20 target_ranks:21 target_ranks:22 target_ranks:23 target_ranks:24 target_ranks:25 target_ranks:26 target_ranks:27 target_ranks:28 target_ranks:29 target_ranks:30 relevant_statements: > authorization: name_mapping: > drop_time:... replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"TABLE t.public.kv" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:2 import_start_wall_time:0 schema_locked:false import_epoch:0 import_type:IMPORT_WITH_START_TIME_ONLY >
commit sql txn Del /NamespaceTable/30/1/106/107/"kv2"/4/1
statement ok
@@ -194,7 +194,7 @@ query TT
$trace_query
----
sql query rows affected: 0
-commit sql txn CPut /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:1 not_visible:false invisibility:0 > next_index_id:4 privileges: users: owner_proto:"root" version:3 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:2 not_visible:false invisibility:0 > state:WRITE_ONLY direction:DROP mutation_id:2 rollback:false > next_mutation_id:2 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false refresh_view_required:false declarative_schema_changer_state:<...> > metadata:<...> target_status:PUBLIC > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata:<> target_status:PUBLIC > current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:VALIDATED current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:PUBLIC target_ranks:0 target_ranks:1 target_ranks:2 target_ranks:3 target_ranks:4 target_ranks:5 target_ranks:6 relevant_statements: > authorization: name_mapping: columns: columns: columns: families: indexes: > > drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:4 import_start_wall_time:0 schema_locked:false import_epoch:0 import_type:IMPORT_WITH_START_TIME_ONLY >
+commit sql txn CPut /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:1 not_visible:false invisibility:0 > next_index_id:4 privileges: users: owner_proto:"root" version:3 > mutations: interleave:<> partitioning: type:FORWARD created_explicitly:true encoding_type:0 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:2 not_visible:false invisibility:0 > state:WRITE_ONLY direction:DROP mutation_id:2 rollback:false > next_mutation_id:2 format_version:3 state:PUBLIC offline_reason:"" view_query:"" is_materialized_view:false refresh_view_required:false declarative_schema_changer_state:<...> > metadata:<...> target_status:PUBLIC > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata:<> target_status:PUBLIC > current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:VALIDATED current_statuses:PUBLIC current_statuses:PUBLIC current_statuses:PUBLIC target_ranks:0 target_ranks:1 target_ranks:2 target_ranks:3 target_ranks:4 target_ranks:5 target_ranks:6 relevant_statements: > authorization: name_mapping: columns: columns: columns: families: indexes: > > drop_time:0 replacement_of: > audit_mode:DISABLED drop_job_id:0 create_query:"" create_as_of_time:<...> temporary:false partition_all_by:false exclude_data_from_backup:false next_constraint_id:4 import_start_wall_time:0 schema_locked:false import_epoch:0 import_type:IMPORT_WITH_START_TIME_ONLY >
statement ok
SET tracing = on,kv,results; DROP TABLE t.kv
@@ -206,7 +206,7 @@ query TT
$trace_query
----
sql query rows affected: 0
-commit sql txn CPut /Table/3/1/108/2/1 -> table: parent_id:106 unexposed_parent_schema_id:107 columns: nullable:false hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > columns: nullable:true hidden:false inaccessible:false generated_as_identity_type:NOT_IDENTITY_COLUMN virtual:false pg_attribute_num:0 alter_column_type_in_progress:false system_column_kind:NONE > next_column_id:3 families: next_family_id:1 primary_index: interleave:<> partitioning: type:FORWARD created_explicitly:false encoding_type:1 sharded: disabled:false geo_config:<> predicate:"" use_delete_preserving_encoding:false created_at_nanos:... constraint_id:1 not_visible:false invisibility:0 > next_index_id:4 privileges: users: owner_proto:"root" version:3 > next_mutation_id:2 format_version:3 state:DROP offline_reason:"" view_query:"" is_materialized_view:false refresh_view_required:false declarative_schema_changer_state:<...> > metadata:<...> target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > element_creation_metadata: > > metadata: target_status:ABSENT > targets: > metadata: target_status:ABSENT > targets: > metadata: