@@ -32,6 +32,7 @@ import (
32
32
"github.com/cockroachdb/cockroach/pkg/sql/types"
33
33
"github.com/cockroachdb/cockroach/pkg/util"
34
34
"github.com/cockroachdb/cockroach/pkg/util/bitarray"
35
+ "github.com/cockroachdb/cockroach/pkg/util/collatedstring"
35
36
"github.com/cockroachdb/cockroach/pkg/util/duration"
36
37
"github.com/cockroachdb/cockroach/pkg/util/encoding"
37
38
"github.com/cockroachdb/cockroach/pkg/util/ipaddr"
@@ -1322,7 +1323,8 @@ type DCollatedString struct {
1322
1323
Contents string
1323
1324
Locale string
1324
1325
// Key is the collation key.
1325
- Key []byte
1326
+ Key []byte
1327
+ Deterministic bool
1326
1328
}
1327
1329
1328
1330
// CollationEnvironment stores the state needed by NewDCollatedString to
@@ -1336,7 +1338,8 @@ type collationEnvironmentCacheEntry struct {
1336
1338
// locale is interned.
1337
1339
locale string
1338
1340
// collator is an expensive factory.
1339
- collator * collate.Collator
1341
+ collator * collate.Collator
1342
+ deterministic bool
1340
1343
}
1341
1344
1342
1345
func (env * CollationEnvironment ) getCacheEntry (
@@ -1353,7 +1356,7 @@ func (env *CollationEnvironment) getCacheEntry(
1353
1356
return collationEnvironmentCacheEntry {}, err
1354
1357
}
1355
1358
1356
- entry = collationEnvironmentCacheEntry {locale , collate .New (tag )}
1359
+ entry = collationEnvironmentCacheEntry {locale , collate .New (tag ), collatedstring . IsDeterministicCollation ( tag ) }
1357
1360
env .cache [locale ] = entry
1358
1361
}
1359
1362
return entry , nil
@@ -1372,7 +1375,7 @@ func NewDCollatedString(
1372
1375
env .buffer = & collate.Buffer {}
1373
1376
}
1374
1377
key := entry .collator .KeyFromString (env .buffer , contents )
1375
- d := DCollatedString {contents , entry .locale , make ([]byte , len (key ))}
1378
+ d := DCollatedString {contents , entry .locale , make ([]byte , len (key )), entry . deterministic }
1376
1379
copy (d .Key , key )
1377
1380
env .buffer .Reset ()
1378
1381
return & d , nil
@@ -1445,7 +1448,7 @@ func (d *DCollatedString) IsMin(ctx context.Context, cmpCtx CompareContext) bool
1445
1448
1446
1449
// Min implements the Datum interface.
1447
1450
func (d * DCollatedString ) Min (ctx context.Context , cmpCtx CompareContext ) (Datum , bool ) {
1448
- return & DCollatedString {"" , d .Locale , nil }, true
1451
+ return & DCollatedString {"" , d .Locale , nil , false }, true
1449
1452
}
1450
1453
1451
1454
// Max implements the Datum interface.
@@ -6204,7 +6207,7 @@ var baseDatumTypeSizes = map[types.Family]struct {
6204
6207
types .FloatFamily : {unsafe .Sizeof (DFloat (0.0 )), fixedSize },
6205
6208
types .DecimalFamily : {unsafe .Sizeof (DDecimal {}), variableSize },
6206
6209
types .StringFamily : {unsafe .Sizeof (DString ("" )), variableSize },
6207
- types .CollatedStringFamily : {unsafe .Sizeof (DCollatedString {"" , "" , nil }), variableSize },
6210
+ types .CollatedStringFamily : {unsafe .Sizeof (DCollatedString {"" , "" , nil , false }), variableSize },
6208
6211
types .BytesFamily : {unsafe .Sizeof (DBytes ("" )), variableSize },
6209
6212
types .EncodedKeyFamily : {unsafe .Sizeof (DBytes ("" )), variableSize },
6210
6213
types .DateFamily : {unsafe .Sizeof (DDate {}), fixedSize },
0 commit comments