Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/schemachanger: Add support for storing expressions in policies #139254

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

spilchen
Copy link
Contributor

Stacked PR

sql/schemachanger: Add support for storing expressions in policies

This commit builds on previous work for storing policy info in the table
descriptor. It adds storing of policy expressions. A policy can have
one expression for reading rows (USING) and one expression for writing
rows (WITH CHECK). The necessary plumbing was added to the DSC to allow
us to store the expressions in the table descriptor.

To keep the scope manageable, this commit does not yet handle forward or
backward references for objects (e.g., columns, UDTs, sequences, or
functions) referenced in the expressions. A follow-up change will address
maintaining these references. Until that is implemented, it will be
possible to drop any of these objects when they are referenced in a
policy expression.

Epic: CRDB-11724
Informs: #136696
Release note: None

sql/schemachanger: Add dependency tracking for policy expressions

A prior change introduced the storage of policy expressions within the
table descriptor. This update builds on that by adding forward and
backward references for objects used in these expressions. These
references ensure that dependent objects cannot be dropped if they are
actively used in a policy expression.

As part of this change, functions are now permitted within policy
expressions. Previously, their use was blocked; however, with proper
dependency tracking in place, this restriction can be safely lifted.

To accommodate dependencies arising from the two possible expressions
(USING and WITH CHECK) in a policy, a new descriptor element,
PolicyDeps, was introduced. This element tracks dependencies for both
expressions.

Epic: CRDB-11724
Informs: #136696
Release note: None

@spilchen spilchen self-assigned this Jan 16, 2025
@spilchen spilchen requested review from a team as code owners January 16, 2025 20:32
Copy link

blathers-crl bot commented Jan 16, 2025

Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

This commit builds on previous work for storing policy info in the table
descriptor. It adds storing of policy expressions. A policy can have
one expression for reading rows (USING) and one expression for writing
rows (WITH CHECK). The necessary plumbing was added to the DSC to allow
us to store the expressions in the table descriptor.

To keep the scope manageable, this commit does not yet handle forward or
backward references for objects (e.g., columns, UDTs, sequences, or
functions) referenced in the expressions. A follow-up change will address
maintaining these references. Until that is implemented, it will be
possible to drop any of these objects when they are referenced in a
policy expression.

Epic: CRDB-11724
Informs: cockroachdb#136696
Release note: None
A prior change introduced the storage of policy expressions within the
table descriptor. This update builds on that by adding forward and
backward references for objects used in these expressions. These
references ensure that dependent objects cannot be dropped if they are
actively used in a policy expression.

As part of this change, functions are now permitted within policy
expressions. Previously, their use was blocked; however, with proper
dependency tracking in place, this restriction can be safely lifted.

To accommodate dependencies arising from the two possible expressions
(USING and WITH CHECK) in a policy, a new descriptor element,
PolicyDeps, was introduced. This element tracks dependencies for both
expressions.

Epic: CRDB-11724
Informs: cockroachdb#136696
Release note: None
@spilchen spilchen force-pushed the gh-136696/250116/1611/expr/full-pr-ready branch from b48c727 to a8b5137 Compare January 17, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants