DOCS-6275 Document dynamic SQL in stored functions (MDEV-39518) - #1064
Merged
Merged
Conversation
MDEV-39518 lets a stored function contain PREPARE, EXECUTE, DEALLOCATE PREPARE and EXECUTE IMMEDIATE, but only when the function is called as the whole right-hand side of an assignment to a stored routine variable. The rejection moved from the parser to call time, so CREATE FUNCTION now succeeds where it used to fail. - prepare-statement.md: new "Dynamic SQL in Stored Functions" section covering the permitted contexts, the rejected ones, and the prelocking, binary-logging and session-scope consequences. Qualify the blanket "not in a stored function or trigger" sentence and the PREPARE LOCAL equivalent. - execute-immediate.md: the existing example showed the error at CREATE FUNCTION time, which is wrong from 13.2.1. Split it into the before and after forms. - stored-function-limitations.md: qualify the prepared-statement bullet and add EXECUTE IMMEDIATE to it. Verified against MariaDB server @ 6f18dc2d117a (commit bfabe0e53042), using the mysql-test/main/ps_in_func* result files as the oracle. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
DOCS-6275 · MDEV-39518
MDEV-39518 allows
PREPARE,EXECUTE,DEALLOCATE PREPAREandEXECUTE IMMEDIATEinside a stored function, but only when the function call is the entire right-hand side of an assignment to a stored routine variable. The restriction moved from the parser to call time, soCREATE FUNCTIONnow succeeds where it used to fail.Changes
prepare-statement.md— new### Dynamic SQL in Stored Functionssection: the three permitted assignment forms, the rejected contexts, and the consequences (no prelocking, per-statement binary logging, session-scoped statement handles, no MDL on the routine). The blanket "not in a stored function or trigger" sentence and thePREPARE LOCALequivalent are version-qualified.execute-immediate.md— the existing example showed the error being raised atCREATE FUNCTIONtime. That is wrong from 13.2.1, so it is split into the before and after forms.stored-function-limitations.md— the prepared-statement bullet is qualified, andEXECUTE IMMEDIATEadded to the list of statements it names.Verification
Every claim is checked against
MariaDB/server@6f18dc2d117a(the feature is commitbfabe0e53042, onmainonly). The examples and the lists of rejected contexts are taken from themysql-test/main/ps_in_func*.resultfiles rather than from prose, so they are the server's own recorded output.One thing worth a reviewer's eye
The ticket says Release Series 13.1 and sits under the 13.1 epic, but MDEV-39518 is Closed/Fixed with fixVersion 13.2.1, and the commit is on
main(13.2.0 alpha) with no 13.1 branch carrying it. The pages are annotated 13.2.1. One test file still carries a stale# End of 13.1 testsmarker, which is probably where the ticket's 13.1 came from. If the series is actually 13.1, three annotations need flipping.🤖 Generated with Claude Code