Skip to content

Commit 5ab8258

Browse files
committed
logical: do not allow the REFCURSOR type
This removes LDR support for the REFCURSOR type. The crud writer does not support it because REFCURSOR does not support the equality SQL operator. This removal is unlikely to impact any users. The REFCURSOR is a weird type that should not show up in a durable table. If the user really needs this type for some reason, they could store they type as a STRING and convert it back to a REFCURSOR when reading from the table. Epic: CRDB-48647 Release note: none
1 parent 2340f9a commit 5ab8258

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

pkg/crosscluster/logical/logical_replication_job_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,6 +2833,11 @@ func TestLogicalReplicationCreationChecks(t *testing.T) {
28332833
jobutils.WaitForJobToCancel(t, dbA, jobAID)
28342834
replicationtestutils.WaitForAllProducerJobsToFail(t, dbB)
28352835

2836+
// Check that REFCURSOR columns are not allowed.
2837+
dbA.Exec(t, "CREATE TABLE tab_with_refcursor (pk INT PRIMARY KEY, curs REFCURSOR)")
2838+
dbB.Exec(t, "CREATE TABLE b.tab_with_refcursor (pk INT PRIMARY KEY, curs REFCURSOR)")
2839+
expectErr(t, "tab_with_refcursor", "cannot create logical replication stream: column curs is a RefCursor")
2840+
28362841
// Add different default values to to the source and dest, verify the stream
28372842
// can be created, and that the default value is sent over the wire.
28382843
dbA.Exec(t, "CREATE TABLE tab2 (pk INT PRIMARY KEY, payload STRING DEFAULT 'cat')")

pkg/sql/catalog/tabledesc/logical_replication_helpers.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,22 @@ func CheckLogicalReplicationCompatibility(
5858
return pgerror.Wrapf(err, pgcode.InvalidTableDefinition, cannotLDRMsg)
5959
}
6060

61+
if err := checkForbiddenTypes(dst); err != nil {
62+
return pgerror.Wrapf(err, pgcode.InvalidTableDefinition, cannotLDRMsg)
63+
}
64+
65+
return nil
66+
}
67+
68+
func checkForbiddenTypes(dst *descpb.TableDescriptor) error {
69+
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)
75+
}
76+
}
6177
return nil
6278
}
6379

0 commit comments

Comments
 (0)