cockroachdb / cockroachdb/cockroach

stmtbundle: include transitive dependencies

Open
#138,022 0 comments 0 reactions 0 assignees View on GitHub
A-sql-debug-bundle C-cleanup T-sql-queries
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

Currently, in the stmt bundles we only include the data sources (tables, sequences, views) that are directly referenced by the metadata of the query as well as FK referencing and FK referenced tables. This can be insufficient when we have transitive dependencies:
```sql
CREATE DATABASE db_view;
USE db_view;
CREATE SCHEMA sc_seq;
CREATE SEQUENCE sc_seq.seq;
CREATE TABLE t (k INT PRIMARY KEY);
CREATE SCHEMA sc_view;
CREATE VIEW sc_view.v AS SELECT *, nextval('sc_seq.seq') FROM t;
RESET database;

CREATE DATABASE db_udf;
USE db_udf;
CREATE SCHEMA sc_udf;
CREATE FUNCTION sc_udf.f() RETURNS INT LANGUAGE SQL AS 'SELECT 1';

EXPLAIN ANALYZE (DEBUG) SELECT *, sc_udf.f() FROM db_view.sc_view.v;
```
In this example we currently forget to include CREATE statements for `sc_seq`, `sc_seq.seq`, and `db_udf` objects.

Jira issue: CRDB-45850

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.