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 fails when an index is referenced by a view #85230

Open
ajwerner opened this issue Jul 28, 2022 · 0 comments
Open

sql: truncate fails when an index is referenced by a view #85230

ajwerner opened this issue Jul 28, 2022 · 0 comments
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Jul 28, 2022

Describe the problem

When an index is referenced by a view, we fail to TRUNCATE the table containing the index with an unclassified error.

To Reproduce

CREATE TABLE t (
    k INT, v INT, INDEX idx (v)
);
CREATE VIEW v AS SELECT v FROM t@idx;
TRUNCATE t;

Results in:

demo@127.0.0.1:26257/movr> truncate t;
ERROR: internal error: relation "t" (118): 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:561: ValidateSelf()
...

Expected behavior

TRUNCATE works. We need to rewrite the index references in the dependencies.

Jira issue: CRDB-18122

@ajwerner ajwerner added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Jul 28, 2022
@ajwerner ajwerner added this to Triage in SQL Foundations via automation Jul 28, 2022
@blathers-crl blathers-crl bot added the T-sql-schema-deprecated Use T-sql-foundations instead label Jul 28, 2022
@ajwerner ajwerner moved this from Triage to Backlog in SQL Foundations Aug 2, 2022
@postamar postamar moved this from Backlog to Declarative Schema Changer Will Fix These in SQL Foundations Nov 10, 2022
@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
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
SQL Foundations
  
Declarative Schema Changer Will Fix T...
Development

No branches or pull requests

1 participant