forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
138709: sql,plpgsql: add support for DO statements r=mgartner a=DrewKimball #### sql: avoid collisions in dollar sign formatted strings This commit adds a `FormatStringDollarQuotes` method to `FmtCtx` that displays a string constant with dollar-sign quotes, like: `$$ foo $$`. In order to ensure that the result is parsable, the new method checks the input string for collisions; first for `$$`, then for `$funcbody$`, then for `$funcbodyx$`, `$funcbodyxx$` and so on. This is similar to Postgres' behavior. The new method is now used for formatting function body strings in `CREATE FUNCTION` and `CREATE PROCEDURE` statements. Informs cockroachdb#115268 Release note: None #### sql: support full tree.Visitor in PL/pgSQL SQLStmtVisitor This commit exports the `tree.WalkStmt` function and adds support for using the full `tree.Visitor` interface to `SQLStmtVisitor`. Note that it is still possible to use `tree.SimpleVisitFn` as before. Epic: None Release note: None #### plpgsqltree: move visitor implementations This is a mechanical commit that moves the `SQLStmtVisitor` and `TypeRefVisitor` to the `plpgsqltree` package. This will allow the PL/pgSQL statements in that package to make use of the visitors. Epic: None Release note: None #### plpgsql/parser: parse PL/pgSQL DO statements This commit adds support for DO statements to the PL/pgSQL parser. The helper function `makeDoStmt` analyzes the DO statement options (language and code string) and then calls into the PL/pgSQL parser for the code string. A following commit will inject this helper into the SQL parser as well. Informs cockroachdb#115268 Release note: None #### sql/parser: parse SQL DO statements This commit adds support for DO statements to the SQL parser. This allows PL/pgSQL logic to be executed inline as an anonymous function. SQL DO blocks can be used either directly as a top-level SQL statement, or as body statements within a SQL routine. Informs cockroachdb#115268 Release note: None #### sql,plpgsql: enable DO statements in PL/pgSQL routines This commit adds support for DO statements embedded within PL/pgSQL code. DO statements are valid within both other DO statements and PL/pgSQL routines. They are handled similarly to a CALL statement with no arguments, where the body is built as a RelExpr that is executed only for its side effects. Informs cockroachdb#115268 Release note (sql change): Added support for DO statements embedded within PL/pgSQL routines and other DO statements. DO statements execute a block of code inline as an anonymous function. Currently, only a PL/pgSQL body is allowed. #### sql: add support for SQL DO statements This commit adds support for SQL DO statements, which allow inline execution of a PL/pgSQL code block. DO statements are only valid as top-level statements, meaning (for example) that they can't be used in a CTE. A following commit will enable DO statements within SQL routines. Informs cockroachdb#115268 Release note (sql change): Added support for DO statements in SQL, which allow a PL/pgSQL code block to be executed inline. #### sql: enable DO statements inside SQL routines This commit allows DO statements to be used as body statements in a SQL routine. Release note (sql change): DO statements can now be used as body statements in a SQL routine to execute PL/pgSQL code inline. Co-authored-by: Drew Kimball <[email protected]>
- Loading branch information
Showing
67 changed files
with
2,625 additions
and
437 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
do_stmt ::= | ||
'DO' do_stmt_opt_list |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ explainable_stmt ::= | |
| comment_stmt | ||
| execute_stmt | ||
| call_stmt | ||
| do_stmt |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
pkg/ccl/logictestccl/tests/local-read-committed/generated_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
pkg/ccl/logictestccl/tests/local-repeatable-read/generated_test.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.