Skip to content

Commit

Permalink
[#1127] YSQL: Fix collation test failure on Mac
Browse files Browse the repository at this point in the history
Summary:
Yifan found that TestPgRegressTypesString is failing on Mac platform because of the newly added
yb_pg_collate_icu_utf8.sql test. In particular, the test uses "en_US.utf8" collation which has a
different name on Mac machine: "en_US.UTF-8". Because the collation name "en_US.utf8" does not exist
on Mac machine, the test did not execute as expected.  I changed the test to use ICU collation
"en-US-x-icu" which exists as an identical name on both linux and Mac platforms. In addition, the
test yb_pg_collate_icu_utf8.sql should use ICU collation and "en_US.utf8" is not an ICU collation.

Test Plan:
Run the following test on both Centos and Mac:
./yb_build.sh debug --java-test 'org.yb.pgsql.TestPgRegressTypesString'

Reviewers: yguan

Reviewed By: yguan

Subscribers: mihnea, yql

Differential Revision: https://phabricator.dev.yugabyte.com/D13800
  • Loading branch information
myang2021 committed Nov 5, 2021
1 parent 8dede22 commit 9ea95ff
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 43 deletions.
72 changes: 36 additions & 36 deletions src/postgres/src/test/regress/expected/yb_pg_collate_icu_utf8.out
Original file line number Diff line number Diff line change
Expand Up @@ -1090,87 +1090,87 @@ INSERT INTO tab1 values ('aaaa');
--------+-----------------------+-----------+----------+---------
id | character varying(10) | | |

ALTER TABLE tab1 ALTER COLUMN id SET DATA TYPE varchar(10) collate "en_US.utf8"; -- fail
ALTER TABLE tab1 ALTER COLUMN id SET DATA TYPE varchar(10) collate "en-US-x-icu"; -- fail
ERROR: This ALTER TABLE command is not yet supported.
\d tab1
Table "collate_tests.tab1"
Column | Type | Collation | Nullable | Default
--------+-----------------------+-----------+----------+---------
id | character varying(10) | | |

CREATE TABLE tab2(id varchar(10) collate "en_US.utf8");
CREATE TABLE tab2(id varchar(10) collate "en-US-x-icu");
CREATE INDEX tab2_id_idx on tab2(id collate "C" desc);
INSERT INTO tab2 VALUES ('aaaa');
\d tab2
Table "collate_tests.tab2"
Column | Type | Collation | Nullable | Default
--------+-----------------------+------------+----------+---------
id | character varying(10) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+-----------------------+-------------+----------+---------
id | character varying(10) | en-US-x-icu | |
Indexes:
"tab2_id_idx" lsm (id COLLATE "C" DESC)

ALTER TABLE tab2 alter COLUMN id SET DATA TYPE varchar(20) collate "en_US.utf8"; -- ok;
ALTER TABLE tab2 alter COLUMN id SET DATA TYPE varchar(20) collate "en-US-x-icu"; -- ok;
\d tab2
Table "collate_tests.tab2"
Column | Type | Collation | Nullable | Default
--------+-----------------------+------------+----------+---------
id | character varying(20) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+-----------------------+-------------+----------+---------
id | character varying(20) | en-US-x-icu | |
Indexes:
"tab2_id_idx" lsm (id COLLATE "C" DESC)

CREATE DATABASE test_db LC_COLLATE = "en_US.utf8" TEMPLATE template0; -- fail;
CREATE DATABASE test_db LC_COLLATE = "en-US-x-icu" TEMPLATE template0; -- fail;
ERROR: Value other than 'C' for lc_collate option is not yet supported at character 25
CREATE TABLE tab3(id char(10) collate "en_US.utf8");
CREATE TABLE tab3(id char(10) collate "en-US-x-icu");
CREATE INDEX tab3_id_idx ON tab3(id bpchar_pattern_ops asc); -- fail;
ERROR: could not use operator class "bpchar_pattern_ops" with column collation "en_US.utf8"
ERROR: could not use operator class "bpchar_pattern_ops" with column collation "en-US-x-icu"
\d tab3
Table "collate_tests.tab3"
Column | Type | Collation | Nullable | Default
--------+---------------+------------+----------+---------
id | character(10) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+---------------+-------------+----------+---------
id | character(10) | en-US-x-icu | |

CREATE INDEX tab3_id_idx ON tab3(id collate "C" asc); -- ok;
\d tab3
Table "collate_tests.tab3"
Column | Type | Collation | Nullable | Default
--------+---------------+------------+----------+---------
id | character(10) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+---------------+-------------+----------+---------
id | character(10) | en-US-x-icu | |
Indexes:
"tab3_id_idx" lsm (id COLLATE "C" ASC)

CREATE TABLE tab4(id varchar(10) collate "en_US.utf8");
CREATE TABLE tab4(id varchar(10) collate "en-US-x-icu");
CREATE INDEX tab4_id_idx ON tab4(id varchar_pattern_ops asc); -- fail;
ERROR: could not use operator class "varchar_pattern_ops" with column collation "en_US.utf8"
ERROR: could not use operator class "varchar_pattern_ops" with column collation "en-US-x-icu"
\d tab4
Table "collate_tests.tab4"
Column | Type | Collation | Nullable | Default
--------+-----------------------+------------+----------+---------
id | character varying(10) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+-----------------------+-------------+----------+---------
id | character varying(10) | en-US-x-icu | |

CREATE INDEX tab4_id_idx ON tab4(id collate "C" asc); -- ok;
\d tab4
Table "collate_tests.tab4"
Column | Type | Collation | Nullable | Default
--------+-----------------------+------------+----------+---------
id | character varying(10) | en_US.utf8 | |
Column | Type | Collation | Nullable | Default
--------+-----------------------+-------------+----------+---------
id | character varying(10) | en-US-x-icu | |
Indexes:
"tab4_id_idx" lsm (id COLLATE "C" ASC)

CREATE TABLE tab5(id text collate "en_US.utf8");
CREATE TABLE tab5(id text collate "en-US-x-icu");
CREATE INDEX tab5_id_idx ON tab5(id text_pattern_ops asc); -- fail;
ERROR: could not use operator class "text_pattern_ops" with column collation "en_US.utf8"
ERROR: could not use operator class "text_pattern_ops" with column collation "en-US-x-icu"
\d tab5
Table "collate_tests.tab5"
Column | Type | Collation | Nullable | Default
--------+------+------------+----------+---------
id | text | en_US.utf8 | |
Table "collate_tests.tab5"
Column | Type | Collation | Nullable | Default
--------+------+-------------+----------+---------
id | text | en-US-x-icu | |

CREATE INDEX tab5_id_idx ON tab5(id collate "C" asc); -- ok;
\d tab5
Table "collate_tests.tab5"
Column | Type | Collation | Nullable | Default
--------+------+------------+----------+---------
id | text | en_US.utf8 | |
Table "collate_tests.tab5"
Column | Type | Collation | Nullable | Default
--------+------+-------------+----------+---------
id | text | en-US-x-icu | |
Indexes:
"tab5_id_idx" lsm (id COLLATE "C" ASC)

Expand Down
14 changes: 7 additions & 7 deletions src/postgres/src/test/regress/sql/yb_pg_collate_icu_utf8.sql
Original file line number Diff line number Diff line change
Expand Up @@ -434,31 +434,31 @@ drop type textrange_en_us;
CREATE TABLE tab1(id varchar(10));
INSERT INTO tab1 values ('aaaa');
\d tab1
ALTER TABLE tab1 ALTER COLUMN id SET DATA TYPE varchar(10) collate "en_US.utf8"; -- fail
ALTER TABLE tab1 ALTER COLUMN id SET DATA TYPE varchar(10) collate "en-US-x-icu"; -- fail
\d tab1

CREATE TABLE tab2(id varchar(10) collate "en_US.utf8");
CREATE TABLE tab2(id varchar(10) collate "en-US-x-icu");
CREATE INDEX tab2_id_idx on tab2(id collate "C" desc);
INSERT INTO tab2 VALUES ('aaaa');
\d tab2
ALTER TABLE tab2 alter COLUMN id SET DATA TYPE varchar(20) collate "en_US.utf8"; -- ok;
ALTER TABLE tab2 alter COLUMN id SET DATA TYPE varchar(20) collate "en-US-x-icu"; -- ok;
\d tab2

CREATE DATABASE test_db LC_COLLATE = "en_US.utf8" TEMPLATE template0; -- fail;
CREATE DATABASE test_db LC_COLLATE = "en-US-x-icu" TEMPLATE template0; -- fail;

CREATE TABLE tab3(id char(10) collate "en_US.utf8");
CREATE TABLE tab3(id char(10) collate "en-US-x-icu");
CREATE INDEX tab3_id_idx ON tab3(id bpchar_pattern_ops asc); -- fail;
\d tab3
CREATE INDEX tab3_id_idx ON tab3(id collate "C" asc); -- ok;
\d tab3

CREATE TABLE tab4(id varchar(10) collate "en_US.utf8");
CREATE TABLE tab4(id varchar(10) collate "en-US-x-icu");
CREATE INDEX tab4_id_idx ON tab4(id varchar_pattern_ops asc); -- fail;
\d tab4
CREATE INDEX tab4_id_idx ON tab4(id collate "C" asc); -- ok;
\d tab4

CREATE TABLE tab5(id text collate "en_US.utf8");
CREATE TABLE tab5(id text collate "en-US-x-icu");
CREATE INDEX tab5_id_idx ON tab5(id text_pattern_ops asc); -- fail;
\d tab5
CREATE INDEX tab5_id_idx ON tab5(id collate "C" asc); -- ok;
Expand Down

0 comments on commit 9ea95ff

Please sign in to comment.