Skip to content

Commit dd92f14

Browse files
committed
crosscluster/logical: test seq support
Fixes #155521 Release note (ops change): ensure the user can run CREATE LOGICAL REPLICATION STREAM where the source table has a column with a sequence expression.
1 parent fbe4b69 commit dd92f14

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pkg/crosscluster/logical/logical_replication_job_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2653,6 +2653,39 @@ func TestPartialIndexes(t *testing.T) {
26532653
dbB.ExpectErr(t, " this schema change is disallowed on table foo because it is referenced by one or more logical replication jobs", "CREATE INDEX idx3 ON b.foo (pi) WHERE pk = 0")
26542654
}
26552655

2656+
// TODO(msbutler): migrate TestLogicalReplicationCreationChecks to this test
2657+
// which has subtests and no weird cross case dependencies.
2658+
func TestSupportedSchemaChecks(t *testing.T) {
2659+
defer leaktest.AfterTest(t)()
2660+
skip.UnderDeadlock(t)
2661+
defer log.Scope(t).Close(t)
2662+
2663+
ctx := context.Background()
2664+
2665+
server, s, dbA, dbB := setupLogicalTestServer(t, ctx, testClusterBaseClusterArgs, 1)
2666+
defer server.Stopper().Stop(ctx)
2667+
2668+
dbAURL := replicationtestutils.GetExternalConnectionURI(t, s, s, serverutils.DBName("a"))
2669+
2670+
// source is allowed to have a seq expression but not dest.
2671+
t.Run("sequences", func(t *testing.T) {
2672+
2673+
dbA.Exec(t, "CREATE SEQUENCE my_seqA")
2674+
dbB.Exec(t, "CREATE SEQUENCE my_seqB")
2675+
dbA.Exec(t, "CREATE TABLE tab_with_seq (pk INT PRIMARY KEY, v INT DEFAULT nextval('my_seqA'))")
2676+
dbA.Exec(t, "INSERT INTO tab_with_seq (pk) VALUES (1), (2), (3)")
2677+
2678+
dbB.Exec(t, "CREATE TABLE tab_with_seq (pk INT PRIMARY KEY, v INT DEFAULT nextval('my_seqB'))")
2679+
dbB.Exec(t, "CREATE TABLE tab_no_seq (pk INT PRIMARY KEY, v INT)")
2680+
2681+
var jobBID jobspb.JobID
2682+
dbB.QueryRow(t, "CREATE LOGICAL REPLICATION STREAM FROM TABLE tab_with_seq ON $1 INTO TABLE tab_no_seq", dbAURL.String()).Scan(&jobBID)
2683+
WaitUntilReplicatedTime(t, s.Clock().Now(), dbB, jobBID)
2684+
2685+
dbB.ExpectErr(t, "references sequences with IDs", "CREATE LOGICAL REPLICATION STREAM FROM TABLE tab_with_seq ON $1 INTO TABLE tab_with_seq", dbAURL.String())
2686+
})
2687+
}
2688+
26562689
// TestLogicalReplicationCreationChecks verifies that we check that the table
26572690
// schemas are compatible when creating the replication stream.
26582691
func TestLogicalReplicationCreationChecks(t *testing.T) {

0 commit comments

Comments
 (0)