cockroachdb / cockroachdb/cockroach

sql: default string collations of PG vs CockroachDB is different

Open
#102,861 3 comments 0 reactions 0 assignees View on GitHub
A-migrations A-tools-aws-dms C-bug T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

in pg, ordering seems to be case insensitive by default:
```
psql (14.6 (Homebrew), server 13.8)
Type "help" for help.

rdsdb=> select 'PH3710230411ax24302d-8a29-42' > 'PH3710230411TFR2304102009571';
?column?
----------
f
(1 row)
```

but not in cockroach:
```
demo@127.0.0.1:26257/defaultdb> select 'PH3710230411ax24302d-8a29-42' > 'PH3710230411TFR2304102009571';
?column?
------------
t
(1 row)

Time: 1ms total (execution 0ms / network 0ms)
```

but if you make it `collate C` in PG, it's "cockroach like":
```
replicationunload=> select 'PH3710230411ax24302d-8a29-42'::varchar(32) collate "C" > 'PH3710230411TFR2304102009571'::varchar(32) collate "C";
?column?
----------
t
(1 row)
```

**NOTE: on OSX, PG's default is C though, just to fool you - could only repro this in a linux env**

This breaks verification tooling between PG <-> CockroachDB if we compare/iterate PKs in ascending order, such as AWS DMS's. The workaround is to make sure the collations match between the two sources.

Slack thread: https://cockroachlabs.slack.com/archives/CV581CE78/p1681424078522449

Jira issue: CRDB-27696

Epic CRDB-60815

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.