Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plpgsql: add support for FETCH and MOVE statements
This patch adds support for the PLpgSQL FETCH and MOVE statements, which seek and return rows from a cursor. This is handled by a builtin function, `crdb_internal.plpgsql_fetch`, which calls into the same logic that implements SQL FETCH and MOVE. Since it is possible to call `FETCH` with `INTO` variables of different types, the `crdb_internal.plpgsql_fetch` builtin takes an argument that supplies the expected column types as a tuple of typed NULL values like this: `(NULL::INT, NULL::BOOL)`. The actual types supplied by the cursor are coerced into the expected types. Note that the current implementation does not support using dynamic expressions in the FETCH/MOVE direction; only constant integer values. Dynamic direction counts like `FORWARD x` are not allowed in SQL syntax, but are allowed by PLpgSQL. Informs cockroachdb#109709 Release note (sql change): Added support for PLpgSQL FETCH and MOVE statements. Similar to SQL FETCH/MOVE statements, commands that would seek the cursor backward will fail. In addition, expressions other than constant integers are not yet supported for the `count` option.
- Loading branch information