Skip to content
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

plpgsql: add support for COMMIT and ROLLBACK statements #119647

Merged
merged 3 commits into from
Mar 13, 2024

Commits on Mar 12, 2024

  1. plpgsql: add parser support for COMMIT and ROLLBACK

    This commit adds support in the PL/pgSQL parser for transaction control
    statements. It also performs some minor refactoring of the AST statements.
    
    Informs cockroachdb#115294
    
    Release note: None
    DrewKimball committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    966c78f View commit details
    Browse the repository at this point in the history
  2. sql: add support for transaction control during SQL execution

    This commit adds a method to commit or abort a transaction from within
    a SQL execution plan, through a `TxnControlExpr`. A `TxnControlExpr` wraps
    a "continuation" routine. Upon evaluation, it directs the connExecutor to
    commit/abort the transaction, and stores a plan built for the continuation.
    The connExecutor will finish the current transaction, and then use the
    stored plan to resume execution in the new transaction. This will be used
    in the following commit to implement the PL/pgSQL COMMIT and ROLLBACK
    statements.
    
    Informs cockroachdb#115294
    
    Release note: None
    DrewKimball committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    21f0faf View commit details
    Browse the repository at this point in the history
  3. plpgsql: add support for COMMIT and ROLLBACK

    This commit adds support for the PL/pgSQL COMMIT and ROLLBACK statements,
    which allow a stored procedure to finish the current transaction and
    resume execution from the new transaction. This behavior is implemented
    through the `TxnControl` expression from the previous commit, which
    passes the necessary information (commit or rollback, continuation) to
    the connExecutor before exiting. Note that these statements can only
    be used from a stored procedure.
    
    Fixes cockroachdb#115294
    
    Release note (sql change): Added support for the PL/pgSQL COMMIT and
    ROLLBACK statements.
    DrewKimball committed Mar 12, 2024
    Configuration menu
    Copy the full SHA
    f1758ec View commit details
    Browse the repository at this point in the history