sql: allow UDFs in EXECUTE arguments #108215
Labels
A-sql-routine
UDFs and Stored Procedures
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-queries
SQL Queries Team
We currently disallow UDFs from being used in EXECUTE arguments (see #99008, #108213). UDF calls cannot be simply evaluated like placeholder expressions are currently:
cockroach/pkg/sql/opt/norm/factory.go
Line 355 in f59f0f4
UDFs must be built by the optimizer and executed as routines. #107767 attempted to address this by replacing placeholders with expressions instead of constants. There were some major issues with this approach though:
PREPARE p AS SELECT $1::INT + $1::INT
, thenf
will be evaluated twice when runningEXECUTE p(f())
. This is fine for stable, immutable, and leakproof functions, but causes unexpected behavior for volatile functions. See the related issue sql: EXECUTE arguments should be evaluated only once #108027.Jira issue: CRDB-30365
The text was updated successfully, but these errors were encountered: