sql/schemachanger: Add support for storing expressions in policies #139254
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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