-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: pg_proc
and SHOW CREATE FUNCTION
#85656
sql: pg_proc
and SHOW CREATE FUNCTION
#85656
Conversation
2b8b413
to
cc450e1
Compare
@@ -796,7 +796,6 @@ func EnsureTypeIsHydrated( | |||
return err | |||
} | |||
} | |||
return 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.
I think this was a bug that EnsureTypeIsHydrated
didn't hydrate table implicit types which is actually a tuple. Let me know if this makes sense..
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.
if we make this change, let's also add a test that shows why it's needed.
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.
ah yeah, good call, I'll add one for it.
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.
i just had some small nits. nice work!
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @chengxiong-ruan)
pkg/sql/crdb_internal.go
line 2581 at r2 (raw file):
var crdbInternalCreateFunctionStmtsTable = virtualSchemaTable{ comment: "CREATE statements for all ",
nit: incomplete sentence
pkg/sql/catalog/funcdesc/func_desc.go
line 538 at r2 (raw file):
// ToTreeNode implements the FunctionDescriptor interface. func (desc *immutable) ToTreeNode() (ret *tree.CreateFunction, err error) {
nit: i think a name like func (desc *immutable) CreateExpr
or func (desc *immutable) ToCreateExpr
might be a bit more natural
pkg/sql/catalog/funcdesc/func_desc.go
line 570 at r2 (raw file):
} func (desc *immutable) getTreeNodeLang() tree.FunctionLanguage {
i think the TreeNode
part of the name is slightly redundant, since we can already see that in the return type
pkg/sql/catalog/funcdesc/func_desc.go
line 578 at r2 (raw file):
} func (desc *immutable) getTreeNodeVolatility() tree.FunctionVolatility {
ditto
pkg/sql/catalog/funcdesc/func_desc.go
line 590 at r2 (raw file):
} func (desc *immutable) getTreeNodeNullInputBehavior() tree.FunctionNullInputBehavior {
ditto
cc450e1
to
d076135
Compare
@rafiss sorry I didn't see your reviews and I added an extra small commit to add |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @chengxiong-ruan)
pkg/sql/sem/eval/parse_doid.go
line 73 at r6 (raw file):
name.Parts[i] = substrs[len(substrs)-1-i] } funcDef, err := ctx.Planner.ResolveFunction(ctx.Ctx(), &name, &ctx.SessionData().SearchPath)
you will also need to update performIntToOidCast
inside eval/cast.go (and add tests please)
d076135
to
2399573
Compare
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @rafiss)
pkg/sql/catalog/funcdesc/func_desc.go
line 538 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
nit: i think a name like
func (desc *immutable) CreateExpr
orfunc (desc *immutable) ToCreateExpr
might be a bit more natural
yeah, good point, fixed
pkg/sql/catalog/funcdesc/func_desc.go
line 570 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
i think the
TreeNode
part of the name is slightly redundant, since we can already see that in the return type
yeah, but I want to distinguish from the function return the catpb
one. Inspired by your another comment on naming, I replaced TreeNode
with CreateExpr
. Hope that makes sense.
pkg/sql/catalog/funcdesc/func_desc.go
line 578 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
ditto
fixed with same renaming
pkg/sql/catalog/funcdesc/func_desc.go
line 590 at r2 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
ditto
fixed with same renaming
pkg/sql/sem/eval/parse_doid.go
line 73 at r6 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
you will also need to update
performIntToOidCast
inside eval/cast.go (and add tests please)
fixed that, and also added a test to make sure function using table implicit types are hydrated properly.
9e6be59
to
3812048
Compare
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.
LGTM
TFTR! |
👎 Rejected by code reviews |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @rafiss)
pkg/sql/sem/eval/cast.go
line 943 at r9 (raw file):
case oid.T_regproc, oid.T_regprocedure: name, _, err := res.ResolveFunctionByOID(ctx, oid.Oid(v))
i think this is going to have the same issue that was just fixed in #85086 -- it's not always safe to ignore this error. (specifically, in the case where the error causes the txn to abort.) so i think you may want something similar where ResolveFunctionByOID
also returns a "safe to ignore error" flag. OR refactor things so that this code never needs to ignore the error.
Previously, rafiss (Rafi Shamim) wrote…
yeah, good point, I added a |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chengxiong-ruan and @rafiss)
pkg/sql/sem/eval/cast.go
line 943 at r9 (raw file):
Previously, chengxiong-ruan (Chengxiong Ruan) wrote…
yeah, good point, I added a
ErrFunctionUndefined
in another pr which bases on this pr. I'll fix this separately outside of this PR, does that sound good?
sure that sounds good
TFTR! |
Build failed (retrying...): |
need to rebased and update udf logic test with increased ids since there were new objects added. |
Canceled. |
3812048
to
08b6f60
Compare
only one flaky test failed, thanks again for the reviews! |
canceling to wait until Marcus' #85674 is merged, there is conflict. |
Canceled. |
This commit extends the pg_proc virtual table with user-defined functions. Release note (sql change): Previously pg_proc table was only populated with builtin functions. With createing UDFs supported, pg_proc table is extended to be populated with UDFs data as well.
Release note (sql change): a new virtual table crdb_internal.create_function_statements is added, so that users can use to query create statements of user defined functions, as well as parent db and schema ids.
Release note (sql change): This commit adds support for the SHOW CREATE FUNCTION statement. If given function name is qualified, the explicit schema will be searched. If function name is not qualified, the schemas on search path are searched and functions from the most significant schema are returned.
08b6f60
to
9f37f9e
Compare
Release note (sql change): Previously, the `::regproc` casting only supported builtin functions. Now it's extened to support user-defined functions as well.
9f37f9e
to
4e4e5d9
Compare
TFTR again! |
Build succeeded: |
Posting here for visibility - I think we have a nil pointer issue with the crdb_internal table when querying across databases. Issue here: #85897 |
This addresses a comment from the review of cockroachdb#85656. Release note: None
85680: amazon,externalconn: add s3 support to External Connections r=adityamaru a=adityamaru This change registers s3 as a URI that can be represented as an External Connection. Most notably we take a page from the CDC book and switch the s3 parse function to check for invalid parameters, and configurations. This allows us to catch certain misconfiguration at the time we create the external connection. Informs: #84753 Release note (sql change): Users can now `CREATE EXTERNAL CONNECTION` to represent an s3 URI. 85849: sql/catalog/tabledesc: relaxed validation for virtual col in SUFFIX cols r=Xiang-Gu a=Xiang-Gu One of the validation rule says that "we don't allow virtual columns to be in the SUFFIX columns of a secondary index", except for one case: `ALTER PRIMARY KYE USING HASH`, where the implicitly created virtual, shard column, will need to appear in the SUFFIX columns of the implicitly created unique, secondary index of the old PK key columns ( which btw is a CRDB unique feature). The validation has logic to exempt us from this special case but it's written specifically to the legacy schema changer. Namely, it uses the canonical `PrimaryKeySwap` mutation type as the signal but we don't have that in the declarative schema changer. This PR addresses this issue and allows the validation logic to also exempt the exact same case but in the declarative schema changer. Release note: None 85862: ui: new insights table component r=maryliag a=maryliag Creation of the base insights table, that can be used on both schema insights and statement details page. This commit only introduce the table, with the different types, but still needs the proper cell formating for each type. Part of #83783 Release note: None 85865: rowexec: use the sorter's own context r=yuzefovich a=yuzefovich Release note: none 85866: streamingccl, rowexec: correctly mark eventStream as "streaming" r=yuzefovich a=yuzefovich This commit fixes an incomplete solution of 9bb5d30 which attempted to mark `eventStream` generator builtin as "streaming" so that the columnarizer on top of the `projectSetProcessor` would not buffer anything. As found by Steven, the solution in that commit was incomplete since the generators array is not populated at the time where `MustBeStreaming` check is performed. This commit fixes that oversight by using a different way of propagating the property - via the function properties. Release note: None 85885: kvserver: add queue size metric to RaftTransport r=tbg a=pavelkalinnikov Currently, there is a `RaftEnqueuePending` metric in `StoreMetrics` which exposes the `RaftTransport` outgoing queue size. However, this is a per-`Store` metric, so it duplicates the same variable across all the stores. The metric should be tracked on a per-node/transport basis. This PR introduces a per-transport `SendQueueSize` metric to replace the old `RaftEnqueuePending`. It also does the necessary plumbing to include it to the exported metrics, since it's the first metric in `RaftTransport`. <img width="1350" alt="Screenshot 2022-08-10 at 15 37 47" src="https://user-images.githubusercontent.com/3757441/183929666-0f6523d7-5877-4f2f-8460-4f013f87966d.png"> Touches #83917 Release note: None 85906: eval: don't always ignore error from ResolveFunctionByOID r=chengxiong-ruan a=rafiss This addresses a comment from the review of #85656. Release note: None 85914: systemschema_test: fix timestamp stripping regex r=postamar a=postamar The test in this package was flaky because hlc.Timestamp values inside descriptors (modification time, for instance) with a logical component would be improperly redacted. This commit fixes this. Fixes #85799. Release note: None Co-authored-by: Aditya Maru <[email protected]> Co-authored-by: Xiang Gu <[email protected]> Co-authored-by: Marylia Gutierrez <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]> Co-authored-by: Pavel Kalinnikov <[email protected]> Co-authored-by: Rafi Shamim <[email protected]> Co-authored-by: Marius Posta <[email protected]>
There 3 commits:
(1) populate
pg_proc
with UDF(2) create
crdb_internal.create_function_statements
virtual table(3) implement
SHOW CREATE FUNCTION
(4) add
::regproc
support for UDFs