Open DrewKimball opened 10 months ago
Hi @michae2, please add branch-* labels to identify which branch(es) this release-blocker affects.
:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.
It looks like this is because we don't allow tuple element access without extra parentheses in a SQL expr:
root@localhost:26257/defaultdb> SELECT v.b FROM (SELECT (y, x)::ab v FROM xy);
ERROR: no data source matches prefix: v in this context
SQLSTATE: 42P01
root@localhost:26257/defaultdb> SELECT (v).b FROM (SELECT (y, x)::ab v FROM xy);
b
-----
1
(1 row)
Time: 3ms total (execution 2ms / network 0ms)
root@localhost:26257/defaultdb> create procedure foo() language plpgsql as $$ declare v xy := ROW(1, 2); y INT; BEGIN RAISE NOTICE '%', (v).x; END $$;
CREATE PROCEDURE
Time: 61ms total (execution 26ms / network 35ms)
root@localhost:26257/defaultdb> CALL foo();
NOTICE: 1
CALL
Time: 19ms total (execution 18ms / network 0ms)
IIRC, postgres has some special logic to resolve PLpgSQL variable references during parsing, which is probably why this syntax is allowed in PLpgSQL but not SQL expressions.
Actually, this isn't a PL/pgSQL-specific problem. We just don't yet support the non-parenthesized column access syntax in SQL, yet.
We allow defining PLpgSQL variables with any concrete type, including composite types. This works in some cases:
However, when the procedure attempts to access elements of the tuple, creating the procedure results in an object-resolution error:
Jira issue: CRDB-33628