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

logictest: frontport test from #96124 #96125

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/schema_change_in_txn
Original file line number Diff line number Diff line change
Expand Up @@ -1950,3 +1950,50 @@ DROP SCHEMA sc;
# Prior to fixing this bug, this commit would hang indefinitely.
statement ok
COMMIT;

# This is a regression test to handle the case where a newly created table or
# a previously unleased table are referenced in a transaction involving
# transactional constraint validation.
subtest validate_constraint_referencing_modified_table

statement ok
CREATE TABLE t1 (id STRING PRIMARY KEY, other_id STRING NOT NULL);
CREATE TABLE t2 (id STRING PRIMARY KEY);
ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (other_id) REFERENCES t2(id) NOT VALID;

statement ok
BEGIN;
SET TRANSACTION PRIORITY HIGH;
ALTER TABLE t2 RENAME TO t3;
ALTER TABLE t1 VALIDATE CONSTRAINT fk;
COMMIT;

statement ok
DROP TABLE t1, t3 CASCADE

statement ok
CREATE TABLE t1 (id STRING PRIMARY KEY, other_id STRING NOT NULL);
CREATE TABLE t2 (id STRING PRIMARY KEY);
ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (other_id) REFERENCES t2(id) NOT VALID;

statement ok
BEGIN;
SET TRANSACTION PRIORITY HIGH;
ALTER TABLE t1 RENAME TO t3;
ALTER TABLE t3 VALIDATE CONSTRAINT fk;
COMMIT;

statement ok
DROP TABLE t2, t3 CASCADE

statement ok
BEGIN;
SET TRANSACTION PRIORITY HIGH;
CREATE TABLE t1 (id STRING PRIMARY KEY, other_id STRING NOT NULL);
CREATE TABLE t2 (id STRING PRIMARY KEY);
ALTER TABLE t1 ADD CONSTRAINT fk FOREIGN KEY (other_id) REFERENCES t2(id);
ALTER TABLE t1 VALIDATE CONSTRAINT fk;
COMMIT;

statement ok
DROP TABLE t1, t2 CASCADE