Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: TRUNCATE after CREATE VIEW using FORCE_INDEX results in schema assertion #101123

Closed
knz opened this issue Apr 10, 2023 · 3 comments
Closed
Labels
A-schema-changes branch-master Failures on the master branch. branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. GA-blocker T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@knz
Copy link
Contributor

knz commented Apr 10, 2023

Describe the problem

(Discovered by @DerZc using random testing with sqllancer.)

The validate call during a TRUNCATE after a CREATE VIEW results in the following assertion error:

ERROR: internal error: relation "t1" (107): index ID 2 found in depended-on-by references, no such index in this relation
SQLSTATE: XX000
DETAIL: stack trace:
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/validate.go:686: ValidateSelf()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:80: func1()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:198: validateDescriptorsAtLevel()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:76: Validate()
github.com/cockroachdb/cockroach/pkg/sql/catalog/internal/validate/validate.go:41: Self()
github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc/structured.go:539: AllocateIDs()
github.com/cockroachdb/cockroach/pkg/sql/truncate.go:222: truncateTable()
github.com/cockroachdb/cockroach/pkg/sql/truncate.go:126: startExec()

To Reproduce

Run the following on a freshly created cluster:

CREATE DATABASE IF NOT EXISTS test;
USE test;
CREATE TABLE t0 (c0 INT PRIMARY KEY);
CREATE TABLE t1 (c0 INT UNIQUE  PRIMARY KEY);
CREATE INDEX ON t1(c0);
CREATE VIEW v0(c0) AS SELECT NULL FROM t0 CROSS JOIN t1 @{FORCE_INDEX=t1_c0_idx,DESC};
TRUNCATE t1 RESTRICT;

Expected behavior

No error

Jira issue: CRDB-26815

@knz knz added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-schema-changes GA-blocker T-sql-schema-deprecated Use T-sql-foundations instead labels Apr 10, 2023
@knz knz added this to Triage in SQL Foundations via automation Apr 10, 2023
@blathers-crl
Copy link

blathers-crl bot commented Apr 10, 2023

Hi @knz, please add branch-* labels to identify which branch(es) this release-blocker affects.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@knz knz added branch-master Failures on the master branch. branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 labels Apr 10, 2023
@DerZc
Copy link

DerZc commented Apr 10, 2023

@knz thanks for your report, but this is a duplicate bug which I have reported #100681

@knz
Copy link
Contributor Author

knz commented Apr 10, 2023

dup #85230

@knz knz closed this as completed Apr 10, 2023
SQL Foundations automation moved this from Triage to Done Apr 10, 2023
@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-schema-changes branch-master Failures on the master branch. branch-release-23.1 Used to mark GA and release blockers and technical advisories for 23.1 C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. GA-blocker T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
Development

No branches or pull requests

2 participants