-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
138909: sql/schemachanger: Add support for storing policy command and type r=spilchen a=spilchen A previous commit introduced basic support for CREATE/DROP POLICY. This commit expands on that functionality by storing additional details in the policy descriptor. Specifically, it adds support for storing the policy type (restrictive or permissive) and the policy command (ALL, SELECT, INSERT, UPDATE, or DELETE). Since neither the policy type nor the policy command will be modifiable via ALTER POLICY, these attributes are included in the Policy element within the DSC, rather than as separate elements. Epic: CRDB-11724 Informs: #136696 Release note: None 138979: roachtest: update activerecord and ruby-pg expected failures r=rafiss a=rafiss - Mark 2 activerecord tests as flaky. - Mark 4 ruby-pg tests as passing after #138709 was merged. fixes #138886 fixes #138881 Release note: None Co-authored-by: Matt Spilchen <[email protected]> Co-authored-by: Rafi Shamim <[email protected]>
- Loading branch information
Showing
21 changed files
with
332 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2025 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the CockroachDB Software License | ||
// included in the /LICENSE file. | ||
|
||
package catpb | ||
|
||
// SafeValue implements the redact.SafeValue interface. | ||
func (PolicyType) SafeValue() {} | ||
|
||
// SafeValue implements the redact.SafeValue interface. | ||
func (PolicyCommand) SafeValue() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
setup | ||
CREATE TABLE defaultdb.foo (i INT PRIMARY KEY); | ||
CREATE USER fred; | ||
---- | ||
|
||
build | ||
CREATE POLICY "first policy" on defaultdb.foo AS PERMISSIVE FOR SELECT TO fred USING (i > 0) WITH CHECK (i % 2 = 0); | ||
---- | ||
- [[IndexData:{DescID: 104, IndexID: 1}, PUBLIC], PUBLIC] | ||
{indexId: 1, tableId: 104} | ||
- [[TableData:{DescID: 104, ReferencedDescID: 100}, PUBLIC], PUBLIC] | ||
{databaseId: 100, tableId: 104} | ||
- [[Policy:{DescID: 104, PolicyID: 1}, PUBLIC], ABSENT] | ||
{command: 2, policyId: 1, tableId: 104, type: 1} | ||
- [[PolicyName:{DescID: 104, Name: first policy, PolicyID: 1}, PUBLIC], ABSENT] | ||
{name: first policy, policyId: 1, tableId: 104} | ||
|
||
build | ||
CREATE POLICY "second policy" on defaultdb.foo AS RESTRICTIVE FOR INSERT USING (false); | ||
---- | ||
- [[IndexData:{DescID: 104, IndexID: 1}, PUBLIC], PUBLIC] | ||
{indexId: 1, tableId: 104} | ||
- [[TableData:{DescID: 104, ReferencedDescID: 100}, PUBLIC], PUBLIC] | ||
{databaseId: 100, tableId: 104} | ||
- [[Policy:{DescID: 104, PolicyID: 1}, PUBLIC], ABSENT] | ||
{command: 3, policyId: 1, tableId: 104, type: 2} | ||
- [[PolicyName:{DescID: 104, Name: second policy, PolicyID: 1}, PUBLIC], ABSENT] | ||
{name: second policy, policyId: 1, tableId: 104} | ||
|
||
build | ||
CREATE POLICY "third policy" on defaultdb.foo FOR DELETE TO CURRENT_USER,fred WITH CHECK (i < 0); | ||
---- | ||
- [[IndexData:{DescID: 104, IndexID: 1}, PUBLIC], PUBLIC] | ||
{indexId: 1, tableId: 104} | ||
- [[TableData:{DescID: 104, ReferencedDescID: 100}, PUBLIC], PUBLIC] | ||
{databaseId: 100, tableId: 104} | ||
- [[Policy:{DescID: 104, PolicyID: 1}, PUBLIC], ABSENT] | ||
{command: 5, policyId: 1, tableId: 104, type: 1} | ||
- [[PolicyName:{DescID: 104, Name: third policy, PolicyID: 1}, PUBLIC], ABSENT] | ||
{name: third policy, policyId: 1, tableId: 104} | ||
|
||
build | ||
CREATE POLICY "fourth policy" on defaultdb.foo AS PERMISSIVE TO PUBLIC,CURRENT_SESSION; | ||
---- | ||
- [[IndexData:{DescID: 104, IndexID: 1}, PUBLIC], PUBLIC] | ||
{indexId: 1, tableId: 104} | ||
- [[TableData:{DescID: 104, ReferencedDescID: 100}, PUBLIC], PUBLIC] | ||
{databaseId: 100, tableId: 104} | ||
- [[Policy:{DescID: 104, PolicyID: 1}, PUBLIC], ABSENT] | ||
{command: 1, policyId: 1, tableId: 104, type: 1} | ||
- [[PolicyName:{DescID: 104, Name: fourth policy, PolicyID: 1}, PUBLIC], ABSENT] | ||
{name: fourth policy, policyId: 1, tableId: 104} |
Oops, something went wrong.