cockroachdb / cockroachdb/cockroach

plpgsql: variables in the INTO clause are case sensitive

Open
#126,727 2 comments 0 reactions 0 assignees View on GitHub
A-sql-plpgsql A-sql-routine branch-master branch-release-23.2 branch-release-24.1 C-bug T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Variables names in PL/pgSQL are meant to be case-insensitive unless surrounded by double quotes, just like identifiers in SQL. However, this is currently not the case when the variable is used as the target of an INTO clause for a SQL exec statement or FETCH statement:
```
root@localhost:26257/defaultdb> CREATE PROCEDURE p() LANGUAGE PLpgSQL AS $$ DECLARE foo INT; BEGIN SELECT 1 INTO FOO; END $$;
ERROR: "FOO" is not a known variable
SQLSTATE: 42601
```
We should ensure that PL/pgSQL variables have correct casing behavior in all contexts.

Jira issue: CRDB-40753

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the supplied PL/pgSQL procedure with SELECT INTO, then investigate the PL/pgSQL handling of variable targets in SQL exec and FETCH statements. Done means unquoted variable names work case-insensitively in all these contexts, while double-quoted names retain their intended case behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.