From 07af523870bcfe930134054febd3a6a114942e5b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 15 May 2015 13:47:42 -0400 Subject: [PATCH] Fix outdated src/test/mb/ tests, and add a GB18030 test. The expected-output files for these tests were broken by the recent addition of a warning for hash indexes. Update them. Also add a test case for GB18030 encoding, similar to the other ones. This is a pretty weak test, but it's better than nothing. --- src/test/mb/expected/big5.out | 1 + src/test/mb/expected/euc_jp.out | 1 + src/test/mb/expected/euc_kr.out | 1 + src/test/mb/expected/euc_tw.out | 1 + src/test/mb/expected/gb18030.out | 87 ++++++++++++++++++++++++++ src/test/mb/expected/mule_internal.out | 2 + src/test/mb/expected/sjis.out | 1 + src/test/mb/expected/utf8.out | 1 + src/test/mb/mbregress.sh | 11 +++- src/test/mb/sql/gb18030.sql | 19 ++++++ 10 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/test/mb/expected/gb18030.out create mode 100644 src/test/mb/sql/gb18030.sql diff --git a/src/test/mb/expected/big5.out b/src/test/mb/expected/big5.out index 97100cd0a2..d7a6097e61 100644 --- a/src/test/mb/expected/big5.out +++ b/src/test/mb/expected/big5.out @@ -2,6 +2,7 @@ drop table create table ¼t°Ó¸ê®Æ (¦æ·~§O text, ¤½¥q©ïÀY varchar, ¦a§} varchar(16)); create index ¼t°Ó¸ê®Æindex1 on ¼t°Ó¸ê®Æ using btree (¦æ·~§O); create index ¼t°Ó¸ê®Æindex2 on ¼t°Ó¸ê®Æ using hash (¤½¥q©ïÀY); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ¼t°Ó¸ê®Æ values ('¹q¸£·~', '¹F¹F¬ì§Þ', '¥_A01¤¯'); insert into ¼t°Ó¸ê®Æ values ('»s³y·~', '°]·½¦³­­¤½¥q', '¤¤B10¤¤'); insert into ¼t°Ó¸ê®Æ values ('À\¶¼·~', '¬ü¨ýªÑ¥÷¦³­­¤½¥q', '°ªZ01¤E'); diff --git a/src/test/mb/expected/euc_jp.out b/src/test/mb/expected/euc_jp.out index 15f83e0231..be248d9135 100644 --- a/src/test/mb/expected/euc_jp.out +++ b/src/test/mb/expected/euc_jp.out @@ -3,6 +3,7 @@ ERROR: table " create table ·×»»µ¡ÍѸì (ÍѸì text, ʬÎॳ¡¼¥É varchar, È÷¹Í1A¤À¤è char(16)); create index ·×»»µ¡ÍѸìindex1 on ·×»»µ¡ÍѸì using btree (ÍѸì); create index ·×»»µ¡ÍѸìindex2 on ·×»»µ¡ÍѸì using hash (ʬÎॳ¡¼¥É); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤','µ¡A01¾å'); insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹','ʬB10Ãæ'); insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼','¿ÍZ01²¼'); diff --git a/src/test/mb/expected/euc_kr.out b/src/test/mb/expected/euc_kr.out index 229ffd8f97..837f2e60d0 100644 --- a/src/test/mb/expected/euc_kr.out +++ b/src/test/mb/expected/euc_kr.out @@ -3,6 +3,7 @@ ERROR: table "ͪߩѦ create table ͪߩѦ¿ë¾î (¿ë¾î text, ÝÂ×¾ÄÚµå varchar, ºñ°í1A¶ó±¸ char(16)); create index ͪߩѦ¿ë¾îindex1 on ͪߩѦ¿ë¾î using btree (¿ë¾î); create index ͪߩѦ¿ë¾îindex2 on ͪߩѦ¿ë¾î using hash (ÝÂ×¾ÄÚµå); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ͪߩѦ¿ë¾î values('ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ', 'ѦA01ß¾'); insert into ͪߩѦ¿ë¾î values('ÄÄÇ»Åͱ׷¡ÇȽº', 'ÝÂB10ñé'); insert into ͪߩѦ¿ë¾î values('ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó', 'ìÑZ01ù»'); diff --git a/src/test/mb/expected/euc_tw.out b/src/test/mb/expected/euc_tw.out index 99eb4884e1..f224e7820d 100644 --- a/src/test/mb/expected/euc_tw.out +++ b/src/test/mb/expected/euc_tw.out @@ -3,6 +3,7 @@ ERROR: table " create table ìÞÙ¸æñÕè (ÈçäÆɱ text, ÄüƳÍñó¤ varchar, ÇâÉß varchar(16)); create index ìÞÙ¸æñÕèindex1 on ìÞÙ¸æñÕè using btree (ÈçäÆɱ); create index ìÞÙ¸æñÕèindex2 on ìÞÙ¸æñÕè using hash (ÄüƳÍñó¤); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ìÞÙ¸æñÕè values ('çÙæªäÆ', 'ç®ç®ÒïÊÀ', 'Æ¡A01Äî'); insert into ìÞÙ¸æñÕè values ('êûÝßäÆ', 'ØÂäãÈ´ÓîÄüƳ', 'ÄãB10Äã'); insert into ìÞÙ¸æñÕè values ('ó§ã£äÆ', 'Ó¡ÌÀϴǹȴÓîÄüƳ', 'ØíZ01Ħ'); diff --git a/src/test/mb/expected/gb18030.out b/src/test/mb/expected/gb18030.out new file mode 100644 index 0000000000..562852b674 --- /dev/null +++ b/src/test/mb/expected/gb18030.out @@ -0,0 +1,87 @@ +drop table ӋËã™CÓÃÕZ; +create table ӋËã™CÓÃÕZ (ÓÃÕZ text, ·Ö³©`¥É varchar, ‚俼1A¤À¤è char(16)); +create index ӋËã™CÓÃÕZindex1 on ӋËã™CÓÃÕZ using btree (ÓÃÕZ); +create index ӋËã™CÓÃÕZindex2 on ӋËã™CÓÃÕZ using hash (·Ö³©`¥É); +WARNING: hash indexes are not WAL-logged and their use is discouraged +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤','™CA01ÉÏ'); +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹','·ÖB10ÖÐ'); +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©`','ÈËZ01ÏÂ'); +vacuum ӋËã™CÓÃÕZ; +select * from ӋËã™CÓÃÕZ; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +----------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | +(3 rows) + +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É = 'ÈËZ01ÏÂ'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +--------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | +(1 row) + +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É ~* 'ÈËz01ÏÂ'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +--------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | +(1 row) + +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É like '_Z01_'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +--------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | +(1 row) + +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É like '_Z%'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +--------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | +(1 row) + +select * from ӋËã™CÓÃÕZ where ÓÃÕZ ~ '¥³¥ó¥Ô¥å©`¥¿[¥Ç¥°]'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +----------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | +(2 rows) + +select * from ӋËã™CÓÃÕZ where ÓÃÕZ ~* '¥³¥ó¥Ô¥å©`¥¿[¥Ç¥°]'; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è +----------------------------+------------+------------ + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | +(2 rows) + +select *,character_length(ÓÃÕZ) from ӋËã™CÓÃÕZ; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è | character_length +----------------------------+------------+------------+------------------ + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | | 12 + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | | 13 + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | | 12 +(3 rows) + +select *,octet_length(ÓÃÕZ) from ӋËã™CÓÃÕZ; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è | octet_length +----------------------------+------------+------------+-------------- + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | | 36 + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | | 39 + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | | 36 +(3 rows) + +select *,position('¥Ç' in ÓÃÕZ) from ӋËã™CÓÃÕZ; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è | position +----------------------------+------------+------------+---------- + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | | 7 + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | | 0 + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | | 0 +(3 rows) + +select *,substring(ÓÃÕZ from 10 for 4) from ӋËã™CÓÃÕZ; + ÓÃÕZ | ·Ö³©`¥É | ‚俼1a¤À¤è | substring +----------------------------+------------+------------+----------- + ¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤ | ™CA01ÉÏ | | ¥×¥ì¥¤ + ¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹ | ·ÖB10ÖÐ | | ¥£¥Ã¥¯¥¹ + ¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©` | ÈËZ01Ï | | ¥é¥Þ©` +(3 rows) + diff --git a/src/test/mb/expected/mule_internal.out b/src/test/mb/expected/mule_internal.out index ac8b57dc42..67f7775706 100644 --- a/src/test/mb/expected/mule_internal.out +++ b/src/test/mb/expected/mule_internal.out @@ -3,6 +3,7 @@ ERROR: table " create table ’·×’»»’µ¡’Íђ¸ì (’Íђ¸ì text, ’ʬ’Îà’¥³’¡¼’¥É varchar, ’È÷’¹Í1A’¤À’¤è char(16)); create index ’·×’»»’µ¡’Íђ¸ìindex1 on ’·×’»»’µ¡’Íђ¸ì using btree (’Íђ¸ì); create index ’·×’»»’µ¡’Íђ¸ìindex2 on ’·×’»»’µ¡’Íђ¸ì using hash (’ʬ’Îà’¥³’¡¼’¥É); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ’·×’»»’µ¡’Íђ¸ì values('’¥³’¥ó’¥Ô’¥å’¡¼’¥¿’¥Ç’¥£’¥¹’¥×’¥ì’¥¤','’µ¡A01’¾å'); insert into ’·×’»»’µ¡’Íђ¸ì values('’¥³’¥ó’¥Ô’¥å’¡¼’¥¿’¥°’¥é’¥Õ’¥£’¥Ã’¥¯’¥¹','’ʬB10’Ãæ'); insert into ’·×’»»’µ¡’Íђ¸ì values('’¥³’¥ó’¥Ô’¥å’¡¼’¥¿’¥×’¥í’¥°’¥é’¥Þ’¡¼','’¿ÍZ01’²¼'); @@ -177,6 +178,7 @@ ERROR: table " create table “ͪ“ß©“Ѧ“¿ë“¾î (“¿ë“¾î text, “Ý“׾“Äړµå varchar, “ºñ“°í1A“¶ó“±¸ char(16)); create index “ͪ“ß©“Ѧ“¿ë“¾îindex1 on “ͪ“ß©“Ѧ“¿ë“¾î using btree (“¿ë“¾î); create index “ͪ“ß©“Ѧ“¿ë“¾îindex2 on “ͪ“ß©“Ѧ“¿ë“¾î using hash (“Ý“׾“Äړµå); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into “ͪ“ß©“Ѧ“¿ë“¾î values('“Äēǻ“Å͓µð“½º“ÇÓ·¹“ÀÌ', '“ѦA01“ß¾'); insert into “ͪ“ß©“Ѧ“¿ë“¾î values('“Äēǻ“Å͓±×“·¡“Çȓ½º', '“ÝÂB10“ñé'); insert into “ͪ“ß©“Ѧ“¿ë“¾î values('“Äēǻ“Å͓ÇÁ“·Î“±×“·¡“¸Ó', '“ìÑZ01“ù»'); diff --git a/src/test/mb/expected/sjis.out b/src/test/mb/expected/sjis.out index db2bfd0d75..73dd29b984 100644 --- a/src/test/mb/expected/sjis.out +++ b/src/test/mb/expected/sjis.out @@ -2,6 +2,7 @@ drop table create table ŒvŽZ‹@—pŒê (—pŒê text, •ª—ÞƒR[ƒh varchar, ”õl1A‚¾‚æ char(16)); create index ŒvŽZ‹@—pŒêindex1 on ŒvŽZ‹@—pŒê using btree (—pŒê); create index ŒvŽZ‹@—pŒêindex2 on ŒvŽZ‹@—pŒê using hash (•ª—ÞƒR[ƒh); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into ŒvŽZ‹@—pŒê values('ƒRƒ“ƒsƒ…[ƒ^ƒfƒBƒXƒvƒŒƒC','‹@A01ã'); insert into ŒvŽZ‹@—pŒê values('ƒRƒ“ƒsƒ…[ƒ^ƒOƒ‰ƒtƒBƒbƒNƒX','•ªB10’†'); insert into ŒvŽZ‹@—pŒê values('ƒRƒ“ƒsƒ…[ƒ^ƒvƒƒOƒ‰ƒ}[','lZ01‰º'); diff --git a/src/test/mb/expected/utf8.out b/src/test/mb/expected/utf8.out index 8f9f63c7e0..715f346837 100644 --- a/src/test/mb/expected/utf8.out +++ b/src/test/mb/expected/utf8.out @@ -3,6 +3,7 @@ ERROR: table "計算機用語" does not exist create table 計算機用語 (用語 text, 分類コード varchar, 備考1Aだよ char(16)); create index 計算機用語index1 on 計算機用語 using btree (用語); create index 計算機用語index2 on 計算機用語 using hash (分類コード); +WARNING: hash indexes are not WAL-logged and their use is discouraged insert into 計算機用語 values('コンピュータディスプレイ','機A01上'); insert into 計算機用語 values('コンピュータグラフィックス','分B10中'); insert into 計算機用語 values('コンピュータプログラマー','人Z01下'); diff --git a/src/test/mb/mbregress.sh b/src/test/mb/mbregress.sh index 03e590c9fc..1efa0326c7 100755 --- a/src/test/mb/mbregress.sh +++ b/src/test/mb/mbregress.sh @@ -18,7 +18,11 @@ dropdb --if-exists utf8 createdb -T template0 -l C -E UTF8 utf8 || exit 1 PSQL="psql -n -e -q" -tests="euc_jp sjis euc_kr euc_cn euc_tw big5 utf8 mule_internal" + +# in the test list, client-only encodings must follow the server encoding +# they're to be tested with; see hard-coded cases below +tests="euc_jp sjis euc_kr euc_cn euc_tw big5 utf8 gb18030 mule_internal" + EXITCODE=0 unset PGCLIENTENCODING @@ -36,6 +40,11 @@ do export PGCLIENTENCODING $PSQL euc_tw < sql/big5.sql > results/big5.out 2>&1 unset PGCLIENTENCODING + elif [ $i = gb18030 ];then + PGCLIENTENCODING=GB18030 + export PGCLIENTENCODING + $PSQL utf8 < sql/gb18030.sql > results/gb18030.out 2>&1 + unset PGCLIENTENCODING else dropdb $i >/dev/null 2>&1 createdb -T template0 -l C -E `echo $i | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` $i >/dev/null diff --git a/src/test/mb/sql/gb18030.sql b/src/test/mb/sql/gb18030.sql new file mode 100644 index 0000000000..91ecaaa973 --- /dev/null +++ b/src/test/mb/sql/gb18030.sql @@ -0,0 +1,19 @@ +drop table ӋËã™CÓÃÕZ; +create table ӋËã™CÓÃÕZ (ÓÃÕZ text, ·Ö³©`¥É varchar, ‚俼1A¤À¤è char(16)); +create index ӋËã™CÓÃÕZindex1 on ӋËã™CÓÃÕZ using btree (ÓÃÕZ); +create index ӋËã™CÓÃÕZindex2 on ӋËã™CÓÃÕZ using hash (·Ö³©`¥É); +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥Ç¥£¥¹¥×¥ì¥¤','™CA01ÉÏ'); +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹','·ÖB10ÖÐ'); +insert into ӋËã™CÓÃÕZ values('¥³¥ó¥Ô¥å©`¥¿¥×¥í¥°¥é¥Þ©`','ÈËZ01ÏÂ'); +vacuum ӋËã™CÓÃÕZ; +select * from ӋËã™CÓÃÕZ; +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É = 'ÈËZ01ÏÂ'; +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É ~* 'ÈËz01ÏÂ'; +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É like '_Z01_'; +select * from ӋËã™CÓÃÕZ where ·Ö³©`¥É like '_Z%'; +select * from ӋËã™CÓÃÕZ where ÓÃÕZ ~ '¥³¥ó¥Ô¥å©`¥¿[¥Ç¥°]'; +select * from ӋËã™CÓÃÕZ where ÓÃÕZ ~* '¥³¥ó¥Ô¥å©`¥¿[¥Ç¥°]'; +select *,character_length(ÓÃÕZ) from ӋËã™CÓÃÕZ; +select *,octet_length(ÓÃÕZ) from ӋËã™CÓÃÕZ; +select *,position('¥Ç' in ÓÃÕZ) from ӋËã™CÓÃÕZ; +select *,substring(ÓÃÕZ from 10 for 4) from ӋËã™CÓÃÕZ; -- 2.40.0