@@ -3959,7 +3959,7 @@ CREATE TABLE crdb_internal.create_statements (
3959
3959
create_statement STRING NOT NULL,
3960
3960
state STRING NOT NULL,
3961
3961
create_nofks STRING NOT NULL,
3962
- policy_statements STRING[] NOT NULL,
3962
+ rls_statements STRING[] NOT NULL,
3963
3963
alter_statements STRING[] NOT NULL,
3964
3964
validate_statements STRING[] NOT NULL,
3965
3965
create_redactable STRING NOT NULL,
@@ -3984,7 +3984,7 @@ CREATE TABLE crdb_internal.create_statements (
3984
3984
var descType tree.Datum
3985
3985
var stmt , createNofk , createRedactable string
3986
3986
alterStmts := tree .NewDArray (types .String )
3987
- policyStmts := tree .NewDArray (types .String )
3987
+ rlsStmts := tree .NewDArray (types .String )
3988
3988
validateStmts := tree .NewDArray (types .String )
3989
3989
namePrefix := tree.ObjectNamePrefix {SchemaName : tree .Name (sc .GetName ()), ExplicitSchema : true }
3990
3990
name := tree .MakeTableNameFromPrefix (namePrefix , tree .Name (table .GetName ()))
@@ -4007,8 +4007,7 @@ CREATE TABLE crdb_internal.create_statements (
4007
4007
} else {
4008
4008
descType = typeTable
4009
4009
displayOptions := ShowCreateDisplayOptions {
4010
- FKDisplayMode : OmitFKClausesFromCreate ,
4011
- IgnoreRLSStatements : true ,
4010
+ FKDisplayMode : OmitFKClausesFromCreate ,
4012
4011
}
4013
4012
createNofk , err = ShowCreateTable (ctx , p , & name , contextName , table , lookup , displayOptions )
4014
4013
if err != nil {
@@ -4019,12 +4018,12 @@ CREATE TABLE crdb_internal.create_statements (
4019
4018
return err
4020
4019
}
4021
4020
4022
- if err = showPolicyStatements (ctx , & name , table , p .EvalContext (), & p .semaCtx , p .SessionData (), policyStmts ); err != nil {
4021
+ if err = showRowLevelSecurityStatements (ctx , & name , table , p .EvalContext (), & p .semaCtx , p .SessionData (), rlsStmts ); err != nil {
4023
4022
return err
4024
4023
}
4025
4024
4026
4025
displayOptions .FKDisplayMode = IncludeFkClausesInCreate
4027
- displayOptions . IgnoreRLSStatements = false
4026
+
4028
4027
stmt , err = ShowCreateTable (ctx , p , & name , contextName , table , lookup , displayOptions )
4029
4028
if err != nil {
4030
4029
return err
@@ -4056,7 +4055,7 @@ CREATE TABLE crdb_internal.create_statements (
4056
4055
tree .NewDString (stmt ),
4057
4056
tree .NewDString (table .GetState ().String ()),
4058
4057
tree .NewDString (createNofk ),
4059
- policyStmts ,
4058
+ rlsStmts ,
4060
4059
alterStmts ,
4061
4060
validateStmts ,
4062
4061
tree .NewDString (createRedactable ),
@@ -4068,21 +4067,31 @@ CREATE TABLE crdb_internal.create_statements (
4068
4067
},
4069
4068
nil )
4070
4069
4071
- // showPolicyStatements adds the RLS policy statements to the policy_statements column.
4072
- func showPolicyStatements (
4070
+ // showRowLevelSecurityStatements adds the RLS policy statements to the rls_statements column.
4071
+ func showRowLevelSecurityStatements (
4073
4072
ctx context.Context ,
4074
4073
tn * tree.TableName ,
4075
4074
table catalog.TableDescriptor ,
4076
4075
evalCtx * eval.Context ,
4077
4076
semaCtx * tree.SemaContext ,
4078
4077
sessionData * sessiondata.SessionData ,
4079
- policyStmts * tree.DArray ,
4078
+ rlsStmts * tree.DArray ,
4080
4079
) error {
4080
+ // Add the row level security ALTER statements to the rls_statements column.
4081
+ if alterRLSStatements , err := showRLSAlterStatement (tn , table , false ); err != nil {
4082
+ return err
4083
+ } else if len (alterRLSStatements ) != 0 {
4084
+ if err = rlsStmts .Append (tree .NewDString (alterRLSStatements )); err != nil {
4085
+ return err
4086
+ }
4087
+ }
4088
+
4089
+ // Add the row level security policy statements to the rls_statements column.
4081
4090
for _ , policy := range table .GetPolicies () {
4082
4091
if policyStatement , err := showPolicyStatement (ctx , tn , table , evalCtx , semaCtx , sessionData , policy , false ); err != nil {
4083
4092
return err
4084
4093
} else if len (policyStatement ) != 0 {
4085
- if err := policyStmts .Append (tree .NewDString (policyStatement )); err != nil {
4094
+ if err := rlsStmts .Append (tree .NewDString (policyStatement )); err != nil {
4086
4095
return err
4087
4096
}
4088
4097
}
@@ -4135,15 +4144,6 @@ func showAlterStatement(
4135
4144
}
4136
4145
}
4137
4146
4138
- // Add the row level security ALTER statements to the alter_statements column.
4139
- if alterRLSStatements , err := showRLSAlterStatement (tn , table , false ); err != nil {
4140
- return err
4141
- } else if len (alterRLSStatements ) != 0 {
4142
- if err = alterStmts .Append (tree .NewDString (alterRLSStatements )); err != nil {
4143
- return err
4144
- }
4145
- }
4146
-
4147
4147
return nil
4148
4148
}
4149
4149
0 commit comments