-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: pg_function_is_visible is not correct for UDFs #89546
Copy link
Copy link
Closed
Labels
A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLA-sql-routineUDFs and Stored ProceduresUDFs and Stored ProceduresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Description
Describe the problem
This builtin was added in 2019. The assumptions from back then no longer hold. See:
cockroach/pkg/sql/sem/builtins/pg_builtins.go
Lines 1178 to 1195 in 1ca61ae
| // pg_function_is_visible returns true if the input oid corresponds to a | |
| // builtin function that is part of the databases on the search path. | |
| // CockroachDB doesn't have a concept of namespaced functions, so this is | |
| // always true if the builtin exists at all, and NULL otherwise. | |
| // https://www.postgresql.org/docs/9.6/static/functions-info.html | |
| "pg_function_is_visible": makeBuiltin(defProps(), | |
| tree.Overload{ | |
| Types: tree.ArgTypes{{"oid", types.Oid}}, | |
| ReturnType: tree.FixedReturnType(types.Bool), | |
| Fn: func(ctx *eval.Context, args tree.Datums) (tree.Datum, error) { | |
| oid := tree.MustBeDOid(args[0]) | |
| t, err := ctx.Planner.QueryRowEx( | |
| ctx.Ctx(), "pg_function_is_visible", | |
| sessiondata.NoSessionDataOverride, | |
| "SELECT * from pg_proc WHERE oid=$1 LIMIT 1", oid.Oid) | |
| if err != nil { | |
| return nil, err | |
| } |
Expected behavior
Match the Postgres implementation, and take into account the schemas on the search path. Maybe it also takes into account privileges?
Also, the current implementation is needlessly slow. I hope we can improve the speed of it too.
Environment:
- CockroachDB v22.2.0-beta
Jira issue: CRDB-20297
Epic CRDB-19147
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-sql-pgcompatSemantic compatibility with PostgreSQLSemantic compatibility with PostgreSQLA-sql-routineUDFs and Stored ProceduresUDFs and Stored ProceduresC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Type
Projects
Status
Done