-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: materialized view created with incorrect fixed timestamp #79015
Copy link
Copy link
Closed
Labels
A-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Description
Describe the problem
# Test CREATE MATERIALIZED VIEW referring to a sequence.
statement ok
CREATE SEQUENCE seq;
CREATE MATERIALIZED VIEW view_from_seq AS (SELECT nextval('seq'))
/home/roach/.cache/bazel/_bazel_roach/c5a4e7d36696d9cd970af2045211a7df/sandbox/processwrapper-sandbox/4047/execroot/cockroach/bazel-out/k8-dbg/bin/pkg/sql/logictest/logictest_test_/logictest_test.runfiles/cockroach/pkg/sql/logictest/testdata/logic_test/materialized_view:214:
expected success, but found
(42P01) nextval(): relation "[115]" does not exist
errors.go:161: in NewUndefinedRelationError()
Seems like the root cause is if the transaction gets pushed, then the CreateAsOfTime will be before the other descriptors created in the same transaction. See
cockroach/pkg/sql/schema_changer.go
Line 420 in a0b4a33
| return sc.backfillQueryIntoTable(ctx, table, table.GetViewQuery(), table.GetCreateAsOfTime(), "materializedViewBackfill") |
cockroach/pkg/sql/create_view.go
Line 239 in 23391d0
| desc.CreateAsOfTime = params.p.Txn().ReadTimestamp() |
The solution here is to remove the code which sets the creation time as we'll set it automatically when we read the descriptor for the first time.
Jira issue: CRDB-14500
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-schema-descriptorsRelating to SQL table/db descriptor handling.Relating to SQL table/db descriptor handling.C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)SQL Foundations Team (formerly SQL Schema + SQL Sessions)