-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Drop function in declarative schema changer #95153
sql/schemachanger: Drop function in declarative schema changer #95153
Conversation
c2857a1
to
fd28925
Compare
4addadd
to
f08485e
Compare
be3b07d
to
b6d46c5
Compare
} | ||
for _, f := range n.Functions { | ||
elts := b.ResolveUDF(&f, ResolveParams{ | ||
IsExistenceOptional: n.IfExists, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't here be another requiredPrivilege : DROP
for b.ResolveUDF
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function only has EXECUTE
privilege. Only function owner can drop the function or perform any schema changes on function. So we have b.mustOwn(fnID)
in ResolveUDF
to validate that
func TestRollback_drop_function(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
sctest.Rollback(t, "pkg/sql/schemachanger/testdata/end_to_end/drop_function", sctest.SingleNodeCluster) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have rollback test here but I didn't find any output text files in explain/explain_verbose
directory. Is this right?
@@ -15,7 +15,11 @@ StatementPhase stage 1 of 1 with 1 MutationType op | |||
ops: | |||
*scop.MarkDescriptorAsSyntheticallyDropped | |||
DescriptorID: 105 | |||
<<<<<<< HEAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix all the merge conflicts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops. I messed it up. done.
(*scpb.FunctionName)(nil), | ||
(*scpb.FunctionVolatility)(nil), | ||
(*scpb.FunctionLeakProof)(nil), | ||
(*scpb.FunctionNullInputBehavior)(nil), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about *scop.FunctionBody
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't skip the op for FunctionBody
because we need to handle cross references removals.
emit(func(this *scpb.ObjectParent) *scop.RemoveObjectParent { | ||
return &scop.RemoveObjectParent{ | ||
ObjectID: this.ObjectID, | ||
ParentSchemaID: this.ParentSchemaID, | ||
} | ||
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need to change this part at all, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm
d0ebaa0
to
6d5135f
Compare
Sorry for the slow turnaround on my end. I'll review this on Monday! |
If it's not too much trouble I'd prefer it if this PR waited until #95631 was done. I'm running out of time before going away on leave and the rebase is likely to hurt. |
Totally understood. |
9718ffe
to
08bad65
Compare
This commit adds function element definitions and decomposition logics. Release note: None
This should work for both view and function, so renaming it to RemoveBackReferencesInRelations. Release note: None
This commit implements DROP FUNCTION given existing declarative schema changer infra (rules and ops). `RemoveObjectParent` is added to handle the removal of function signature from schema. Release note: None
08bad65
to
07ba6fb
Compare
TFTR! |
Build succeeded: |
This pr contains 3 commits:
Part of: https://cockroachlabs.atlassian.net/browse/CRDB-19495
Fixes: #83235