2 -- create user defined conversion
4 CREATE USER conversion_test_user WITH NOCREATEDB NOCREATEUSER;
5 SET SESSION AUTHORIZATION conversion_test_user;
6 CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
8 -- cannot make same name conversion in same schema
10 CREATE CONVERSION myconv FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
11 ERROR: conversion "myconv" already exists
13 -- create default conversion with qualified name
15 CREATE DEFAULT CONVERSION public.mydef FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
17 -- cannot make default conversion with same shcema/for_encoding/to_encoding
19 CREATE DEFAULT CONVERSION public.mydef2 FOR 'LATIN1' TO 'UTF8' FROM iso8859_1_to_utf8;
20 ERROR: default conversion for LATIN1 to UTF8 already exists
22 COMMENT ON CONVERSION myconv_bad IS 'foo';
23 ERROR: conversion "myconv_bad" does not exist
24 COMMENT ON CONVERSION myconv IS 'bar';
25 COMMENT ON CONVERSION myconv IS NULL;
27 -- drop user defined conversion
29 DROP CONVERSION myconv;
30 DROP CONVERSION mydef;
32 -- make sure all pre-defined conversions are fine.
33 -- SQL_ASCII --> MULE_INTERNAL
34 SELECT CONVERT('foo', 'SQL_ASCII', 'MULE_INTERNAL');
40 -- MULE_INTERNAL --> SQL_ASCII
41 SELECT CONVERT('foo', 'MULE_INTERNAL', 'SQL_ASCII');
47 -- KOI8R --> MULE_INTERNAL
48 SELECT CONVERT('foo', 'KOI8R', 'MULE_INTERNAL');
54 -- MULE_INTERNAL --> KOI8R
55 SELECT CONVERT('foo', 'MULE_INTERNAL', 'KOI8R');
61 -- ISO-8859-5 --> MULE_INTERNAL
62 SELECT CONVERT('foo', 'ISO-8859-5', 'MULE_INTERNAL');
68 -- MULE_INTERNAL --> ISO-8859-5
69 SELECT CONVERT('foo', 'MULE_INTERNAL', 'ISO-8859-5');
75 -- WIN1251 --> MULE_INTERNAL
76 SELECT CONVERT('foo', 'WIN1251', 'MULE_INTERNAL');
82 -- MULE_INTERNAL --> WIN1251
83 SELECT CONVERT('foo', 'MULE_INTERNAL', 'WIN1251');
89 -- WIN866 --> MULE_INTERNAL
90 SELECT CONVERT('foo', 'WIN866', 'MULE_INTERNAL');
96 -- MULE_INTERNAL --> WIN866
97 SELECT CONVERT('foo', 'MULE_INTERNAL', 'WIN866');
104 SELECT CONVERT('foo', 'KOI8R', 'WIN1251');
111 SELECT CONVERT('foo', 'WIN1251', 'KOI8R');
118 SELECT CONVERT('foo', 'KOI8R', 'WIN866');
125 SELECT CONVERT('foo', 'WIN866', 'KOI8R');
131 -- WIN866 --> WIN1251
132 SELECT CONVERT('foo', 'WIN866', 'WIN1251');
138 -- WIN1251 --> WIN866
139 SELECT CONVERT('foo', 'WIN1251', 'WIN866');
145 -- ISO-8859-5 --> KOI8R
146 SELECT CONVERT('foo', 'ISO-8859-5', 'KOI8R');
152 -- KOI8R --> ISO-8859-5
153 SELECT CONVERT('foo', 'KOI8R', 'ISO-8859-5');
159 -- ISO-8859-5 --> WIN1251
160 SELECT CONVERT('foo', 'ISO-8859-5', 'WIN1251');
166 -- WIN1251 --> ISO-8859-5
167 SELECT CONVERT('foo', 'WIN1251', 'ISO-8859-5');
173 -- ISO-8859-5 --> WIN866
174 SELECT CONVERT('foo', 'ISO-8859-5', 'WIN866');
180 -- WIN866 --> ISO-8859-5
181 SELECT CONVERT('foo', 'WIN866', 'ISO-8859-5');
187 -- EUC_CN --> MULE_INTERNAL
188 SELECT CONVERT('foo', 'EUC_CN', 'MULE_INTERNAL');
194 -- MULE_INTERNAL --> EUC_CN
195 SELECT CONVERT('foo', 'MULE_INTERNAL', 'EUC_CN');
202 SELECT CONVERT('foo', 'EUC_JP', 'SJIS');
209 SELECT CONVERT('foo', 'SJIS', 'EUC_JP');
215 -- EUC_JP --> MULE_INTERNAL
216 SELECT CONVERT('foo', 'EUC_JP', 'MULE_INTERNAL');
222 -- SJIS --> MULE_INTERNAL
223 SELECT CONVERT('foo', 'SJIS', 'MULE_INTERNAL');
229 -- MULE_INTERNAL --> EUC_JP
230 SELECT CONVERT('foo', 'MULE_INTERNAL', 'EUC_JP');
236 -- MULE_INTERNAL --> SJIS
237 SELECT CONVERT('foo', 'MULE_INTERNAL', 'SJIS');
243 -- EUC_KR --> MULE_INTERNAL
244 SELECT CONVERT('foo', 'EUC_KR', 'MULE_INTERNAL');
250 -- MULE_INTERNAL --> EUC_KR
251 SELECT CONVERT('foo', 'MULE_INTERNAL', 'EUC_KR');
258 SELECT CONVERT('foo', 'EUC_TW', 'BIG5');
265 SELECT CONVERT('foo', 'BIG5', 'EUC_TW');
271 -- EUC_TW --> MULE_INTERNAL
272 SELECT CONVERT('foo', 'EUC_TW', 'MULE_INTERNAL');
278 -- BIG5 --> MULE_INTERNAL
279 SELECT CONVERT('foo', 'BIG5', 'MULE_INTERNAL');
285 -- MULE_INTERNAL --> EUC_TW
286 SELECT CONVERT('foo', 'MULE_INTERNAL', 'EUC_TW');
292 -- MULE_INTERNAL --> BIG5
293 SELECT CONVERT('foo', 'MULE_INTERNAL', 'BIG5');
299 -- LATIN2 --> MULE_INTERNAL
300 SELECT CONVERT('foo', 'LATIN2', 'MULE_INTERNAL');
306 -- MULE_INTERNAL --> LATIN2
307 SELECT CONVERT('foo', 'MULE_INTERNAL', 'LATIN2');
313 -- WIN1250 --> MULE_INTERNAL
314 SELECT CONVERT('foo', 'WIN1250', 'MULE_INTERNAL');
320 -- MULE_INTERNAL --> WIN1250
321 SELECT CONVERT('foo', 'MULE_INTERNAL', 'WIN1250');
327 -- LATIN2 --> WIN1250
328 SELECT CONVERT('foo', 'LATIN2', 'WIN1250');
334 -- WIN1250 --> LATIN2
335 SELECT CONVERT('foo', 'WIN1250', 'LATIN2');
341 -- LATIN1 --> MULE_INTERNAL
342 SELECT CONVERT('foo', 'LATIN1', 'MULE_INTERNAL');
348 -- MULE_INTERNAL --> LATIN1
349 SELECT CONVERT('foo', 'MULE_INTERNAL', 'LATIN1');
355 -- LATIN3 --> MULE_INTERNAL
356 SELECT CONVERT('foo', 'LATIN3', 'MULE_INTERNAL');
362 -- MULE_INTERNAL --> LATIN3
363 SELECT CONVERT('foo', 'MULE_INTERNAL', 'LATIN3');
369 -- LATIN4 --> MULE_INTERNAL
370 SELECT CONVERT('foo', 'LATIN4', 'MULE_INTERNAL');
376 -- MULE_INTERNAL --> LATIN4
377 SELECT CONVERT('foo', 'MULE_INTERNAL', 'LATIN4');
383 -- SQL_ASCII --> UTF8
384 SELECT CONVERT('foo', 'SQL_ASCII', 'UTF8');
390 -- UTF8 --> SQL_ASCII
391 SELECT CONVERT('foo', 'UTF8', 'SQL_ASCII');
398 SELECT CONVERT('foo', 'BIG5', 'UTF8');
405 SELECT CONVERT('foo', 'UTF8', 'BIG5');
412 SELECT CONVERT('foo', 'UTF8', 'KOI8R');
419 SELECT CONVERT('foo', 'KOI8R', 'UTF8');
426 SELECT CONVERT('foo', 'UTF8', 'WIN1251');
433 SELECT CONVERT('foo', 'WIN1251', 'UTF8');
440 SELECT CONVERT('foo', 'UTF8', 'WIN1252');
447 SELECT CONVERT('foo', 'WIN1252', 'UTF8');
454 SELECT CONVERT('foo', 'UTF8', 'WIN866');
461 SELECT CONVERT('foo', 'WIN866', 'UTF8');
468 SELECT CONVERT('foo', 'EUC_CN', 'UTF8');
475 SELECT CONVERT('foo', 'UTF8', 'EUC_CN');
482 SELECT CONVERT('foo', 'EUC_JP', 'UTF8');
489 SELECT CONVERT('foo', 'UTF8', 'EUC_JP');
496 SELECT CONVERT('foo', 'EUC_KR', 'UTF8');
503 SELECT CONVERT('foo', 'UTF8', 'EUC_KR');
510 SELECT CONVERT('foo', 'EUC_TW', 'UTF8');
517 SELECT CONVERT('foo', 'UTF8', 'EUC_TW');
524 SELECT CONVERT('foo', 'GB18030', 'UTF8');
531 SELECT CONVERT('foo', 'UTF8', 'GB18030');
538 SELECT CONVERT('foo', 'GBK', 'UTF8');
545 SELECT CONVERT('foo', 'UTF8', 'GBK');
552 SELECT CONVERT('foo', 'UTF8', 'LATIN2');
559 SELECT CONVERT('foo', 'LATIN2', 'UTF8');
566 SELECT CONVERT('foo', 'UTF8', 'LATIN3');
573 SELECT CONVERT('foo', 'LATIN3', 'UTF8');
580 SELECT CONVERT('foo', 'UTF8', 'LATIN4');
587 SELECT CONVERT('foo', 'LATIN4', 'UTF8');
594 SELECT CONVERT('foo', 'UTF8', 'LATIN5');
601 SELECT CONVERT('foo', 'LATIN5', 'UTF8');
608 SELECT CONVERT('foo', 'UTF8', 'LATIN6');
615 SELECT CONVERT('foo', 'LATIN6', 'UTF8');
622 SELECT CONVERT('foo', 'UTF8', 'LATIN7');
629 SELECT CONVERT('foo', 'LATIN7', 'UTF8');
636 SELECT CONVERT('foo', 'UTF8', 'LATIN8');
643 SELECT CONVERT('foo', 'LATIN8', 'UTF8');
650 SELECT CONVERT('foo', 'UTF8', 'LATIN9');
657 SELECT CONVERT('foo', 'LATIN9', 'UTF8');
664 SELECT CONVERT('foo', 'UTF8', 'LATIN10');
671 SELECT CONVERT('foo', 'LATIN10', 'UTF8');
677 -- UTF8 --> ISO-8859-5
678 SELECT CONVERT('foo', 'UTF8', 'ISO-8859-5');
684 -- ISO-8859-5 --> UTF8
685 SELECT CONVERT('foo', 'ISO-8859-5', 'UTF8');
691 -- UTF8 --> ISO-8859-6
692 SELECT CONVERT('foo', 'UTF8', 'ISO-8859-6');
698 -- ISO-8859-6 --> UTF8
699 SELECT CONVERT('foo', 'ISO-8859-6', 'UTF8');
705 -- UTF8 --> ISO-8859-7
706 SELECT CONVERT('foo', 'UTF8', 'ISO-8859-7');
712 -- ISO-8859-7 --> UTF8
713 SELECT CONVERT('foo', 'ISO-8859-7', 'UTF8');
719 -- UTF8 --> ISO-8859-8
720 SELECT CONVERT('foo', 'UTF8', 'ISO-8859-8');
726 -- ISO-8859-8 --> UTF8
727 SELECT CONVERT('foo', 'ISO-8859-8', 'UTF8');
734 SELECT CONVERT('foo', 'LATIN1', 'UTF8');
741 SELECT CONVERT('foo', 'UTF8', 'LATIN1');
748 SELECT CONVERT('foo', 'JOHAB', 'UTF8');
755 SELECT CONVERT('foo', 'UTF8', 'JOHAB');
762 SELECT CONVERT('foo', 'SJIS', 'UTF8');
769 SELECT CONVERT('foo', 'UTF8', 'SJIS');
776 SELECT CONVERT('foo', 'WIN1258', 'UTF8');
783 SELECT CONVERT('foo', 'UTF8', 'WIN1258');
790 SELECT CONVERT('foo', 'UHC', 'UTF8');
797 SELECT CONVERT('foo', 'UTF8', 'UHC');
804 SELECT CONVERT('foo', 'UTF8', 'WIN1250');
811 SELECT CONVERT('foo', 'WIN1250', 'UTF8');
818 SELECT CONVERT('foo', 'UTF8', 'WIN1256');
825 SELECT CONVERT('foo', 'WIN1256', 'UTF8');
832 SELECT CONVERT('foo', 'UTF8', 'WIN874');
839 SELECT CONVERT('foo', 'WIN874', 'UTF8');
846 SELECT CONVERT('foo', 'UTF8', 'WIN1253');
853 SELECT CONVERT('foo', 'WIN1253', 'UTF8');
860 SELECT CONVERT('foo', 'UTF8', 'WIN1254');
867 SELECT CONVERT('foo', 'WIN1254', 'UTF8');
874 SELECT CONVERT('foo', 'UTF8', 'WIN1255');
881 SELECT CONVERT('foo', 'WIN1255', 'UTF8');
888 SELECT CONVERT('foo', 'UTF8', 'WIN1257');
895 SELECT CONVERT('foo', 'WIN1257', 'UTF8');
901 -- UTF8 --> EUC_JIS_2004
902 SELECT CONVERT('foo', 'UTF8', 'EUC_JIS_2004');
908 -- EUC_JIS_2004 --> UTF8
909 SELECT CONVERT('foo', 'EUC_JIS_2004', 'UTF8');
915 -- UTF8 --> SHIFT_JIS_2004
916 SELECT CONVERT('foo', 'UTF8', 'SHIFT_JIS_2004');
922 -- SHIFT_JIS_2004 --> UTF8
923 SELECT CONVERT('foo', 'SHIFT_JIS_2004', 'UTF8');
929 -- EUC_JIS_2004 --> SHIFT_JIS_2004
930 SELECT CONVERT('foo', 'EUC_JIS_2004', 'SHIFT_JIS_2004');
936 -- SHIFT_JIS_2004 --> EUC_JIS_2004
937 SELECT CONVERT('foo', 'SHIFT_JIS_2004', 'EUC_JIS_2004');
944 -- return to the super user
946 RESET SESSION AUTHORIZATION;
947 DROP USER conversion_test_user;