@@ -2948,3 +2948,53 @@ func TestLogicalReplicationExternalConnWithoutDBName(t *testing.T) {
29482948 reverseJobID := GetReverseJobID (ctx , t , dbA , jobID )
29492949 WaitUntilReplicatedTime (t , s .Clock ().Now (), dbA , reverseJobID )
29502950}
2951+
2952+ func TestLogicalReplicationCapitalTableName (t * testing.T ) {
2953+ defer leaktest .AfterTest (t )()
2954+ defer log .Scope (t ).Close (t )
2955+
2956+ ctx := context .Background ()
2957+
2958+ server , s , dbA , dbB := setupLogicalTestServer (t , ctx , testClusterBaseClusterArgs , 1 )
2959+ defer server .Stopper ().Stop (ctx )
2960+
2961+ dbA .Exec (t , `CREATE TABLE a.public."Foo" (x INT PRIMARY KEY)` )
2962+ dbA .Exec (t , `INSERT INTO a.public."Foo" SELECT * FROM generate_series(1, 10)` )
2963+ dbA .Exec (t , "CREATE USER userA WITH PASSWORD '123'" )
2964+ dbA .Exec (t , `GRANT REPLICATIONSOURCE, REPLICATIONDEST ON TABLE a.public."Foo" TO userA` )
2965+ dbAURL := replicationtestutils .GetExternalConnectionURI (
2966+ t , s , s , serverutils .ClientCerts (false ), serverutils .UserPassword ("userA" , "123" ), serverutils .DBName ("a" ),
2967+ )
2968+
2969+ dbB .Exec (t , "CREATE USER userB WITH PASSWORD '123'" )
2970+ dbB .Exec (t , "GRANT CREATE ON DATABASE b TO userB" )
2971+ dbBURL := replicationtestutils .GetExternalConnectionURI (
2972+ t , s , s , serverutils .ClientCerts (false ), serverutils .UserPassword ("userB" , "123" ), serverutils .DBName ("b" ),
2973+ )
2974+
2975+ dbBAsUser := sqlutils .MakeSQLRunner (s .SQLConn (
2976+ t ,
2977+ serverutils .DBName ("b" ),
2978+ serverutils .ClientCerts (false ),
2979+ serverutils .UserPassword ("userB" , "123" ),
2980+ ))
2981+
2982+ // Unidirectional into B.
2983+ dbBAsUser .Exec (t , `CREATE TABLE b.public."uFoo" (x INT PRIMARY KEY)` )
2984+ var uJobID jobspb.JobID
2985+ dbBAsUser .QueryRow (t , `CREATE LOGICAL REPLICATION STREAM FROM TABLE a.public."Foo" ON $1 INTO TABLE b.public."uFoo"` , dbAURL .String ()).Scan (& uJobID )
2986+ WaitUntilReplicatedTime (t , s .Clock ().Now (), dbB , uJobID )
2987+
2988+ // Bidirectional
2989+ var jobID jobspb.JobID
2990+ dbBAsUser .QueryRow (
2991+ t ,
2992+ `CREATE LOGICALLY REPLICATED TABLE b.public."Foo" FROM TABLE a.public."Foo" ON $1 WITH BIDIRECTIONAL ON $2` ,
2993+ dbAURL .String (),
2994+ dbBURL .String (),
2995+ ).Scan (& jobID )
2996+ WaitUntilReplicatedTime (t , s .Clock ().Now (), dbB , jobID )
2997+
2998+ reverseJobID := GetReverseJobID (ctx , t , dbA , jobID )
2999+ WaitUntilReplicatedTime (t , s .Clock ().Now (), dbA , reverseJobID )
3000+ }
0 commit comments