Skip to content

Commit 0a58aa1

Browse files
craig[bot]jeffswenson
andcommitted
Merge #156799
156799: logical: fix creation time check for REFCURSOR r=jeffswenson a=jeffswenson This fixes a bug that was uncovered by TestRandomTables. Compound types that include REFCURSORs could sneak by the validation. Epic: CRDB-48647 Release note: none Co-authored-by: Jeff Swenson <jeffswenson@betterthannull.com>
2 parents 1fdf936 + c98dfe8 commit 0a58aa1

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

pkg/crosscluster/logical/logical_replication_job_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2845,7 +2845,7 @@ func TestLogicalReplicationCreationChecks(t *testing.T) {
28452845
// Check that REFCURSOR columns are not allowed.
28462846
dbA.Exec(t, "CREATE TABLE tab_with_refcursor (pk INT PRIMARY KEY, curs REFCURSOR)")
28472847
dbB.Exec(t, "CREATE TABLE b.tab_with_refcursor (pk INT PRIMARY KEY, curs REFCURSOR)")
2848-
expectErr(t, "tab_with_refcursor", "cannot create logical replication stream: column curs is a RefCursor")
2848+
expectErr(t, "tab_with_refcursor", "cannot create logical replication stream: RefCursor is not supported by LDR")
28492849

28502850
// Add different default values to to the source and dest, verify the stream
28512851
// can be created, and that the default value is sent over the wire.

pkg/sql/catalog/tabledesc/logical_replication_helpers.go

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,30 @@ func CheckLogicalReplicationCompatibility(
6666
}
6767

6868
func checkForbiddenTypes(dst *descpb.TableDescriptor) error {
69+
var isForbiddenType func(typ *types.T) error
70+
isForbiddenType = func(typ *types.T) error {
71+
switch typ.Family() {
72+
case types.RefCursorFamily:
73+
// RefCursor is not supported by LDR because it has no definition of
74+
// equality. It's a weird type that should never exist in a durable table
75+
// since a cursor is a session scoped entity.
76+
return errors.Newf("RefCursor is not supported by LDR")
77+
case types.ArrayFamily:
78+
return isForbiddenType(typ.ArrayContents())
79+
case types.TupleFamily:
80+
for _, tupleTyp := range typ.TupleContents() {
81+
if err := isForbiddenType(tupleTyp); err != nil {
82+
return err
83+
}
84+
}
85+
return nil
86+
default:
87+
return nil
88+
}
89+
}
6990
for _, col := range dst.Columns {
70-
// RefCursor is not supported by LDR because it has no definition of
71-
// equality. It's a weird type that should never exist in a durable table
72-
// since a cursor is a session scoped entity.
73-
if col.Type.Family() == types.RefCursorFamily {
74-
return errors.Newf("column %s is a RefCursor", col.Name)
91+
if err := isForbiddenType(col.Type); err != nil {
92+
return err
7593
}
7694
}
7795
return nil

0 commit comments

Comments
 (0)