cockroachdb / cockroachdb/cockroach
plpgsql: local cursor variable name should become "outer" cursor name
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
Noticed when looking at one of our existing tests. Consider the following setup:
```sql
DROP FUNCTION IF EXISTS f();
CREATE FUNCTION f() RETURNS INT AS $$
DECLARE
curs CURSOR FOR SELECT 100;
BEGIN
OPEN curs;
RETURN 0;
END
$$ LANGUAGE PLpgSQL;
BEGIN;
SELECT f();
SELECT name FROM pg_cursors;
COMMIT;
```
In postgres it returns the following:
```
name
------
curs
```
which IIUC indicates that the local variable name for the cursor becomes the cursor names outside of the function declaration.
However, in CRDB we get the following:
```
name
----------------------
```
The name of the cursor wasn't explicitly provided, so we used internally-generated one.
Jira issue: CRDB-33640
Contributor guide
Assessment
This issue has not been assessed yet.