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 nested blocks #117710

Merged
merged 4 commits into from
Feb 1, 2024
Merged

Commits on Jan 31, 2024

  1. plpgsql: change order of params and variables

    Previously, the parameters of a continuation sub-routine would be chosen
    by first appending the variables of the (single) block, then the parameters
    of the PL/pgSQL routine. In preparation for supporting nested blocks, this
    commit changes the order to first add the routine's parameters, and then the
    variables from the block. This prepares to enforce an invariant that the
    parameters/arguments of a parent sub-routine are always a prefix of those
    of a child sub-routine. This will simplify exception handling later on.
    
    Informs cockroachdb#114775
    
    Release note: None
    DrewKimball committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    1ac9b61 View commit details
    Browse the repository at this point in the history
  2. plpgsql: allow early exit for visitor

    This commit makes two changes to the plpgsql Visitor interface and
    implementation - first, the `changed` return value has been replaced
    with pointer comparisons. Second, a new return value, `recurse`,
    indicates whether a node's children should be visited. This will
    allow for Visitor implementations that have to return early.
    
    Epic: None
    
    Release note: None
    DrewKimball committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    9445f0a View commit details
    Browse the repository at this point in the history
  3. plpgsql: refactor logic for building PL/pgSQL blocks

    This commit pulls the logic for handling a PL/pgSQL block into a single
    method. Information specific to a given block (including a pointer to the
    parent block) is stored in a new struct, `blockScope`, which is allocated
    when the block is built. Note that nested blocks are still not allowed in
    this commit.
    
    Informs cockroachdb#114775
    
    Release note: None
    DrewKimball committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    dd9047d View commit details
    Browse the repository at this point in the history
  4. plpgsql: add support for nested blocks

    This commit makes the final change to support nested blocks with some
    limitations, and adds corresponding tests. Currently, variable shadowing
    is not allowed, and neither are exception handlers for routines with
    nested blocks.
    
    Fixes cockroachdb#114775
    
    Release note (sql change): PL/pgSQL now supports nested blocks, with
    the following limitations for now: variable shadowing is disallowed,
    and exception handlers cannot be used in a routine with nested blocks.
    DrewKimball committed Jan 31, 2024
    Configuration menu
    Copy the full SHA
    082a198 View commit details
    Browse the repository at this point in the history