@@ -15,6 +15,30 @@ import (
1515 "github.com/cockroachdb/cockroach/pkg/sql/types"
1616)
1717
18+ func isSupportedType (t * types.T ) bool {
19+ switch t .Family () {
20+ case types .RefCursorFamily :
21+ // We don't support RefCursor columns in LDR tables because they do not
22+ // support equality.
23+ return false
24+ case types .ArrayFamily :
25+ // We don't allow Arrays of bits because rand.LoadTable doesn't correctly identify their bit width.
26+ if t .ArrayContents ().Family () == types .BitFamily {
27+ return false
28+ }
29+ return isSupportedType (t .ArrayContents ())
30+ case types .TupleFamily :
31+ for _ , elemType := range t .TupleContents () {
32+ if ! isSupportedType (elemType ) {
33+ return false
34+ }
35+ }
36+ return true
37+ default :
38+ return true
39+ }
40+ }
41+
1842func GenerateLDRTable (
1943 ctx context.Context , rng * rand.Rand , tableName string , supportKVWriter bool ,
2044) * tree.CreateTable {
@@ -31,21 +55,7 @@ func GenerateLDRTable(
3155 randgen .WithPrimaryIndexRequired (),
3256 randgen .WithSkipColumnFamilyMutations (),
3357 randgen .WithColumnFilter (func (columnDef * tree.ColumnTableDef ) bool {
34- // We don't allow Arrays of bits because rand.LoadTable doesn't correctly identify their bit width.
35- if columnDef .Type .(* types.T ).Family () == types .ArrayFamily && columnDef .Type .(* types.T ).ArrayContents ().Family () == types .BitFamily {
36- return false
37- }
38- // We don't support RefCursor columns in LDR tables because they do not
39- // support equality.
40- if columnDef .Type .(* types.T ).Family () == types .RefCursorFamily {
41- return false
42- }
43- // We don't allow the special '"char"' column because pgwire truncates the value to 1 byte.
44- // TODO(jeffswenson): remove this once #149427 is fixed.
45- if columnDef .Type .(* types.T ).Family () == types .StringFamily && columnDef .Type .(* types.T ).Width () == 1 {
46- return false
47- }
48- return true
58+ return isSupportedType (columnDef .Type .(* types.T ))
4959 }),
5060 randgen .WithPrimaryIndexFilter (func (indexDef * tree.IndexTableDef , columnDefs []* tree.ColumnTableDef ) bool {
5161 for _ , col := range indexDef .Columns {
0 commit comments