cockroachdb / cockroachdb/cockroach

plpgsql: report ambiguous column error for conflicting variable names

Open
#115,680 0 comments 0 reactions 0 assignees View on GitHub
A-sql-plpgsql C-bug docs-done docs-known-limitation P-2 T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

By default, when a PLpgSQL variable conflicts with a column name, the result is an ambiguous column error. It is also possible to change the `plpgsql.variable_conflict` setting in order to prefer either columns or variables in such cases. See the postgres docs here: https://www.postgresql.org/docs/current/plpgsql-implementation.html#PLPGSQL-VAR-SUBST

Currently, CRDB resolves ambiguous cases as column references rather than variable references.

Jira issue: CRDB-34151

Contributor guide

Open the contributing guide

Research direction

Start with the PostgreSQL PL/pgSQL variable-conflict documentation linked in the issue, then locate CockroachDB’s existing PL/pgSQL name-resolution handling and regression tests. Confirm the current column-preference behavior, add coverage for an ambiguous variable and column reference, and ensure it reports the ambiguity as PostgreSQL does.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgres, 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.