cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
30.16k stars 3.82k forks source link

sql: include hidden columns in triggers #133331

Open DrewKimball opened 4 weeks ago

DrewKimball commented 4 weeks ago

Now that it is possible to assign to an element of a composite-typed PL/pgSQL variable (#132628), we should make hidden columns visible to triggers, in addition to visible columns.

Jira issue: CRDB-43543

DrewKimball commented 4 weeks ago

Note that until this is fixed, triggers will encounter an assertion error upon execution on a table with the implicit rowid >column. For example, the following optimizer test:


exec-ddl
CREATE TABLE t (a INT);
----

exec-ddl CREATE FUNCTION f() RETURNS TRIGGER LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEW; END $$;

exec-ddl CREATE TRIGGER tr BEFORE INSERT ON t FOR EACH ROW EXECUTE FUNCTION f();

build INSERT INTO t VALUES (1);


>encounters: "unexpected number of visible columns"

It turns out the assertion failure was an artifact of some missing handling for hidden columns in opt tests. However, we can still keep this issue open to track adding support for hidden columns to triggers.