]> granicus.if.org Git - postgresql/commitdiff
I really hope that I haven't missed anything in this one...
authorMarc G. Fournier <scrappy@hub.org>
Fri, 24 Jul 1998 03:32:46 +0000 (03:32 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Fri, 24 Jul 1998 03:32:46 +0000 (03:32 +0000)
From: t-ishii@sra.co.jp

Attached are patches to enhance the multi-byte support.  (patches are
against 7/18 snapshot)

* determine encoding at initdb/createdb rather than compile time

Now initdb/createdb has an option to specify the encoding. Also, I
modified the syntax of CREATE DATABASE to accept encoding option. See
README.mb for more details.

For this purpose I have added new column "encoding" to pg_database.
Also pg_attribute and pg_class are changed to catch up the
modification to pg_database.  Actually I haved added pg_database_mb.h,
pg_attribute_mb.h and pg_class_mb.h. These are used only when MB is
enabled. The reason having separate files is I couldn't find a way to
use ifdef or whatever in those files. I have to admit it looks
ugly. No way.

* support for PGCLIENTENCODING when issuing COPY command

commands/copy.c modified.

* support for SQL92 syntax "SET NAMES"

See gram.y.

* support for LATIN2-5
* add UNICODE regression test case
* new test suite for MB

New directory test/mb added.

* clean up source files

Basic idea is to have MB's own subdirectory for easier maintenance.
These are include/mb and backend/utils/mb.

82 files changed:
doc/README.mb
doc/README.mb.jp
src/Makefile.global.in
src/backend/bootstrap/Makefile
src/backend/bootstrap/bootparse.y
src/backend/bootstrap/bootscanner.l
src/backend/bootstrap/bootstrap.c
src/backend/catalog/Makefile
src/backend/commands/Makefile
src/backend/commands/cluster.c
src/backend/commands/copy.c
src/backend/commands/dbcommands.c
src/backend/commands/rename.c
src/backend/commands/user.c
src/backend/commands/vacuum.c
src/backend/commands/variable.c
src/backend/parser/Makefile
src/backend/parser/gram.y
src/backend/parser/keywords.c
src/backend/regex/Makefile
src/backend/rewrite/Makefile
src/backend/rewrite/rewriteSupport.c
src/backend/storage/lmgr/Makefile
src/backend/storage/lmgr/lmgr.c
src/backend/storage/smgr/Makefile
src/backend/storage/smgr/md.c
src/backend/tcop/utility.c
src/backend/utils/Makefile
src/backend/utils/adt/like.c
src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c
src/backend/utils/cache/Makefile
src/backend/utils/cache/fcache.c
src/backend/utils/cache/relcache.c
src/backend/utils/init/Makefile
src/backend/utils/init/miscinit.c
src/backend/utils/init/postinit.c
src/backend/utils/mb/Makefile [new file with mode: 0644]
src/backend/utils/mb/README [new file with mode: 0644]
src/backend/utils/mb/common.c [new file with mode: 0644]
src/backend/utils/mb/conv.c [moved from src/backend/commands/mbutils.c with 60% similarity]
src/backend/utils/mb/mbutils.c [new file with mode: 0644]
src/backend/utils/mb/utftest.c [moved from src/backend/regex/utftest.c with 92% similarity]
src/backend/utils/mb/variable.c [new file with mode: 0644]
src/backend/utils/mb/wchar.c [moved from src/backend/regex/utils.c with 76% similarity]
src/backend/utils/mb/wstrcmp.c [moved from src/backend/regex/wstrcmp.c with 98% similarity]
src/backend/utils/mb/wstrncmp.c [moved from src/backend/regex/wstrncmp.c with 98% similarity]
src/backend/utils/misc/Makefile
src/backend/utils/misc/database.c
src/bin/Makefile
src/bin/createdb/Makefile
src/bin/createdb/createdb.sh
src/bin/initdb/Makefile
src/bin/initdb/initdb [deleted file]
src/bin/pg_encoding/Makefile [new file with mode: 0644]
src/bin/pg_encoding/pg_encoding.c [new file with mode: 0644]
src/bin/psql/psqlHelp.h
src/configure.in
src/include/catalog/pg_proc.h
src/include/commands/dbcommands.h
src/include/mb/pg_wchar.h [moved from src/include/regex/pg_wchar.h with 59% similarity]
src/include/miscadmin.h
src/include/nodes/parsenodes.h
src/include/regex/regex.h
src/interfaces/libpq/Makefile.in
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/pqmbutils.c [deleted file]
src/interfaces/libpq/pqutils.c [deleted file]
src/test/mb/README [new file with mode: 0644]
src/test/mb/expected/euc_cn.out [new file with mode: 0644]
src/test/mb/expected/euc_jp.out [new file with mode: 0644]
src/test/mb/expected/euc_kr.out [new file with mode: 0644]
src/test/mb/expected/mule_internal.out [new file with mode: 0644]
src/test/mb/expected/sjis.out [new file with mode: 0644]
src/test/mb/expected/unicode.out [new file with mode: 0644]
src/test/mb/mbregress.sh [new file with mode: 0644]
src/test/mb/sql/euc_cn.sql [new file with mode: 0644]
src/test/mb/sql/euc_jp.sql [new file with mode: 0644]
src/test/mb/sql/euc_kr.sql [new file with mode: 0644]
src/test/mb/sql/mule_internal.sql [new file with mode: 0644]
src/test/mb/sql/sjis.sql [new file with mode: 0644]
src/test/mb/sql/unicode.sql [new file with mode: 0644]

index 775d05c48bab4aa505fb54934a732b95165d877f..d5436d16039b5fe6eaaabbd42d70800e40e89495 100644 (file)
@@ -1,4 +1,4 @@
-postgresql 6.4 multi-byte (MB) support README    Jun 5 1998
+postgresql 6.4 multi-byte (MB) support README    Jul 22 1998
 
                                                Tatsuo Ishii
                                                t-ishii@sra.co.jp
@@ -10,7 +10,10 @@ The MB support is intended for allowing PostgreSQL to handle
 multi-byte character sets such as EUC(Extended Unix Code), Unicode and
 Mule internal code. With the MB enabled you can use multi-byte
 character sets in regexp ,LIKE and some functions. The encoding system
-chosen is determined at the compile time.
+chosen is determined when initializing your PostgreSQL installation
+using initdb(1). Note that this can be overrided when creating a
+database using createdb(1) or create database SQL command. So you
+could have multiple databases with different encoding system.
 
 MB also fixes some problems concerning with 8-bit single byte
 character sets including ISO8859. (I would not say all of problems
@@ -36,7 +39,11 @@ where encoding_system is one of:
        EUC_TW                  Taiwan EUC
        UNICODE                 Unicode(UTF-8)
        MULE_INTERNAL           Mule internal
-       LATIN1                  ISO 8859-1 English and some European laguages
+       LATIN1                  ISO 8859-1 English and some European languages
+       LATIN2                  ISO 8859-2 English and some European languages
+       LATIN3                  ISO 8859-3 English and some European languages
+       LATIN4                  ISO 8859-4 English and some European languages
+       LATIN5                  ISO 8859-5 English and some European languages
 
 Example:
 
@@ -50,7 +57,28 @@ Example:
 If MB is disabled, nothing is changed except better supporting for
 8-bit single byte character sets.
 
-2. PGCLIENTENCODING
+2. How to set encoding
+
+initdb command defines the default encoding for a PostgreSQL
+installation. For example:
+
+       % initdb -e EUC_JP
+
+sets the default encoding to EUC_JP(Extended Unix Code for Japanese).
+Note that you can use "-pgencoding" instead of "-e" if you like longer
+option string:-) If no -e or -pgencoding option is given, the encoding
+specified at the compile time is used.
+
+You can create a database with a different encoding.
+
+       % createdb -E EUC_KR korean
+
+will create a database named "korean" with EUC_KR encoding. The
+another way to accomplish this is to use a SQL command:
+
+       CREATE DATABASE korean WITH ENCODING = 'EUC_KR';
+
+3. PGCLIENTENCODING
 
 If an environment variable PGCLIENTENCODING is defined on the
 frontend, automatic encoding translation is done by the backend. For
@@ -68,7 +96,11 @@ Supported encodings for PGCLIENTENCODING are:
        EUC_KR                  Korean EUC
        EUC_TW                  Taiwan EUC
        MULE_INTERNAL           Mule internal
-       LATIN1                  ISO 8859-1 English and some European laguages
+       LATIN1                  ISO 8859-1 English and some European languages
+       LATIN2                  ISO 8859-2 English and some European languages
+       LATIN3                  ISO 8859-3 English and some European languages
+       LATIN4                  ISO 8859-4 English and some European languages
+       LATIN5                  ISO 8859-5 English and some European languages
 
 Note that UNICODE is not supported(yet). Also note that the
 translation is not always possible. Suppose you choose EUC_JP for the
@@ -86,7 +118,12 @@ new command:
        SET CLIENT_ENCODING TO 'encoding';
 
 where encoding is one of the encodings those can be set to
-PGCLIENTENCODING.  To query the current the frontend encoding:
+PGCLIENTENCODING. Also you can use SQL92 syntax "SET NAMES" for this
+purpose:
+
+       SET NAMES 'encoding';
+
+To query the current the frontend encoding:
 
        SHOW CLIENT_ENCODING;
 
@@ -114,7 +151,16 @@ Unicode: http://www.unicode.org/
 
 5. History
 
-Jun 5, 1988
+Jul 22, 1998
+       * determine encoding at initdb/createdb rather than compile time
+       * support for PGCLIENTENCODING when issuing COPY command
+       * support for SQL92 syntax "SET NAMES"
+       * support for LATIN2-5
+       * add UNICODE regression test case
+       * new test suite for MB
+       * clean up source files
+
+Jun 5, 1998
        * add support for the encoding translation between the backend
          and the frontend
        * new command SET CLIENT_ENCODING etc. added
index 3fde80f4205b59960f2e71e4232db7e338a0f8b9..08476595dc0ba91cd373434bb238a3784d2a6ba0 100644 (file)
@@ -1,4 +1,4 @@
-postgresql 6.3.2 multi-byte (MB) support README               1998/5/25 \e$B:n@.\e(B
+postgresql 6.4 multi-byte (MB) support README         1998/7/22 \e$B:n@.\e(B
 
                                                        \e$B@P0fC#IW\e(B
                                                t-ishii@sra.co.jp
@@ -9,7 +9,7 @@ postgresql 6.3.2 multi-byte (MB) support README        1998/5/25 \e$B:n@.\e(B
   PostgreSQL \e$B$K$*$1$k%^%k%A%P%$%H%5%]!<%H$O0J2<$N$h$&$JFCD'$r;}$C$F$$$^$9!#\e(B
 
     1.\e$B%^%k%A%P%$%HJ8;z$H$7$F!"F|K\8l!"Cf9q8l$J$I$N3F9q$N\e(B EUC\e$B!"\e(BUnicode\e$B!"\e(B
-      mule internal code, ISO-8859-1 \e$B$,%3%s%Q%$%k;~$KA*Br2DG=!#\e(B
+      mule internal code, ISO-8859-1 \e$B$,%G!<%?%Y!<%9:n@.;~$KA*Br2DG=!#\e(B
       \e$B%G!<%?%Y!<%9$K$O$3$N%3!<%I$N$^$^3JG<$5$l$^$9!#\e(B
     2.\e$B%F!<%V%kL>$K%^%k%A%P%$%HJ8;z$,;HMQ2DG=\e(B(\e$B$?$@$7!"\e(BOS \e$B$,%^%k%A%P%$%H\e(B
       \e$B$N%U%!%$%kL>$r5v$7$F$$$k$3$H$,I,MW\e(B)
@@ -23,6 +23,7 @@ postgresql 6.3.2 multi-byte (MB) support README              1998/5/25 \e$B:n@.\e(B
       \e$B$,%P%C%/%(%s%IB&$H0[$k>l9g$K!"<+F0E*$K%3!<%IJQ49$r9T$J$$$^$9!#\e(B
 
 \e$B%$%s%9%H!<%k!'\e(B
+
   \e$B%G%U%)%k%H$G$O\e(B PostgreSQL \e$B$O%^%k%A%P%$%H$r%5%]!<%H$7$F$$$^$;$s!#\e(B
   \e$B%^%k%A%P%$%H%5%]!<%H$rM-8z$K$9$kJ}K!$r@bL@$7$^$9!#\e(B
 
@@ -34,9 +35,11 @@ postgresql 6.3.2 multi-byte (MB) support README             1998/5/25 \e$B:n@.\e(B
 
   % configure --with-mb=EUC_JP
 
-  \e$BJ8;z%3!<%I$H$7$F$O\e(B EUC_JP \e$B$r4^$a!"0J2<$N%3!<%I$,;XDj$G$-$^$9!#\e(B
-  (\e$B8=:_$N<BAu$G$O!"J8;z%3!<%I$O%3%s%Q%$%k;~$K7hDj$5$l!"<B9T;~$K\e(B
-   \e$BF0E*$KJQ99$9$k$3$H$O$G$-$^$;$s\e(B)
+  \e$BJ8;z%3!<%I$H$7$F$O\e(B EUC_JP \e$B$r4^$a!"0J2<$N%3!<%I$,\e(B initdb \e$B$K$h$k\e(B
+  \e$B%G!<%?%Y!<%9=i4|2=;~$*$h$S%G!<%?%Y!<%9:n@.;~\e(B
+  (Unix \e$B%3%^%s%I$N\e(B createdb \e$B$b$7$/$O\e(B SQL \e$B$N\e(B create database)
+  \e$B$K;XDj$G$-$^$9!#\e(BMakefile.custom \e$B$"$k$$$O\e(B configure \e$B$G;XDj$7$?J8;z%3!<\e(B
+  \e$B%I$O\e(B initdb \e$B$N>JN,;~$NJ8;z%3!<%I$K$J$j$^$9!#\e(B
 
        EUC_JP          \e$BF|K\8l\e(B EUC
        EUC_CN          GB \e$B$r%Y!<%9$K$7$?CfJ8\e(BEUC\e$B!#\e(Bcode set 2 \e$B$O\e(B
@@ -48,9 +51,9 @@ postgresql 6.3.2 multi-byte (MB) support README              1998/5/25 \e$B:n@.\e(B
                        \e$B$9$J$o$A\e(B 0xffff \e$B$^$G$G$9!#\e(B
        MULE_INTERNAL   mule \e$B$NFbIt%3!<%I!#$?$@$7!"\e(BType N \e$B$NITDjD9J8;z$O\e(B
                        \e$B%5%]!<%H$7$F$$$^$;$s!#\e(B
-       LATIN1          ISO8859 Latin 1\e$B!#%7%s%0%k%P%$%H$J$s$G$9$1$I!"\e(B
-                       \e$B;n$7$H$$$&$3$H$G\e(B:-)\e$B$A$J$_$K!"\e(BLATIN2 etc. \e$B$O\e(B
-                       \e$BL$%5%]!<%H!#\e(B
+       LATIN*          ISO8859 Latin \e$B%7%j!<%:!#\e(B* \e$B$O\e(B 1 \e$B$+$i\e(B 5 \e$B$^$G;XDj\e(B
+                       \e$B$G$-$^$9!#%7%s%0%k%P%$%H$J$s$G$9$1$I!"\e(B
+                       \e$B;n$7$H$$$&$3$H$G\e(B:-)
 
   \e$BA*Br$NL\0B$H$7$F$O!"1Q8l$HF|K\8l$7$+;H$o$J$$>l9g$O\e(B EUC_JP(\e$BF1MM$K!"Cf\e(B
   \e$B9q8l$7$+;H$o$J$$>l9g$O\e(B EUC_CN... \e$B$J$I$H$J$j$^$9\e(B)\e$B!"$=$NB>$N8@8l$b;H$$$?\e(B
@@ -69,13 +72,42 @@ postgresql 6.3.2 multi-byte (MB) support README            1998/5/25 \e$B:n@.\e(B
   http://www.sra.co.jp/people/t-ishii/PostgreSQL/ \e$B$G$b4JC1$J%$%s%9%H!<\e(B
   \e$B%kJ}K!$r>R2p$7$F$$$^$9!#\e(B
 
+initdb/createdb/create database \e$B$K$*$1$kJ8;z%3!<%I$N;XDj$K$D$$$F\e(B
+
+  initdb \e$B$G$O0J2<$N%*%W%7%g%s$GJ8;z%3!<%I$,;XDj$G$-$^$9!#\e(B
+
+       -e \e$BJ8;z%3!<%I\e(B
+       -pgencoding \e$BJ8;z%3!<%I\e(B
+
+  \e$B$3$3$G;XDj$7$?J8;z%3!<%I$O!"0J8e\e(B createdb/create database \e$B$GJ8;z%3!<%I$r\e(B
+  \e$B>JN,$7$?>l9g$K@_Dj$5$l$kJ8;z%3!<%I$K$J$j$^$9!#\e(B-e \e$B$^$?$O\e(B -pgencoding
+  \e$B%*%W%7%g%s$r>JN,$7$?>l9g$O!"\e(BMakefile.custom \e$B$"$k$$$O\e(B configure \e$B$G;X\e(B
+  \e$BDj$7$?J8;z%3!<%I$,:NMQ$5$l$^$9!#\e(B
+
+  createdb \e$B$G$O0J2<$N%*%W%7%g%s$GJ8;z%3!<%I$,;XDj$G$-$^$9!#\e(B
+
+       -E \e$BJ8;z%3!<%I\e(B
+
+  create database \e$B$G$O0J2<$N%*%W%7%g%s$GJ8;z%3!<%I$,;XDj$G$-$^$9!#\e(B
+
+       CREATE DATABASE dbanme WITH ENCODING = '\e$BJ8;z%3!<%I\e(B';
+
+  LOCATION \e$B$rF1;~$K;XDj$9$k>l9g$O0J2<$N$h$&$K$J$j$^$9!#\e(B
+
+       CREATE DATABASE dbanme WITH LOCATION = 'path' ENCODING = '\e$BJ8;z%3!<%I\e(B';
+
+  createdb/create database \e$B$O!"J8;z%3!<%I;XDj$r>JN,$7$?>l9g$O!"\e(Binitdb 
+  \e$B$G;XDj$7$?J8;z%3!<%I$,:NMQ$5$l$^$9!#\e(B
+
 \e$B4D6-JQ?t\e(B PGCLIENTENCODING \e$B$K$D$$$F!'\e(B
 
-  \e$B%G%U%)%k%H$G$O!"%3%s%Q%$%k;~$K;XDj$7$?%5!<%PB&$NJ8;z%3!<%I$H!"\e(Bpsql 
-  \e$B$J$I$N%/%i%$%"%s%HB&$NJ8;z%3!<%I$,0lCW$7$F$$$k$b$N$H8+Jo$5$l$^$9!#%5!<\e(B
-  \e$B%PB&$H0[$kJ8;z%3!<%I$r;H$$$?$$>l9g$O!"4D6-JQ?t\e(B PGCLIENTENCODING \e$B$r@_\e(B
-  \e$BDj$7$^$9!#@_Dj2DG=$JJ8;z%3!<%I$O!">e5-$K2C$(!"\e(BSJIS (\e$B%7%U%H\e(BJIS)
-  \e$B$,;XDj$G$-$^$9!#\e(B
+  \e$B4D6-JQ?t\e(B PGCLIENTENCODING \e$B$,@_Dj$5$l$F$$$J$$>l9g!"\e(Blibpq \e$B$O%;%C%7%g%s\e(B
+  \e$B3+;O;~$K%5!<%PB&$KJ8;z%3!<%I$rLd$$9g$o$;!"$=$NCM$r4D6-JQ?t\e(B 
+  PGCLIENTENCODING \e$B$K@_Dj$7$^$9!#\e(B
+
+  \e$B4D6-JQ?t\e(B PGCLIENTENCODING \e$B$,@_Dj$5$l$F$$$k>l9g$O$=$NCM$,M%@h$5$l!"%5!<\e(B
+  \e$B%PB&$H0[$J$kJ8;z%3!<%I$,;HMQ$G$-$^$9!#@_Dj2DG=$JJ8;z%3!<%I$O!">e5-$K\e(B
+  \e$B2C$(!"\e(BSJIS (\e$B%7%U%H\e(BJIS)\e$B$,;XDj$G$-$^$9!#\e(B
 
        \e$B$A$J$_$K!"\e(BSJIS \e$B$O\e(B JISX0201 \e$B$N\e(B 1\e$B%P%$%H%+%J!"$$$o$f$k!VH>3Q%+%?\e(B
        \e$B%+%J!W$b%5%]!<%H$7$F$$$^$9\e(B(\e$B7h$7$F!VH>3Q%+%?%+%J!W$N;HMQ$r$*4+\e(B
@@ -150,6 +182,18 @@ postgresql 6.3.2 multi-byte (MB) support README           1998/5/25 \e$B:n@.\e(B
 
 \e$B2~DjMzNr!'\e(B
 
+  1998/7/22 6.4 \e$B&A8~$1$K%Q%C%A$r%j%j!<%9!#\e(B
+       * initdb/createdb/create database \e$B$G%5!<%PB&$NJ8;z%3!<%I$r@_Dj\e(B
+          \e$B$G$-$k5!G=<BAu!#$3$N$?$a!"%7%9%F%`%+%?%m%0$N\e(B pg_database \e$B$K\e(B
+          \e$B?7$7$$%+%i%`\e(B encoding \e$B$rDI2C\e(B(MB\e$B$,M-8z$J;~$@$1\e(B)
+       * copy \e$B$,\e(B PGCLIENTENCODING \e$B$KBP1~\e(B
+       * SQL92 \e$B$N\e(B "SET NAMES" \e$B$r%5%]!<%H\e(B(MB\e$B$,M-8z$J;~$@$1\e(B)
+       * LATIN2-5 \e$B$r%5%]!<%H\e(B
+       * regression test \e$B$K\e(B unicode \e$B$N%F%9%H%1!<%9$rDI2C\e(B
+       * MB \e$B@lMQ$N\e(B regression \e$B%F%9%H%G%#%l%/%H%j\e(B test/mb \e$B$rDI2C\e(B
+       * \e$B%=!<%9%U%!%$%k$NCV$->l=j$rBgI}8+D>$7!#\e(BMB \e$B4X78$O\e(B
+         include/mb, backend/utils/mb \e$B$KCV$/$h$&$K$7$?\e(B
+
   1998/5/25 \e$B%P%0=$@5\e(B(mb_b3.patch \e$B$H$7$F\e(B pgsql-jp ML \e$B$K%j%j!<%9!"\e(B
        \e$BK\2H$G$O\e(B 6.4 snapshot \e$B$K<h$j9~$^$l$kM=Dj\e(B)   
 
index ebd5c4ba933bb2a79fc4a1392a2b33915ca90420..89045b0dad55116d16dbd30d72e1accc9ba49ed3 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.43 1998/06/16 07:29:15 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.44 1998/07/24 03:31:04 scrappy Exp $
 #
 # NOTES
 #    Essentially all Postgres make files include this file and use the 
@@ -150,7 +150,7 @@ X11_LIBS= -lX11 @X_EXTRA_LIBS@
 #
 # enable multi-byte support
 # choose one of:
-# EUC_JP,EUC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1
+# EUC_JP,EUC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1-5
 MB=@MB@
 
 ##############################################################################
index b172c4d267b06533f669f461d3720c60a2590292..a3e8fa168586716aa5ebe9fec45eae95eaaa5f40 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for the bootstrap module
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.13 1998/04/06 00:22:02 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.14 1998/07/24 03:31:06 scrappy Exp $
 #
 #
 # We must build bootparse.c and bootscanner.c with yacc and lex and sed,
@@ -22,6 +22,9 @@ SRCDIR= ../..
 include ../../Makefile.global
 
 CFLAGS += -I..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
 
 ifeq ($(CC), gcc)
 CFLAGS+= -Wno-error
index ef7c801347e124565bbc6d4b4ec84230f2530d0a..470d16b10158abd4c512bc329a3de3eaf32ac1fc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.16 1998/04/26 04:05:51 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.17 1998/07/24 03:31:07 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "bootstrap/bootstrap.h"
 #include "catalog/heap.h"
 #include "catalog/pg_am.h"
+#ifdef MB
+#include "catalog/pg_attribute_mb.h"
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_attribute.h"
 #include "catalog/pg_class.h"
+#endif
 #include "commands/defrem.h"
 #include "nodes/nodes.h"
 #include "nodes/parsenodes.h"
index e94133c2b0c0845a15a7668e471b2ab447e14b09..c3364c08735a6a697afcdcf717e7b302e0938bbb 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.8 1997/11/24 05:07:56 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.9 1998/07/24 03:31:08 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "storage/block.h"
 #include "storage/off.h"
 #include "storage/itemptr.h"
+#ifdef MB
+#include "catalog/pg_attribute_mb.h"
+#else
 #include "catalog/pg_attribute.h"
+#endif
 #include "access/attnum.h"
 #include "nodes/pg_list.h"
 #include "access/tupdesc.h"
 #include "access/funcindex.h"
 #include "storage/fd.h"
 #include "catalog/pg_am.h"
+#ifdef MB
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_class.h"
+#endif
 #include "nodes/nodes.h"
 #include "rewrite/prs2lock.h"
 #include "access/skey.h"
index acf461d1627fcc18e5dbb779c09ef1b816b47ee9..b5fa5e1952aaaff323f343c948de482e65fc1156 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.44 1998/06/27 04:53:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.45 1998/07/24 03:31:08 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "catalog/catname.h"
 #include "catalog/index.h"
 #include "catalog/pg_am.h"
+#ifdef MB
+#include "catalog/pg_attribute_mb.h"
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_attribute.h"
 #include "catalog/pg_class.h"
+#endif
 #include "catalog/pg_type.h"
 #include "executor/execdesc.h"
 #include "executor/hashjoin.h"
index f13fa5f92ab410d8b3efb5a7cd42892fda437d97..79c38a8928e944006ef2a950529c7164cb5cd7b7 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for catalog
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.10 1998/04/06 00:22:13 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/catalog/Makefile,v 1.11 1998/07/24 03:31:09 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -24,11 +24,28 @@ SUBSYS.o: $(OBJS)
 
 GENBKI= ./genbki.sh
 
+ifdef MB
+GLOBALBKI_SRCS= $(addprefix ../../include/catalog/, \
+                  pg_database_mb.h pg_variable.h pg_shadow.h \
+                  pg_group.h pg_log.h \
+                 )
+else
 GLOBALBKI_SRCS= $(addprefix ../../include/catalog/, \
                   pg_database.h pg_variable.h pg_shadow.h \
                   pg_group.h pg_log.h \
                  )
+endif
 
+ifdef MB
+LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
+                 pg_proc.h pg_type.h pg_attribute_mb.h pg_class_mb.h \
+                 pg_inherits.h pg_index.h pg_version.h pg_statistic.h \
+                 pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
+                 pg_language.h pg_parg.h \
+                 pg_aggregate.h pg_ipl.h pg_inheritproc.h \
+                 pg_rewrite.h pg_listener.h pg_description.h indexing.h \
+                )
+else
 LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
                  pg_proc.h pg_type.h pg_attribute.h pg_class.h \
                  pg_inherits.h pg_index.h pg_version.h pg_statistic.h \
@@ -37,7 +54,7 @@ LOCALBKI_SRCS= $(addprefix ../../include/catalog/, \
                  pg_aggregate.h pg_ipl.h pg_inheritproc.h \
                  pg_rewrite.h pg_listener.h pg_description.h indexing.h \
                 )
-
+endif
 global1.bki.source: $(GENBKI) $(GLOBALBKI_SRCS)
        sh $(SHOPTS) $(GENBKI) $(BKIOPTS) $(GLOBALBKI_SRCS) > $@ 2>global1.description
 
index fc2b7199ab05a2df0b34a3ad42cbfae027fad523..66e8f9a490e20f587f4d4cdffa3f95f01c2bb921 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for commands
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.13 1998/06/16 07:29:20 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.14 1998/07/24 03:31:11 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -22,10 +22,6 @@ OBJS = async.o creatinh.o command.o copy.o defind.o define.o \
        recipe.o explain.o sequence.o trigger.o user.o proclang.o \
        dbcommands.o variable.o
 
-ifdef MB
-OBJS += mbutils.o
-endif
-
 all: SUBSYS.o
 
 SUBSYS.o: $(OBJS)
index 377f8f166ce994c8f8176609bcb65538c19237d1..10a2fca34c164da2f6f3f4722ccf98467b0abb71 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.23 1998/02/26 04:30:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.24 1998/07/24 03:31:13 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <utils/excid.h>
 #include <utils/mcxt.h>
 #include <catalog/pg_proc.h>
+#ifdef MB
+#include <catalog/pg_class_mb.h>
+#else
 #include <catalog/pg_class.h>
+#endif
 #include <optimizer/internal.h>
 #ifndef NO_SECURITY
 #include <utils/acl.h>
index 4ad772d0a38c6657af39e3f8645ada6f511823a6..23af759af4cddfc2bf3b6b349d047c038b99521a 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.49 1998/07/15 18:53:40 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.50 1998/07/24 03:31:14 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "commands/trigger.h"
 #include <storage/fd.h>
 
+#ifdef MB
+#include "mb/pg_wchar.h"
+#endif
+
 #define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
 #define VALUE(c) ((c) - '0')
 
@@ -61,7 +65,7 @@ static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline
 static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim);
 
 #endif
-static void CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array);
+static void CopyAttributeOut(FILE *fp, unsigned char *string, char *delim, int is_array);
 static int     CountTuples(Relation relation);
 
 extern FILE *Pfout,
@@ -277,7 +281,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
                                {
                                        string = (char *) (*fmgr_faddr(&out_functions[i]))
                                                (value, elements[i], typmod[i]);
-                                       CopyAttributeOut(fp, string, delim, attr[i]->attnelems);
+                                       CopyAttributeOut(fp, (unsigned char*)string, delim, attr[i]->attnelems);
                                        pfree(string);
                                }
                                else
@@ -1012,6 +1016,17 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
        char            c;
        int                     done = 0;
        int                     i = 0;
+#ifdef MB
+       int     mblen;
+       int     encoding;
+       unsigned char   s[2];
+       int     j;
+#endif
+
+#ifdef MB
+       encoding = pg_get_client_encoding();
+       s[1] = 0;
+#endif
 
 #ifdef COPY_PATCH
        /* if last delimiter was a newline return a NULL attribute */
@@ -1029,9 +1044,9 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
        while (!done)
        {
                c = getc(fp);
-
                if (feof(fp))
                        return (NULL);
+
                else if (c == '\\')
                {
                        c = getc(fp);
@@ -1112,21 +1127,55 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
 #endif
                        done = 1;
                }
-               if (!done)
+               if (!done) {
                        attribute[i++] = c;
+#ifdef MB
+                       s[0] = c;
+                       mblen = pg_encoding_mblen(encoding, s);
+                       mblen--;
+                       for(j=0;j<mblen;j++) {
+                         c = getc(fp);
+                         if (feof(fp))
+                           return (NULL);
+                         attribute[i++] = c;
+                       }
+#endif
+               }
                if (i == EXT_ATTLEN - 1)
                        elog(ERROR, "CopyReadAttribute - attribute length too long. line: %d", lineno);
        }
        attribute[i] = '\0';
+#ifdef MB
+       return(pg_client_to_server((unsigned char*)attribute, strlen(attribute)));
+#else
        return (&attribute[0]);
+#endif
 }
 
 static void
-CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array)
+CopyAttributeOut(FILE *fp, unsigned char *server_string, char *delim, int is_array)
 {
-       char            c;
+        unsigned char           *string;
+       unsigned char           c;
+#ifdef MB
+       int     mblen;
+       int     encoding;
+       int     i;
+#endif
+
+#ifdef MB
+       string = pg_server_to_client(server_string, strlen(server_string));
+       encoding = pg_get_client_encoding();
+#else
+       string = server_string;
+#endif
 
+#ifdef MB
+       for (; (mblen = pg_encoding_mblen(encoding, string)) &&
+              ((c = *string) != '\0'); string += mblen)
+#else
        for (; (c = *string) != '\0'; string++)
+#endif
        {
                if (c == delim[0] || c == '\n' ||
                        (c == '\\' && !is_array))
@@ -1148,7 +1197,13 @@ CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array)
                                fputc('\\', fp);
                        }
                }
+#ifdef MB
+               for (i=0;i<mblen;i++) {
+                       fputc(*(string+i), fp);
+               }
+#else
                fputc(*string, fp);
+#endif
        }
 }
 
index 2d4bdcb39b971f310f6ac0ea3292c62e14b5a401..c2518b5a613cc8521c2177402432a39c1dc62803 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.15 1998/06/15 19:28:14 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.16 1998/07/24 03:31:15 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "access/htup.h"
 #include "access/relscan.h"
 #include "catalog/catname.h"
+#ifdef MB
+#include "catalog/pg_database_mb.h"
+#else
 #include "catalog/pg_database.h"
+#endif
 #include "catalog/pg_shadow.h"
 #include "commands/dbcommands.h"
 #include "fmgr.h"
@@ -43,7 +47,11 @@ static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel);
 static void stop_vacuum(char *dbpath, char *dbname);
 
 void
+#ifdef MB
+createdb(char *dbname, char *dbpath, int encoding)
+#else
 createdb(char *dbname, char *dbpath)
+#endif
 {
        Oid                     db_id,
                                user_id;
@@ -90,8 +98,13 @@ createdb(char *dbname, char *dbpath)
                        dbname, user_id, dbname);
 #endif
 
+#ifdef MB
+       sprintf(buf, "insert into pg_database (datname, datdba, encoding, datpath)"
+                       " values (\'%s\', \'%d\', \'%d\', \'%s\');", dbname, user_id, encoding, loc);
+#else
        sprintf(buf, "insert into pg_database (datname, datdba, datpath)"
                        " values (\'%s\', \'%d\', \'%s\');", dbname, user_id, loc);
+#endif
 
        pg_exec_query(buf);
 }
index 9cfbba984c383a8f431cd273d08090a0f04a4aee..ef082f9dfdeae154f43c1840602c4f16e5214192 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.11 1998/01/05 16:38:59 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.12 1998/07/24 03:31:19 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include <utils/excid.h>
 #include <utils/mcxt.h>
 #include <catalog/pg_proc.h>
+#ifdef MB
+#include <catalog/pg_class_mb.h>
+#else
 #include <catalog/pg_class.h>
+#endif
 #include <optimizer/internal.h>
 #include <optimizer/prep.h>            /* for find_all_inheritors */
 #ifndef NO_SECURITY
index 1f43be77d5dc72553b730fac68f775c249ea4d23..08088eb4b7f43f8c6a3282e20ad6fe6723cc324b 100644 (file)
 
 #include <miscadmin.h>
 #include <catalog/catname.h>
+#ifdef MB
+#include <catalog/pg_database_mb.h>
+#else
 #include <catalog/pg_database.h>
+#endif
 #include <catalog/pg_shadow.h>
 #include <libpq/crypt.h>
 #include <access/heapam.h>
index 995774ed6a511ffa4c9bc1cbaa84353036d1656e..61375a0b8c600dd4226f660dccf422fe842aad96 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.66 1998/07/12 04:37:52 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.67 1998/07/24 03:31:20 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "catalog/catalog.h"
 #include "catalog/catname.h"
 #include "catalog/index.h"
+#ifdef MB
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_class.h"
+#endif
 #include "catalog/pg_index.h"
 #include "catalog/pg_operator.h"
 #include "catalog/pg_statistic.h"
index a4553e2d4e6710f38575bc4bd798bd6a55f1694a..26070b7c7ded2efcf9f72c4da859df7434bc5b8e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for handling of 'SET var TO',
  *     'SHOW var' and 'RESET var' statements.
  *
- * $Id: variable.c,v 1.8 1998/07/18 18:34:01 momjian Exp $
+ * $Id: variable.c,v 1.9 1998/07/24 03:31:20 scrappy Exp $
  *
  */
 
@@ -602,6 +602,9 @@ struct VariableParsers
        {
                "client_encoding", parse_client_encoding, show_client_encoding, reset_client_encoding
        },
+       {
+               "server_encoding", parse_server_encoding, show_server_encoding, reset_server_encoding
+       },
 #endif
        {
                NULL, NULL, NULL, NULL
index 33702f6da143896afdc6cbce16a9f29ed9062d35..2ee71b738084f2102cd7ada2170dee180e57206c 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for parser
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.17 1998/05/13 04:54:16 thomas Exp $
+#    $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.18 1998/07/24 03:31:21 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,6 +17,9 @@ ifeq ($(CC), gcc)
 CFLAGS+= -Wno-error
 endif
 
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
 
 OBJS= analyze.o gram.o keywords.o parser.o parse_agg.o parse_clause.o \
       parse_expr.o parse_func.o parse_node.o parse_oper.o parse_relation.o \
index 71d4a204c656d3e9aac7bddb5e8fb022ac3cf6db..6d5f1a3d250b0c515cd292b4957c448ad7ae9609 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.15 1998/07/19 05:49:22 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.16 1998/07/24 03:31:23 scrappy Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
 #include "utils/elog.h"
 #include "access/xact.h"
 
+#ifdef MB
+#include "mb/pg_wchar.h"
+#endif
+
 static char saved_relname[NAMEDATALEN];  /* need this for complex attributes */
 static bool QueryIsRule = FALSE;
 static List *saved_In_Expr = NIL;
@@ -126,7 +130,7 @@ Oid param_type(int t); /* used in parse_expr.c */
                ExplainStmt, VariableSetStmt, VariableShowStmt, VariableResetStmt,
                CreateUserStmt, AlterUserStmt, DropUserStmt
 
-%type <str>            opt_database, location
+%type <str>    opt_database1, opt_database2, location, encoding
 
 %type <pboolean> user_createdb_clause, user_createuser_clause
 %type <str>   user_passwd_clause
@@ -262,7 +266,7 @@ Oid param_type(int t); /* used in parse_expr.c */
                GRANT, GROUP, HAVING, HOUR_P,
                IN, INNER_P, INSERT, INTERVAL, INTO, IS,
                JOIN, KEY, LANGUAGE, LEADING, LEFT, LIKE, LOCAL,
-               MATCH, MINUTE_P, MONTH_P,
+               MATCH, MINUTE_P, MONTH_P, NAMES,
                NATIONAL, NATURAL, NCHAR, NO, NOT, NOTIFY, NULL_P, NUMERIC,
                ON, OPTION, OR, ORDER, OUTER_P,
                PARTIAL, POSITION, PRECISION, PRIMARY, PRIVILEGES, PROCEDURE, PUBLIC,
@@ -290,7 +294,7 @@ Oid param_type(int t); /* used in parse_expr.c */
                NEW, NONE, NOTHING, NOTNULL, OIDS, OPERATOR, PROCEDURAL,
                RECIPE, RENAME, RESET, RETURNS, ROW, RULE,
                SEQUENCE, SETOF, SHOW, START, STATEMENT, STDIN, STDOUT, TRUSTED, 
-               VACUUM, VERBOSE, VERSION
+               VACUUM, VERBOSE, VERSION, ENCODING
 
 /* Keywords (obsolete; retain through next version for parser - thomas 1997-12-04) */
 %token ARCHIVE
@@ -535,6 +539,17 @@ VariableSetStmt:  SET ColId TO var_value
                                        n->value = $4;
                                        $$ = (Node *) n;
                                }
+               | SET NAMES encoding
+                               {
+#ifdef MB
+                                       VariableSetStmt *n = makeNode(VariableSetStmt);
+                                       n->name  = "client_encoding";
+                                       n->value = $3;
+                                       $$ = (Node *) n;
+#else
+                                       elog(ERROR, "SET NAMES is not supported");
+#endif
+                               }
                ;
 
 var_value:  Sconst                     { $$ = $1; }
@@ -2094,16 +2109,45 @@ LoadStmt:  LOAD file_name
  *
  *****************************************************************************/
 
-CreatedbStmt:  CREATE DATABASE database_name opt_database
+CreatedbStmt:  CREATE DATABASE database_name WITH opt_database1 opt_database2
                                {
                                        CreatedbStmt *n = makeNode(CreatedbStmt);
+                                       if ($5 == NULL && $6 == NULL) {
+                                               elog(ERROR, "CREATE DATABASE WITH requires at least an option");
+                                       }
                                        n->dbname = $3;
-                                       n->dbpath = $4;
+                                       n->dbpath = $5;
+#ifdef MB
+                                       if ($6 != NULL) {
+                                               n->encoding = pg_char_to_encoding($6);
+                                               if (n->encoding < 0) {
+                                                       elog(ERROR, "invalid encoding name %s", $6);
+                                               }
+                                       } else {
+                                               n->encoding = GetTemplateEncoding();
+                                       }
+#else
+                                       elog(ERROR, "WITH ENCODING is not supported");
+#endif
                                        $$ = (Node *)n;
                                }
+               | CREATE DATABASE database_name
+                               {
+                                       CreatedbStmt *n = makeNode(CreatedbStmt);
+                                       n->dbname = $3;
+                                       n->dbpath = NULL;
+#ifdef MB
+                                       n->encoding = GetTemplateEncoding();
+#endif
+                                       $$ = (Node *)n;
+                               }
+               ;
+
+opt_database1:  LOCATION '=' location                  { $$ = $3; }
+               | /*EMPTY*/                                                             { $$ = NULL; }
                ;
 
-opt_database:  WITH LOCATION '=' location              { $$ = $4; }
+opt_database2:  ENCODING '=' encoding                  { $$ = $3; }
                | /*EMPTY*/                                                             { $$ = NULL; }
                ;
 
@@ -2112,6 +2156,11 @@ location:  Sconst                                                                { $$ = $1; }
                | /*EMPTY*/                                                             { $$ = NULL; }
                ;
 
+encoding:  Sconst                                                              { $$ = $1; }
+               | DEFAULT                                                               { $$ = NULL; }
+               | /*EMPTY*/                                                             { $$ = NULL; }
+               ;
+
 /*****************************************************************************
  *
  *             QUERY:
@@ -4487,6 +4536,7 @@ ColId:  IDENT                                                     { $$ = $1; }
                | DELIMITERS                                    { $$ = "delimiters"; }
                | DOUBLE                                                { $$ = "double"; }
                | EACH                                                  { $$ = "each"; }
+               | ENCODING                                              { $$ = "encoding"; }
                | FUNCTION                                              { $$ = "function"; }
                | INCREMENT                                             { $$ = "increment"; }
                | INDEX                                                 { $$ = "index"; }
index b94a59d49ca0e81ce9bd73193edfe5a432c7d323..c3b53722a3106b3b244015bcd15cafe69cae7a8e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.37 1998/05/09 23:28:49 thomas Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.38 1998/07/24 03:31:24 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -86,6 +86,7 @@ static ScanKeyword ScanKeywords[] = {
        {"double", DOUBLE},
        {"drop", DROP},
        {"each", EACH},
+       {"encoding", ENCODING},
        {"end", END_TRANS},
        {"execute", EXECUTE},
        {"exists", EXISTS},
@@ -135,6 +136,7 @@ static ScanKeyword ScanKeywords[] = {
        {"minvalue", MINVALUE},
        {"month", MONTH_P},
        {"move", MOVE},
+       {"names", NAMES},
        {"national", NATIONAL},
        {"natural", NATURAL},
        {"nchar", NCHAR},
index 42f635aaeb420f8af64abb3fc7a67d753ded6a0c..1d1a9ac4f689271ff322143d8dc626f3fc8aa203 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for regex
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.6 1998/04/06 00:24:39 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/regex/Makefile,v 1.7 1998/07/24 03:31:24 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -16,7 +16,6 @@ CFLAGS += -DPOSIX_MISTAKE
 
 OBJS = regcomp.o regerror.o regexec.o regfree.o
 ifdef MB
-OBJS += utils.o wstrcmp.o wstrncmp.o
 CFLAGS += -DMB=$(MB)
 endif
 
index cba2474b8bbe86f50ff3ada281e28f2099ba9fef..557313e3dd4505ce473020f47661079b89103287 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for rewrite
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/rewrite/Makefile,v 1.6 1998/04/06 00:24:49 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/rewrite/Makefile,v 1.7 1998/07/24 03:31:30 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,6 +12,9 @@ SRCDIR = ../..
 include ../../Makefile.global
 
 CFLAGS += -I..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
 
 OBJS = rewriteRemove.o rewriteDefine.o \
        rewriteHandler.o rewriteManip.o rewriteSupport.o locks.o
index 964e50f702084fcbba1d92146289bd762ed85488..9acf1eb13b18eaf2f749f6ad6408d891a103eb5f 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.21 1998/06/15 19:29:08 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.22 1998/07/24 03:31:31 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "access/heapam.h"
 #include "catalog/catname.h"
 #include "catalog/indexing.h"
+#ifdef MB
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_class.h"
+#endif
 #include "catalog/pg_rewrite.h"
 #include "fmgr.h"
 #include "nodes/parsenodes.h"
index be70c7234a0de4e777266cdc143f5253ccab51b9..5c7ee26afaf89fc0948519141475fe552afa7f2e 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for storage/lmgr
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Makefile,v 1.6 1998/04/06 00:25:43 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Makefile,v 1.7 1998/07/24 03:31:32 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,6 +12,9 @@ SRCDIR = ../../..
 include ../../../Makefile.global
 
 CFLAGS += -I../..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
 
 OBJS = lmgr.o lock.o multi.o proc.o single.o
 
index 0f55f118634789dd55152721e6cf3d95739f5ab9..a2633744e98e5cb5134e971dd91441cde633a39a 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.13 1998/07/13 16:34:50 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.14 1998/07/24 03:31:33 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "catalog/catname.h"
 #include "catalog/catalog.h"
+#ifdef MB
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_class.h"
+#endif
 
 #include "nodes/memnodes.h"
 #include "storage/bufmgr.h"
index ba3278d62da8b8c0d55df02a0eab7266fd1834c1..95784123fb44a9a5b44afafc1d6ac85b652d7009 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for storage/smgr
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/storage/smgr/Makefile,v 1.6 1998/04/06 00:25:58 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/storage/smgr/Makefile,v 1.7 1998/07/24 03:31:35 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,6 +13,10 @@ include ../../../Makefile.global
 
 CFLAGS += -I../..
 
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
+
 OBJS = md.o mm.o smgr.o smgrtype.o
 
 all: SUBSYS.o
index ba67413bdcbd876e4dfd23b00d8bb4366b1eb894..850b8df96ad4e99b6c7fca79739ed0fdf9def3d7 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.33 1998/07/20 16:56:55 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.34 1998/07/24 03:31:35 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -568,8 +568,15 @@ mdblindwrt(char *dbstr,
                Oid                     owner,
                                        id;
                char       *tmpPath;
+#ifdef MB
+               int        tmpEncoding;
+#endif
 
+#ifdef MB
+               GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
+#else
                GetRawDatabaseInfo(dbstr, &owner, &id, dbpath);
+#endif
 
                if (id != dbid)
                        elog(FATAL, "mdblindwrt: oid of db %s is not %u", dbstr, dbid);
@@ -607,7 +614,15 @@ mdblindwrt(char *dbstr,
                                        id;
                char       *tmpPath;
 
+#ifdef MB
+               int        tmpEncoding;
+#endif
+
+#ifdef MB
+               GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
+#else
                GetRawDatabaseInfo(dbstr, &owner, &id, dbpath);
+#endif
 
                if (id != dbid)
                        elog(FATAL, "mdblindwrt: oid of db %s is not %u", dbstr, dbid);
index d66cfa365c8171865c91fa5c45d3d26ab6284c2a..01520324a7440f9d4a2fd35c103fca93f3123abc 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.42 1998/06/16 02:53:26 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.43 1998/07/24 03:31:38 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -558,7 +558,11 @@ ProcessUtility(Node *parsetree,
 
                                *ps_status = commandTag = "CREATEDB";
                                CHECK_IF_ABORTED();
+#ifdef MB
+                               createdb(stmt->dbname, stmt->dbpath, stmt->encoding);
+#else
                                createdb(stmt->dbname, stmt->dbpath);
+#endif
                        }
                        break;
 
index 887c7f0324ab0bd0028351d3060931d9f0ec8b96..2f09fe46fe0b0d526c92c4228df095224b1d68dd 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for utils
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.6 1998/04/06 00:26:13 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/Makefile,v 1.7 1998/07/24 03:31:39 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -23,6 +23,11 @@ OBJS = fmgrtab.o adt/SUBSYS.o cache/SUBSYS.o error/SUBSYS.o \
 
 DIRS = adt cache error fmgr hash init misc mmgr sort time
 
+ifdef MB
+OBJS += mb/SUBSYS.o
+DIRS += mb
+endif
+
 SUBSYS.o: $(OBJS) 
        $(LD) -r -o SUBSYS.o $(OBJS)
 
index dc5cdabed6fe7ee9a26650fc7afb1181d6ebec89..0cfaff9edfb3d61f7044bcbc9bed982873b1e9d0 100644 (file)
@@ -21,7 +21,7 @@
 #include "postgres.h"                  /* postgres system include file */
 #include "utils/palloc.h"
 #include "utils/builtins.h"            /* where the function declarations go */
-#include "regex/pg_wchar.h"
+#include "mb/pg_wchar.h"
 
 static int     like(pg_wchar *text, pg_wchar *p);
 
@@ -111,7 +111,7 @@ textnlike(struct varlena * s, struct varlena * p)
 }
 
 
-/*     $Revision: 1.17 $
+/*     $Revision: 1.18 $
 **     "like.c" A first attempt at a LIKE operator for Postgres95.
 **
 **     Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.
index ce4631ce92b85a28fbf9ca53270d0d71b2509678..bb64722176e4b415667e2ed8600ce39ceb379134 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.36 1998/07/18 18:34:12 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.37 1998/07/24 03:31:42 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -21,7 +21,7 @@ char     *convertstr(char *, int, int);
 
 #endif
 
-#include "regex/pg_wchar.h"
+#include "mb/pg_wchar.h"
 
 /*
  * CHAR() and VARCHAR() types are part of the ANSI SQL standard. CHAR()
index 3308212a3a99f402aaaac3e9404be1623a949b55..f5c4fecba9d06790311f4ddaf6795da2892c7216 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.38 1998/07/18 18:34:13 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.39 1998/07/24 03:31:43 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 #include "utils/palloc.h"
 #include "utils/builtins.h"            /* where function declarations go */
 
-#include "regex/pg_wchar.h"
+#include "mb/pg_wchar.h"
 
 /*****************************************************************************
  *      USER I/O ROUTINES                                                                                                               *
index 46c267bbe534402ff2196a897724b50cd39cab8a..78eed2b19b9b6a6f9602d140c8dbbbf357bd6227 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for utils/cache
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.6 1998/04/06 00:26:33 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.7 1998/07/24 03:31:46 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,6 +12,9 @@ SRCDIR = ../../..
 include ../../../Makefile.global
 
 CFLAGS += -I../..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
 
 OBJS = catcache.o inval.o rel.o relcache.o syscache.o lsyscache.o fcache.o
 
index 943ec3d0a7b321dd5962e41b02d5a5e219a33a97..28af48dc90420c39d604697744222eb5def64b53 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.12 1998/06/15 19:29:39 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.13 1998/07/24 03:31:46 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "catalog/pg_type.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_language.h"
+#ifdef MB
+#include "catalog/pg_class_mb.h"
+#else
 #include "catalog/pg_class.h"
+#endif
 #include "parser/parsetree.h"  /* for getrelname() */
 #include "utils/builtins.h"
 #include "utils/fcache.h"
index 3196a12bf7d37862aaa65d69fd6af1656ac5ff8a..1f97949d3039888ac9301f4787d96ec9036e0dde 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.41 1998/07/20 16:14:16 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.42 1998/07/24 03:31:47 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "catalog/indexing.h"
 #include "catalog/pg_aggregate.h"
 #include "catalog/pg_attrdef.h"
+#ifdef MB
+#include "catalog/pg_attribute_mb.h"
+#else
 #include "catalog/pg_attribute.h"
+#endif
 #include "catalog/pg_index.h"
 #include "catalog/pg_proc.h"
 #include "catalog/pg_class.h"
index debf02991438e9a199737b8f43916bdfce15c841..c9d7826dce36f84e899779094749d5e7477c1be9 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for utils/init
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/init/Makefile,v 1.7 1998/04/06 00:27:07 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/init/Makefile,v 1.8 1998/07/24 03:31:49 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -12,6 +12,9 @@ SRCDIR = ../../..
 include ../../../Makefile.global
 
 CFLAGS += -I../..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
 
 OBJS = enbl.o findbe.o globals.o miscinit.o postinit.o
 
index da0f412feacc5e05973ee18c3595a50cc994b76f..a5d727b43843ceb9e40e8145ecdde80ef085b5ef 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.16 1998/06/27 04:53:47 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.17 1998/07/24 03:31:50 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -234,6 +234,18 @@ SetDatabaseName(char *name)
        strcpy(DatabaseName, name);
 }
 
+#ifndef MB
+/* even if MB is not enabled, this function is neccesary
+ * since pg_proc.h does have.
+ */
+const char *
+getdatabaseencoding()
+{
+  elog(ERROR, "you need to enable MB to use this function");
+  return("");
+}
+#endif
+
 #ifdef CYR_RECODE
 #define MAX_TOKEN      80
 
index 36de317266486e3c4fd22067fc8f35c016268bf4..57ce319e764ed1f72dddc9ea640806de9e92d9ba 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.30 1998/06/27 04:53:48 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.31 1998/07/24 03:31:50 scrappy Exp $
  *
  * NOTES
  *             InitPostgres() is the function called from PostgresMain
 #include "utils/inval.h"
 
 #include "catalog/catname.h"
+#ifdef MB
+#include "catalog/pg_database_mb.h"
+#include "mb/pg_wchar.h"
+#else
 #include "catalog/pg_database.h"
+#endif
 
 #include "libpq/libpq.h"
 
@@ -78,7 +83,11 @@ static void InitStdio(void);
 static void InitUserid(void);
 
 extern char *ExpandDatabasePath(char *name);
+#ifdef MB
+extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding);
+#else
 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
+#endif
 
 static IPCKey PostgresIpcKey;
 
@@ -119,9 +128,16 @@ InitMyDatabaseInfo(char *name)
        Oid                     owner;
        char       *path,
                                myPath[MAXPGPATH + 1];
+#ifdef MB
+       int encoding;
+#endif
 
        SetDatabaseName(name);
+#ifdef MB
+       GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath, &encoding);
+#else
        GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath);
+#endif
 
        if (!OidIsValid(MyDatabaseId))
                elog(FATAL,
@@ -131,6 +147,9 @@ InitMyDatabaseInfo(char *name)
 
        path = ExpandDatabasePath(myPath);
        SetDatabasePath(path);
+#ifdef MB
+       SetDatabaseEncoding(encoding);
+#endif
 
        return;
 }      /* InitMyDatabaseInfo() */
diff --git a/src/backend/utils/mb/Makefile b/src/backend/utils/mb/Makefile
new file mode 100644 (file)
index 0000000..9f501eb
--- /dev/null
@@ -0,0 +1,35 @@
+#-------------------------------------------------------------------------
+#
+# Makefile--
+#    Makefile for utils/mb
+#
+# IDENTIFICATION
+#    $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.1 1998/07/24 03:31:54 scrappy Exp $
+#
+#-------------------------------------------------------------------------
+
+SRCDIR = ../../..
+include ../../../Makefile.global
+
+CFLAGS += -I../..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
+
+OBJS = common.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o
+
+all: SUBSYS.o
+
+SUBSYS.o: $(OBJS)
+       $(LD) -r -o SUBSYS.o $(OBJS)
+
+depend dep:
+       $(CC) -MM $(CFLAGS) *.c >depend
+
+clean: 
+       rm -f SUBSYS.o $(OBJS)
+
+ifeq (depend,$(wildcard depend))
+include depend
+endif
+
diff --git a/src/backend/utils/mb/README b/src/backend/utils/mb/README
new file mode 100644 (file)
index 0000000..2ecfe21
--- /dev/null
@@ -0,0 +1,10 @@
+common.c:      public functions for both the backend and the frontend.
+               requires conv.c and wchar.c
+conv.c:                static functions and a public table for code conversion
+wchar.c:       mostly static functions and a public table for mb string and
+               multi-byte conversion
+mbutilc.c:     public functions for the backend only.
+               requires conv.c and wchar.c
+wstrcmp.c:     strcmp for mb
+wstrncmp.c:    strncmp for mb
+varable.c:     public functions for show/set/reset variable commands
diff --git a/src/backend/utils/mb/common.c b/src/backend/utils/mb/common.c
new file mode 100644 (file)
index 0000000..c4e796e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * This file contains some public functions
+ * usable for both the backend and the frontend.
+ * Tatsuo Ishii
+ * $Id: common.c,v 1.1 1998/07/24 03:31:56 scrappy Exp $ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "mb/pg_wchar.h"
+
+/*
+ * convert encoding char to encoding symbol value.
+ * case is ignored.
+ * if there's no valid encoding, returns -1
+ */
+int pg_char_to_encoding(const char *s)
+{
+  pg_encoding_conv_tbl *p = pg_conv_tbl;
+
+  for(;p->encoding >= 0;p++) {
+    if (!strcasecmp(s, p->name)) {
+      break;
+    }
+  }
+  return(p->encoding);
+}
+
+/*
+ * check to see if encoding name is valid
+ */
+int pg_valid_client_encoding(const char *name)
+{
+  return(pg_char_to_encoding(name));
+}
+
+/*
+ * find encoding table entry by encoding
+ */
+pg_encoding_conv_tbl *pg_get_encent_by_encoding(int encoding)
+{
+  pg_encoding_conv_tbl *p = pg_conv_tbl;
+  for(;p->encoding >= 0;p++) {
+    if (p->encoding == encoding) {
+      return(p);
+    }
+  }
+  return(0);
+}
+
+/*
+ * convert encoding symbol to encoding char.
+ * if there's no valid encoding symbol, returns ""
+ */
+const char *pg_encoding_to_char(int encoding)
+{
+  pg_encoding_conv_tbl *p = pg_get_encent_by_encoding(encoding);
+
+  if (!p) return("");
+  return(p->name);
+}
+
+/* returns the byte length of a multi-byte word for an encoding */
+int pg_encoding_mblen(int encoding, const unsigned char *mbstr)
+{
+  return((*pg_wchar_table[encoding].mblen)(mbstr));
+}
similarity index 60%
rename from src/backend/commands/mbutils.c
rename to src/backend/utils/mb/conv.c
index 86c72dfc265a8abdd984c7b4864d3c60066b02f4..bca95c5f6b6a26bafbfef225aca98185355adfdf 100644 (file)
@@ -2,18 +2,13 @@
  * conversion between client encoding and server internal encoding
  * (currently mule internal code (mic) is used)
  * Tatsuo Ishii
- * $Id: mbutils.c,v 1.2 1998/07/18 18:34:01 momjian Exp $
+ * $Id: conv.c,v 1.1 1998/07/24 03:31:56 scrappy Exp $
  */
 #include <stdio.h>
 #include <string.h>
 
-#include "postgres.h"
-#include "miscadmin.h"
-#include "regex/pg_wchar.h"
-#include "commands/variable.h"
+#include "mb/pg_wchar.h"
 
-static int client_encoding = MULTIBYTE;        /* defalut client encoding is set to
-                                          same as the server encoding */
 /*
  * convert bogus chars that cannot be represented in the current encoding
  * system.
@@ -296,15 +291,15 @@ static void mic2euc_tw(unsigned char *mic, unsigned char *p, int len)
 }
 
 /*
- * LATIN1 ---> MIC
+ * LATINn ---> MIC
  */
-static void latin12mic(unsigned char *l, unsigned char *p, int len)
+static void latin2mic(unsigned char *l, unsigned char *p, int len, int lc)
 {
   int c1;
 
   while (len-- > 0 && (c1 = *l++)) {
     if (c1 > 0x7f) {   /* Latin1? */
-      *p++ = LC_ISO8859_1;
+      *p++ = lc;
     }
     *p++ = c1;
   }
@@ -312,16 +307,16 @@ static void latin12mic(unsigned char *l, unsigned char *p, int len)
 }
 
 /*
- * MIC ---> LATIN1
+ * MIC ---> LATINn
  */
-static void mic2latin1(unsigned char *mic, unsigned char *p, int len)
+static void mic2latin(unsigned char *mic, unsigned char *p, int len, int lc)
 {
   int c1;
 
   while (len > 0 && (c1 = *mic)) {
     len -= pg_mic_mblen(mic++);
 
-    if (c1 == LC_ISO8859_1) {
+    if (c1 == lc) {
       *p++ = *mic++;
     } else if (c1 > 0x7f) {
       mic--;
@@ -333,195 +328,59 @@ static void mic2latin1(unsigned char *mic, unsigned char *p, int len)
   *p = '\0';
 }
 
-typedef struct {
-  int encoding;                /* encoding symbol value */
-  char *name;          /* encoding name */
-  int is_client_only;  /* 0: server/client bothg supported
-                          1: client only */
-  void (*to_mic)();    /* client encoding to MIC */
-  void (*from_mic)();  /* MIC to client encoding */
-} pg_encoding_conv_tbl;
-
-static pg_encoding_conv_tbl conv_tbl[] = {
-  {EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp},       /* EUC_JP */
-  {EUC_CN, "EUC_CN", 0, euc_cn2mic, mic2euc_cn},       /* EUC_CN */
-  {EUC_KR, "EUC_KR", 0, euc_kr2mic, mic2euc_kr},       /* EUC_KR */
-  {EUC_TW, "EUC_TW", 0, euc_tw2mic, mic2euc_tw},       /* EUC_TW */
-  {UNICODE, "UNICODE", 0, 0, 0},                       /* UNICODE */
-  {MULE_INTERNAL, "MULE_INTERNAL", 0, 0, 0},           /* MULE_INTERNAL */
-  {LATIN1, "LATIN1", 0, latin12mic, mic2latin1},       /* ISO 8859 Latin 1 */
-  {SJIS, "SJIS", 1, sjis2mic, mic2sjis},               /* SJIS */
-  {-1, "", 0, 0, 0}                                    /* end mark */
-};
-
-/*
- * find encoding table entry by encoding
- */
-static pg_encoding_conv_tbl *get_enc_ent(int encoding)
+static void latin12mic(unsigned char *l, unsigned char *p, int len)
 {
-  pg_encoding_conv_tbl *p = conv_tbl;
-  for(;p->encoding >= 0;p++) {
-    if (p->encoding == encoding) {
-      return(p);
-    }
-  }
-  return(0);
+  latin2mic(l, p, len, LC_ISO8859_1);
 }
-
-void (*client_to_mic)();       /* something to MIC */
-void (*client_from_mic)();     /* MIC to something */
-void (*server_to_mic)();       /* something to MIC */
-void (*server_from_mic)();     /* MIC to something */
-
-/*
- * set the client encoding. if client/server encoding is
- * not supported, returns -1
- */
-int pg_set_client_encoding(int encoding)
+static void mic2latin1(unsigned char *mic, unsigned char *p, int len)
 {
-  client_encoding = encoding;
-
-  if (client_encoding == MULTIBYTE) {  /* server == client? */
-    client_to_mic = client_from_mic = 0;
-    server_to_mic = server_from_mic = 0;
-  } else if (MULTIBYTE == MULE_INTERNAL) {     /* server == MULE_INETRNAL? */
-    client_to_mic = get_enc_ent(encoding)->to_mic;
-    client_from_mic = get_enc_ent(encoding)->from_mic;
-    server_to_mic = server_from_mic = 0;
-    if (client_to_mic == 0 || client_from_mic == 0) {
-      return(-1);
-    }
-  } else if (encoding == MULE_INTERNAL) {      /* client == MULE_INETRNAL? */
-    client_to_mic = client_from_mic = 0;
-    server_to_mic = get_enc_ent(MULTIBYTE)->to_mic;
-    server_from_mic = get_enc_ent(MULTIBYTE)->from_mic;
-    if (server_to_mic == 0 || server_from_mic == 0) {
-      return(-1);
-    }
-  } else {
-    client_to_mic = get_enc_ent(encoding)->to_mic;
-    client_from_mic = get_enc_ent(encoding)->from_mic;
-    server_to_mic = get_enc_ent(MULTIBYTE)->to_mic;
-    server_from_mic = get_enc_ent(MULTIBYTE)->from_mic;
-    if (client_to_mic == 0 || client_from_mic == 0) {
-      return(-1);
-    }
-    if (server_to_mic == 0 || server_from_mic == 0) {
-      return(-1);
-    }
-  }
-  return(0);
+  mic2latin(mic, p, len, LC_ISO8859_1);
 }
-
-/*
- * returns the current client encoding
- */
-int pg_get_client_encoding()
+static void latin22mic(unsigned char *l, unsigned char *p, int len)
 {
-  return(client_encoding);
+  latin2mic(l, p, len, LC_ISO8859_2);
 }
-
-/*
- * convert client encoding to server encoding
- */
-unsigned char *pg_client_to_server(unsigned char *s, int len)
+static void mic2latin2(unsigned char *mic, unsigned char *p, int len)
 {
-  static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
-  static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
-  unsigned char *p;
-
-  if (client_to_mic) {
-    (*client_to_mic)(s, b1, len);
-    len = strlen(b1);
-    p = b1;
-  } else {
-    p = s;
-  }
-  if (server_from_mic) {
-    (*server_from_mic)(p, b2, len);
-    p = b2;
-  }
-  return(p);
+  mic2latin(mic, p, len, LC_ISO8859_2);
 }
-
-/*
- * convert server encoding to client encoding
- */
-unsigned char *pg_server_to_client(unsigned char *s, int len)
+static void latin32mic(unsigned char *l, unsigned char *p, int len)
 {
-  static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
-  static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
-  unsigned char *p;
-
-  if (server_to_mic) {
-    (*server_to_mic)(s, b1, len);
-    len = strlen(b1);
-    p = b1;
-  } else {
-    p = s;
-  }
-  if (client_from_mic) {
-    (*client_from_mic)(p, b2, len);
-    p = b2;
-  }
-  return(p);
+  latin2mic(l, p, len, LC_ISO8859_3);
 }
-
-/*
- * convert encoding char to encoding symbol value.
- * case is ignored.
- * if there's no valid encoding, returns -1
- */
-int pg_char_to_encoding(const char *s)
+static void mic2latin3(unsigned char *mic, unsigned char *p, int len)
 {
-  pg_encoding_conv_tbl *p = conv_tbl;
-
-  for(;p->encoding >= 0;p++) {
-    if (!strcasecmp(s, p->name)) {
-      break;
-    }
-  }
-  return(p->encoding);
+  mic2latin(mic, p, len, LC_ISO8859_3);
 }
-
-/*
- * check to see if encoding name is valid
- */
-int pg_valid_client_encoding(const char *name)
+static void latin42mic(unsigned char *l, unsigned char *p, int len)
 {
-  return(pg_char_to_encoding(name));
+  latin2mic(l, p, len, LC_ISO8859_4);
 }
-
-/*
- * convert encoding symbol to encoding char.
- * if there's no valid encoding symbol, returns ""
- */
-const char *pg_encoding_to_char(int encoding)
+static void mic2latin4(unsigned char *mic, unsigned char *p, int len)
 {
-  pg_encoding_conv_tbl *p = get_enc_ent(encoding);
-
-  if (!p) return("");
-  return(p->name);
+  mic2latin(mic, p, len, LC_ISO8859_4);
 }
-
-#ifdef MULTIBYTEUTILSDEBUG
-#include <stdio.h>
-
-main()
+static void latin52mic(unsigned char *l, unsigned char *p, int len)
 {
-  unsigned char sbuf[2048],ebuf[2048];
-  unsigned char *p = sbuf;
-
-  int c;
-  while ((c = getchar()) != EOF) {
-    *p++ = c;
-  }
-  *p = '\0';
-
-  /*
-  mic2sjis(sbuf,ebuf,2048);
-  */
-  euc_jp2mic(sbuf,ebuf,2048);
-  printf("%s",ebuf);
+  latin2mic(l, p, len, LC_ISO8859_5);
 }
-#endif
+static void mic2latin5(unsigned char *mic, unsigned char *p, int len)
+{
+  mic2latin(mic, p, len, LC_ISO8859_5);
+}
+
+pg_encoding_conv_tbl pg_conv_tbl[] = {
+  {EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp},       /* EUC_JP */
+  {EUC_CN, "EUC_CN", 0, euc_cn2mic, mic2euc_cn},       /* EUC_CN */
+  {EUC_KR, "EUC_KR", 0, euc_kr2mic, mic2euc_kr},       /* EUC_KR */
+  {EUC_TW, "EUC_TW", 0, euc_tw2mic, mic2euc_tw},       /* EUC_TW */
+  {UNICODE, "UNICODE", 0, 0, 0},                       /* UNICODE */
+  {MULE_INTERNAL, "MULE_INTERNAL", 0, 0, 0},           /* MULE_INTERNAL */
+  {LATIN1, "LATIN1", 0, latin12mic, mic2latin1},       /* ISO 8859 Latin 1 */
+  {LATIN2, "LATIN2", 0, latin22mic, mic2latin2},       /* ISO 8859 Latin 2 */
+  {LATIN3, "LATIN3", 0, latin32mic, mic2latin3},       /* ISO 8859 Latin 3 */
+  {LATIN4, "LATIN4", 0, latin42mic, mic2latin4},       /* ISO 8859 Latin 4 */
+  {LATIN5, "LATIN5", 0, latin52mic, mic2latin5},       /* ISO 8859 Latin 5 */
+  {SJIS, "SJIS", 1, sjis2mic, mic2sjis},               /* SJIS */
+  {-1, "", 0, 0, 0}                                    /* end mark */
+};
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
new file mode 100644 (file)
index 0000000..eb6cbc5
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * This file contains public functions for conversion between
+ * client encoding and server internal encoding.
+ * (currently mule internal code (mic) is used)
+ * Tatsuo Ishii
+ * $Id: mbutils.c,v 1.1 1998/07/24 03:31:56 scrappy Exp $ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "mb/pg_wchar.h"
+
+static client_encoding = -1;
+static void (*client_to_mic)();        /* something to MIC */
+static void (*client_from_mic)();      /* MIC to something */
+static void (*server_to_mic)();        /* something to MIC */
+static void (*server_from_mic)();      /* MIC to something */
+
+/*
+ * find encoding table entry by encoding
+ */
+static pg_encoding_conv_tbl *get_enc_ent(int encoding)
+{
+  pg_encoding_conv_tbl *p = pg_conv_tbl;
+  for(;p->encoding >= 0;p++) {
+    if (p->encoding == encoding) {
+      return(p);
+    }
+  }
+  return(0);
+}
+
+/*
+ * set the client encoding. if client/server encoding is
+ * not supported, returns -1
+ */
+int pg_set_client_encoding(int encoding)
+{
+  int current_server_encoding = GetDatabaseEncoding();
+
+  client_encoding = encoding;
+
+  if (client_encoding == current_server_encoding) {    /* server == client? */
+    client_to_mic = client_from_mic = 0;
+    server_to_mic = server_from_mic = 0;
+  } else if (current_server_encoding == MULE_INTERNAL) {       /* server == MULE_INETRNAL? */
+    client_to_mic = get_enc_ent(encoding)->to_mic;
+    client_from_mic = get_enc_ent(encoding)->from_mic;
+    server_to_mic = server_from_mic = 0;
+    if (client_to_mic == 0 || client_from_mic == 0) {
+      return(-1);
+    }
+  } else if (encoding == MULE_INTERNAL) {      /* client == MULE_INETRNAL? */
+    client_to_mic = client_from_mic = 0;
+    server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
+    server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
+    if (server_to_mic == 0 || server_from_mic == 0) {
+      return(-1);
+    }
+  } else {
+    client_to_mic = get_enc_ent(encoding)->to_mic;
+    client_from_mic = get_enc_ent(encoding)->from_mic;
+    server_to_mic = get_enc_ent(current_server_encoding)->to_mic;
+    server_from_mic = get_enc_ent(current_server_encoding)->from_mic;
+    if (client_to_mic == 0 || client_from_mic == 0) {
+      return(-1);
+    }
+    if (server_to_mic == 0 || server_from_mic == 0) {
+      return(-1);
+    }
+  }
+  return(0);
+}
+
+/*
+ * returns the current client encoding
+ */
+int pg_get_client_encoding()
+{
+  if (client_encoding == -1) {
+    /* this is the first time */
+    client_encoding = GetDatabaseEncoding();
+  }
+  return(client_encoding);
+}
+
+/*
+ * convert client encoding to server encoding. if server_encoding ==
+ * client_encoding or no conversion function exists,
+ * returns s. So be careful.
+ */
+unsigned char *pg_client_to_server(unsigned char *s, int len)
+{
+  static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
+  static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
+  unsigned char *p = s;
+
+  if (client_encoding == GetDatabaseEncoding()) {
+    return(p);
+  }
+  if (client_to_mic) {
+    (*client_to_mic)(s, b1, len);
+    len = strlen(b1);
+    p = b1;
+  }
+  if (server_from_mic) {
+    (*server_from_mic)(p, b2, len);
+    p = b2;
+  }
+  return(p);
+}
+
+/*
+ * convert server encoding to client encoding. if server_encoding ==
+ * client_encoding or no conversion function exists,
+ * returns s. So be careful.
+ */
+unsigned char *pg_server_to_client(unsigned char *s, int len)
+{
+  static unsigned char b1[MAX_PARSE_BUFFER*4]; /* is this enough? */
+  static unsigned char b2[MAX_PARSE_BUFFER*4]; /* is this enough? */
+  unsigned char *p = s;
+
+  if (client_encoding == GetDatabaseEncoding()) {
+    return(p);
+  }
+  if (server_to_mic) {
+    (*server_to_mic)(s, b1, len);
+    len = strlen(b1);
+    p = b1;
+  }
+  if (client_from_mic) {
+    (*client_from_mic)(p, b2, len);
+    p = b2;
+  }
+  return(p);
+}
+
+/* convert a multi-byte string to a wchar */
+void pg_mb2wchar(const unsigned char *from, pg_wchar *to)
+{
+  (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len)(from,to,strlen(from));
+}
+
+/* convert a multi-byte string to a wchar with a limited length */
+void pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
+{
+  (*pg_wchar_table[GetDatabaseEncoding()].mb2wchar_with_len)(from,to,len);
+}
+
+/* returns the byte length of a multi-byte word */
+int pg_mblen(const unsigned char *mbstr)
+{
+  return((*pg_wchar_table[GetDatabaseEncoding()].mblen)(mbstr));
+}
+
+/* returns the length (counted as a wchar) of a multi-byte string */
+int pg_mbstrlen(const unsigned char *mbstr)
+{
+  int len = 0;
+  while (*mbstr) {
+    mbstr += pg_mblen(mbstr);
+    len++;
+  }
+  return(len);
+}
+
+/* returns the length (counted as a wchar) of a multi-byte string 
+   (not necessarily  NULL terminated) */
+int pg_mbstrlen_with_len(const unsigned char *mbstr, int limit)
+{
+  int len = 0;
+  int l;
+  while (*mbstr && limit > 0) {
+    l = pg_mblen(mbstr);
+    limit -= l;
+    mbstr += l;
+    len++;
+  }
+  return(len);
+}
+
+/*
+ * fuctions for utils/init
+ */
+static int DatabaseEncoding = MB;
+void
+SetDatabaseEncoding(int encoding)
+{
+  DatabaseEncoding = encoding;
+}
+
+int
+GetDatabaseEncoding()
+{
+  return(DatabaseEncoding);
+}
+
+/* for builtin-function */
+const char *
+getdatabaseencoding()
+{
+  return(pg_encoding_to_char(DatabaseEncoding));
+}
+
+/* set and get template1 database encoding */
+static int templateEncoding;
+void SetTemplateEncoding(int encoding)
+{
+  templateEncoding = encoding;
+}
+
+int GetTemplateEncoding()
+{
+  return(templateEncoding);
+}
similarity index 92%
rename from src/backend/regex/utftest.c
rename to src/backend/utils/mb/utftest.c
index 28baf7255ef6a7ec2db85e7ee9581944ecc83480..e49f8d77949acce1b160f872c4dc80ea9ef72213 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * testing of utf2wchar()
- * $Id: utftest.c,v 1.1 1998/03/15 07:38:37 scrappy Exp $
+ * $Id: utftest.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
  */
 #include <regex/regex.h>
 #include <regex/utils.h>
diff --git a/src/backend/utils/mb/variable.c b/src/backend/utils/mb/variable.c
new file mode 100644 (file)
index 0000000..12cc23d
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * This file contains some public functions
+ * related to show/set/reset variable commands.
+ * Tatsuo Ishii
+ * $Id: variable.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
+ */
+
+#include "mb/pg_wchar.h"
+
+bool
+parse_client_encoding(const char *value)
+{
+  int encoding;
+
+  encoding = pg_valid_client_encoding(value);
+  if (encoding < 0) {
+    elog(ERROR, "Client encoding %s is not supported", value);
+  } else {    
+    if (pg_set_client_encoding(encoding)) {
+      elog(ERROR, "Conversion between %s and %s is not supported",
+          value, pg_encoding_to_char(GetDatabaseEncoding()));
+    }
+  }
+  return TRUE;
+}
+
+bool
+show_client_encoding()
+{
+  elog(NOTICE, "Current client encoding is %s",
+       pg_encoding_to_char(pg_get_client_encoding()));
+  return TRUE;
+}
+
+bool
+reset_client_encoding()
+{
+  int encoding;
+  char *env = getenv("PGCLIENTENCODING");
+
+  if (env) {
+    encoding = pg_char_to_encoding(env);
+    if (encoding < 0) {
+      encoding = GetDatabaseEncoding();
+    }
+  } else {
+    encoding = GetDatabaseEncoding();
+  }
+  pg_set_client_encoding(encoding);
+  return TRUE;
+}
+
+bool
+parse_server_encoding(const char *value)
+{
+  elog(NOTICE, "SET SERVER_ENCODING is not supported");
+  return TRUE;
+}
+
+bool
+show_server_encoding()
+{
+  elog(NOTICE, "Current server encoding is %s",
+       pg_encoding_to_char(GetDatabaseEncoding()));
+  return TRUE;
+}
+
+bool
+reset_server_encoding()
+{
+  elog(NOTICE, "RESET SERVER_ENCODING is not supported");
+  return TRUE;
+}
similarity index 76%
rename from src/backend/regex/utils.c
rename to src/backend/utils/mb/wchar.c
index 0f8844f41e311eca6830001dd25e2e3b519fff77..ecb7b5435941c14afbbf341dc78d7cb5921db042 100644 (file)
@@ -1,9 +1,10 @@
 /*
- * misc conversion functions between pg_wchar and other encodings.
+ * conversion functions between pg_wchar and multi-byte streams.
  * Tatsuo Ishii
- * $Id: utils.c,v 1.4 1998/07/18 18:34:08 momjian Exp $
+ * $Id: wchar.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
  */
-#include <regex/pg_wchar.h>
+
+#include "mb/pg_wchar.h"
 
 /*
  * conversion to pg_wchar is done by "table driven."
  * supported in the client, you don't need to define 
  * mb2wchar_with_len() function (SJIS is the case).
  */
-typedef struct {
-  void (*mb2wchar_with_len)(); /* convert a multi-byte string to a wchar */
-  int  (*mblen)();             /* returns the length of a multi-byte word */
-} pg_wchar_tbl;
-
 static void pg_euc2wchar_with_len
 (const unsigned char *from, pg_wchar *to, int len)
 {
@@ -268,7 +264,7 @@ static void pg_mule2wchar_with_len(const unsigned char *from, pg_wchar *to, int
   *to = 0;
 }
 
-static int pg_mule_mblen(const unsigned char *s)
+int pg_mule_mblen(const unsigned char *s)
 {
   int len;
 
@@ -319,7 +315,7 @@ static int pg_sjis_mblen(const unsigned char *s)
   return(len);
 }
 
-static pg_wchar_tbl pg_wchar_table[] = {
+pg_wchar_tbl pg_wchar_table[] = {
   {pg_eucjp2wchar_with_len, pg_eucjp_mblen},
   {pg_euccn2wchar_with_len, pg_euccn_mblen},
   {pg_euckr2wchar_with_len, pg_euckr_mblen},
@@ -327,6 +323,22 @@ static pg_wchar_tbl pg_wchar_table[] = {
   {pg_utf2wchar_with_len, pg_utf_mblen},
   {pg_mule2wchar_with_len, pg_mule_mblen},
   {pg_latin12wchar_with_len, pg_latin1_mblen},
+  {pg_latin12wchar_with_len, pg_latin1_mblen},
+  {pg_latin12wchar_with_len, pg_latin1_mblen},
+  {pg_latin12wchar_with_len, pg_latin1_mblen},
+  {pg_latin12wchar_with_len, pg_latin1_mblen},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
+  {0, 0},
   {0, 0},
   {0, 0},
   {0, 0},
@@ -339,66 +351,8 @@ static pg_wchar_tbl pg_wchar_table[] = {
   {0, pg_sjis_mblen}
 };
 
-/*
- *########################################################################
- *
- * Public functions
- *
- *########################################################################
- */
-
-/* convert a multi-byte string to a wchar */
-void pg_mb2wchar(const unsigned char *from, pg_wchar *to)
-{
-  (*pg_wchar_table[MULTIBYTE].mb2wchar_with_len)(from,to,strlen(from));
-}
-
-/* convert a multi-byte string to a wchar with a limited length */
-void pg_mb2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
-{
-  (*pg_wchar_table[MULTIBYTE].mb2wchar_with_len)(from,to,len);
-}
-
-/* returns the byte length of a multi-byte word */
-int pg_mblen(const unsigned char *mbstr)
-{
-  return((*pg_wchar_table[MULTIBYTE].mblen)(mbstr));
-}
-
-/* returns the byte length of a multi-byte word for an encoding */
-int pg_encoding_mblen(int encoding, const unsigned char *mbstr)
-{
-  return((*pg_wchar_table[encoding].mblen)(mbstr));
-}
-
 /* returns the byte length of a word for mule internal code */
 int pg_mic_mblen(const unsigned char *mbstr)
 {
   return(pg_mule_mblen(mbstr));
 }
-
-/* returns the length (counted as a wchar) of a multi-byte string */
-int pg_mbstrlen(const unsigned char *mbstr)
-{
-  int len = 0;
-  while (*mbstr) {
-    mbstr += pg_mblen(mbstr);
-    len++;
-  }
-  return(len);
-}
-
-/* returns the length (counted as a wchar) of a multi-byte string 
-   (not necessarily  NULL terminated) */
-int pg_mbstrlen_with_len(const unsigned char *mbstr, int limit)
-{
-  int len = 0;
-  int l;
-  while (*mbstr && limit > 0) {
-    l = pg_mblen(mbstr);
-    limit -= l;
-    mbstr += l;
-    len++;
-  }
-  return(len);
-}
similarity index 98%
rename from src/backend/regex/wstrcmp.c
rename to src/backend/utils/mb/wstrcmp.c
index b562f103150eb3922132daad471e4ffcb39d1776..e1ff89d3c04e066a889111382fa178e4859c81ce 100644 (file)
@@ -34,7 +34,7 @@
  * SUCH DAMAGE.
  */
 
-#include <regex/pg_wchar.h>
+#include <mb/pg_wchar.h>
 
 int
 pg_char_and_wchar_strcmp(s1, s2)
similarity index 98%
rename from src/backend/regex/wstrncmp.c
rename to src/backend/utils/mb/wstrncmp.c
index e7ce52ed7b2ae0c061347d8c1448cd9027bd2b37..6c42a7604d8204ca9b87dd0e3d4134293e65595b 100644 (file)
@@ -33,7 +33,7 @@
  * SUCH DAMAGE.
  */
 
-#include <regex/pg_wchar.h>
+#include <mb/pg_wchar.h>
 
 int
 pg_wchar_strncmp(s1, s2, n)
index a827137ed007725422f5a1a58abe33b819963b7e..b6993d1108a72e32bfbd93dc43aa27026a200c94 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for utils/misc
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/utils/misc/Makefile,v 1.6 1998/04/06 00:27:16 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/utils/misc/Makefile,v 1.7 1998/07/24 03:31:58 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,6 +13,10 @@ include ../../../Makefile.global
 
 CFLAGS += -I../..
 
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
+
 OBJS = database.o superuser.o 
 
 all: SUBSYS.o
index 9c9a0a63fa8b0f5be80d3ee9cba90400d8aa061c..6a106b9ad1213723de7f22bb70ed0a047097d255 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.11 1998/07/20 16:14:18 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.12 1998/07/24 03:31:59 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "access/heapam.h"
 #include "access/xact.h"
 #include "catalog/catname.h"
+#ifdef MB
+#include "catalog/pg_database_mb.h"
+#include "mb/pg_wchar.h"
+#else
 #include "catalog/pg_database.h"
+#endif
 #include "fmgr.h"
 #include "miscadmin.h"
 #include "storage/bufmgr.h"
@@ -179,7 +184,11 @@ ExpandDatabasePath(char *dbpath)
  * --------------------------------
  */
 void
+#ifdef MB
+GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding)
+#else
 GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path)
+#endif
 {
        int                     dbfd;
        int                     fileflags;
@@ -273,7 +282,9 @@ GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path)
                                strncpy(path, VARDATA(&(tup_db->datpath)),
                                                (VARSIZE(&(tup_db->datpath)) - VARHDRSZ));
                                *(path + VARSIZE(&(tup_db->datpath)) - VARHDRSZ) = '\0';
-
+#ifdef MB
+                               *encoding = tup_db->encoding;
+#endif
                                goto done;
                        }
                }
index 4511dc9d16f9a0585518c2fd248b3d7252674aa3..ceb610359a52662c013b4251bb37677642d34e80 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.13 1998/04/06 03:23:01 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/Makefile,v 1.14 1998/07/24 03:32:02 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,6 +17,10 @@ include ../Makefile.global
 DIRS = pg_id pg_version psql pg_dump pg_passwd cleardbdir createdb \
        createuser destroydb destroyuser initdb initlocation ipcclean
 
+ifdef MB
+DIRS += pg_encoding
+endif
+
 #
 # TCL/TK programs
 #
index 5b5fa2dfdf4cf264a787a7991c9fa77c9d509461..896fe33d92d29f49dd4e9a5a9b24cef98609c304 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/createdb/Attic/Makefile,v 1.8 1998/04/06 16:49:28 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/createdb/Attic/Makefile,v 1.9 1998/07/24 03:32:04 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -17,7 +17,7 @@ include ../../Makefile.global
 all: createdb
 
 createdb: createdb.sh
-       cp createdb.sh createdb
+       sed 's/__MB__/$(MB)/' createdb.sh > createdb
 
 install: createdb
        $(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
index 6fee8f2839229b16995ee5d54e8215573a8e5529..2217f19714a32708ab3bc941626f2ec5b4d5c8ac 100644 (file)
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.8 1998/01/29 02:26:21 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.9 1998/07/24 03:32:06 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
 CMDNAME=`basename $0`
 
+MBENABLED=__MB__
+MB=
+
 if [ -z "$USER" ]; then
        if [ -z "$LOGNAME" ]; then
                if [ -z "`whoami`" ]; then
@@ -43,6 +46,18 @@ do
                -p) PGPORT=$2; shift;;
                -u) PASSWDOPT=$1;;
                -D) dbpath=$2; shift;;
+               -E)
+                       if [ -z "$MBENABLED" ];then
+                               echo "$CMDNAME: you need to turn on MB compile time option"
+                               exit 1
+                       fi
+                       MB=$2
+                       MBID=`pg_encoding $MB`
+                       if [ -z "$MBID" ];then
+                               echo "$CMDNAME: $MB is not a valid encoding name"
+                               exit 1
+                       fi
+                       shift;;
                -*) echo "$CMDNAME: unrecognized parameter $1"; usage=1;;
                 *) dbname=$1;;
        esac
@@ -50,8 +65,12 @@ do
 done
 
 if [ "$usage" ]; then
-       echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> [dbname]"
+       if [ -z "$MBENABLED" ];then
+               echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> [dbname]"
+       else
+               echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> -E <encoding> [dbname]"
        exit 1
+       fi
 fi
 
 if [ -z "$AUTHSYS" ]; then
@@ -82,8 +101,16 @@ else
 #      fi
        location="with location = '$dbpath'"
 fi
+if [ -z "$MBENABLED" -o -z "$MB" ]; then
+       encoding=""
+else
+       encoding="encoding = '$MB'"
+       if [ -z "$location" ];then
+               encoding="with $encoding"
+       fi
+fi
 
-psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create database $dbname $location" template1
+psql $PASSWDOPT -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create database $dbname $location $encoding" template1
 
 if [ $? -ne 0 ]; then
        echo "$CMDNAME: database creation failed on $dbname."
index 59000129c22e6b6254fc5202666e8756b1d09788..e46e3af841e925cfb96bb56e1054224f3306b353 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.9 1998/04/06 16:50:22 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/bin/initdb/Makefile,v 1.10 1998/07/24 03:32:08 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -16,9 +16,13 @@ include ../../Makefile.global
 
 all: initdb
 
+initdb: initdb.sh
+       sed 's/__MB__/$(MB)/' initdb.sh > initdb
+
 install: initdb
        $(INSTALL) $(INSTL_EXE_OPTS) $< $(BINDIR)/$<
 
 clean:
+       rm -f initdb
 
 dep depend:
diff --git a/src/bin/initdb/initdb b/src/bin/initdb/initdb
deleted file mode 100644 (file)
index bec8f5e..0000000
+++ /dev/null
@@ -1,383 +0,0 @@
-#!/bin/sh
-#-------------------------------------------------------------------------
-#
-# initdb.sh--
-#     Create (initialize) a Postgres database system.  
-# 
-#     A database system is a collection of Postgres databases all managed
-#     by the same postmaster.  
-#
-#     To create the database system, we create the directory that contains
-#     all its data, create the files that hold the global classes, create
-#     a few other control files for it, and create one database:  the
-#     template database.
-#
-#     The template database is an ordinary Postgres database.  Its data
-#     never changes, though.  It exists to make it easy for Postgres to 
-#     create other databases -- it just copies.
-#
-#     Optionally, we can skip creating the database system and just create
-#     (or replace) the template database.
-#
-#     To create all those classes, we run the postgres (backend) program and
-#     feed it data from bki files that are in the Postgres library directory.
-#
-# Copyright (c) 1994, Regents of the University of California
-#
-#
-# IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb,v 1.1 1998/04/06 01:05:52 momjian Exp $
-#
-#-------------------------------------------------------------------------
-
-# ----------------
-#       The _fUnKy_..._sTuFf_ gets set when the script is built (with make)
-#       from parameters set in the make file.
-#
-# ----------------
-
-CMDNAME=`basename $0`
-
-# Find the default PGLIB directory (the directory that contains miscellaneous 
-# files that are part of Postgres).  The user-written program postconfig
-# outputs variable settings like "PGLIB=/usr/lib/whatever".  If it doesn't
-# output a PGLIB value, then there is no default and the user must
-# specify the pglib option.  Postconfig may validly not exist, in which case
-# our invocation of it silently fails.
-
-# The 2>/dev/null is to swallow the "postconfig: not found" message if there
-# is no postconfig.
-
-postconfig_result="`sh -c postconfig 2>/dev/null`"
-if [ ! -z "$postconfig_result" ]; then
-  set -a   # Make the following variable assignment exported to environment
-  eval "$postconfig_result"
-  set +a   # back to normal
-fi
-
-# Set defaults:
-debug=0
-noclean=0
-template_only=0
-POSTGRES_SUPERUSERNAME=$USER
-
-while [ "$#" -gt 0 ]
-do
-# ${ARG#--username=} is not reliable or available on all platforms
-
-    case "$1" in
-        --debug|-d)
-                debug=1
-                echo "Running with debug mode on."
-                ;;
-        --noclean|-n)
-                noclean=1
-                echo "Running with noclean mode on. "
-                     "Mistakes will not be cleaned up."
-                ;;
-        --template|-t)
-                template_only=1
-                echo "updating template1 database only."
-                ;;
-        --username=*)
-                POSTGRES_SUPERUSERNAME="`echo $1 | sed 's/^--username=//'`"
-                ;;
-        -u)
-                shift
-                POSTGRES_SUPERUSERNAME="$1"
-                ;;
-        -u*)
-                POSTGRES_SUPERUSERNAME="`echo $1 | sed 's/^-u//'`"
-                ;;
-        --pgdata=*)
-                PGDATA="`echo $1 | sed 's/^--pgdata=//'`"
-                ;;
-        -r)
-                shift
-                PGDATA="$1"
-                ;;
-        -r*)
-                PGDATA="`echo $1 | sed 's/^-r//'`"
-                ;;
-        --pglib=*)
-                PGLIB="`echo $1 | sed 's/^--pglib=//'`"
-                ;;
-        -l)
-                shift
-                PGLIB="$1"
-                ;;
-        -l*)
-                PGLIB="`echo $1 | sed 's/^-l//'`"
-                ;;
-
-        *)
-                echo "Unrecognized option '$1'.  Syntax is:"
-                echo "initdb [-t | --template] [-d | --debug]" \
-                     "[-n | --noclean]" \
-                     "[-u SUPERUSER | --username=SUPERUSER]" \
-                     "[-r DATADIR | --pgdata=DATADIR]" \
-                     "[-l LIBDIR | --pglib=LIBDIR]"
-                exit 100
-        esac
-        shift
-done
-
-#-------------------------------------------------------------------------
-# Make sure he told us where to find the Postgres files.
-#-------------------------------------------------------------------------
-if [ -z "$PGLIB" ]; then
-    echo "$CMDNAME does not know where to find the files that make up "
-    echo "Postgres (the PGLIB directory).  You must identify the PGLIB "
-    echo "directory either with a --pglib invocation option, or by "
-    echo "setting the PGLIB environment variable, or by having a program "
-    echo "called 'postconfig' in your search path that outputs an asignment "
-    echo "for PGLIB."
-    exit 20
-fi
-
-#-------------------------------------------------------------------------
-# Make sure he told us where to build the database system
-#-------------------------------------------------------------------------
-
-if [ -z "$PGDATA" ]; then
-    echo "$CMDNAME: You must identify the PGDATA directory, where the data"
-    echo "for this database system will reside.  Do this with either a"
-    echo "--pgdata invocation option or a PGDATA environment variable."
-    echo
-    exit 20
-fi
-
-TEMPLATE=$PGLIB/local1_template1.bki.source
-GLOBAL=$PGLIB/global1.bki.source
-TEMPLATE_DESCR=$PGLIB/local1_template1.description
-GLOBAL_DESCR=$PGLIB/global1.description
-PG_HBA_SAMPLE=$PGLIB/pg_hba.conf.sample
-PG_GEQO_SAMPLE=$PGLIB/pg_geqo.sample
-
-
-#-------------------------------------------------------------------------
-# Find the input files
-#-------------------------------------------------------------------------
-
-for PREREQ_FILE in $TEMPLATE $GLOBAL $PG_HBA_SAMPLE; do
-    if [ ! -f $PREREQ_FILE ]; then 
-        echo "$CMDNAME does not find the file '$PREREQ_FILE'."
-        echo "This means you have identified an invalid PGLIB directory."
-        echo "You specify a PGLIB directory with a --pglib invocation "
-        echo "option, a PGLIB environment variable, or a postconfig program."
-        exit 1
-    fi
-done
-
-echo "$CMDNAME: using $TEMPLATE as input to create the template database."
-if [ $template_only -eq 0 ]; then
-    echo "$CMDNAME: using $GLOBAL as input to create the global classes."
-    echo "$CMDNAME: using $PG_HBA_SAMPLE as the host-based authentication" \
-         "control file."
-    echo
-fi  
-
-#---------------------------------------------------------------------------
-# Figure out who the Postgres superuser for the new database system will be.
-#---------------------------------------------------------------------------
-
-if [ -z "$POSTGRES_SUPERUSERNAME" ]; then 
-    echo "Can't tell what username to use.  You don't have the USER"
-    echo "environment variable set to your username and didn't specify the "
-    echo "--username option"
-    exit 1
-fi
-
-POSTGRES_SUPERUID=`pg_id $POSTGRES_SUPERUSERNAME`
-
-if [ $POSTGRES_SUPERUID = NOUSER ]; then
-    echo "Valid username not given.  You must specify the username for "
-    echo "the Postgres superuser for the database system you are "
-    echo "initializing, either with the --username option or by default "
-    echo "to the USER environment variable."
-    exit 10
-fi
-
-if [ $POSTGRES_SUPERUID -ne `pg_id` -a `pg_id` -ne 0 ]; then 
-    echo "Only the unix superuser may initialize a database with a different"
-    echo "Postgres superuser.  (You must be able to create files that belong"
-    echo "to the specified unix user)."
-    exit 2
-fi
-
-echo "We are initializing the database system with username" \
-  "$POSTGRES_SUPERUSERNAME (uid=$POSTGRES_SUPERUID)."   
-echo "This user will own all the files and must also own the server process."
-echo
-
-# -----------------------------------------------------------------------
-# Create the data directory if necessary
-# -----------------------------------------------------------------------
-
-# umask must disallow access to group, other for files and dirs
-umask 077
-
-if [ -f "$PGDATA/PG_VERSION" ]; then
-    if [ $template_only -eq 0 ]; then
-        echo "$CMDNAME: error: File $PGDATA/PG_VERSION already exists."
-        echo "This probably means initdb has already been run and the "
-        echo "database system already exists."
-        echo 
-        echo "If you want to create a new database system, either remove "
-        echo "the $PGDATA directory or run initdb with a --pgdata option "
-        echo "other than $PGDATA."
-        exit 1
-    fi
-else
-    if [ ! -d $PGDATA ]; then
-        echo "Creating Postgres database system directory $PGDATA"
-        echo
-        mkdir $PGDATA
-        if [ $? -ne 0 ]; then exit 5; fi
-    fi
-    if [ ! -d $PGDATA/base ]; then
-        echo "Creating Postgres database system directory $PGDATA/base"
-        echo
-        mkdir $PGDATA/base
-        if [ $? -ne 0 ]; then exit 5; fi
-    fi
-fi
-
-#----------------------------------------------------------------------------
-# Create the template1 database
-#----------------------------------------------------------------------------
-
-rm -rf $PGDATA/base/template1
-mkdir $PGDATA/base/template1
-
-if [ "$debug" -eq 1 ]; then
-    BACKEND_TALK_ARG="-d"
-else
-    BACKEND_TALK_ARG="-Q"
-fi
-
-BACKENDARGS="-boot -C -F -D$PGDATA $BACKEND_TALK_ARG"
-
-echo "$CMDNAME: creating template database in $PGDATA/base/template1"
-echo "Running: postgres $BACKENDARGS template1"
-
-cat $TEMPLATE \
-| sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \
-      -e "s/PGUID/$POSTGRES_SUPERUID/" \
-| postgres $BACKENDARGS template1
-
-if [ $? -ne 0 ]; then
-    echo "$CMDNAME: could not create template database"
-    if [ $noclean -eq 0 ]; then
-        echo "$CMDNAME: cleaning up by wiping out $PGDATA/base/template1"
-        rm -rf $PGDATA/base/template1
-    else
-        echo "$CMDNAME: cleanup not done because noclean options was used."
-    fi
-    exit 1;
-fi
-
-echo
-
-pg_version $PGDATA/base/template1
-
-#----------------------------------------------------------------------------
-# Create the global classes, if requested.
-#----------------------------------------------------------------------------
-
-if [ $template_only -eq 0 ]; then
-    echo "Creating global classes in $PG_DATA/base"
-    echo "Running: postgres $BACKENDARGS template1"
-
-    cat $GLOBAL \
-    | sed -e "s/postgres PGUID/$POSTGRES_SUPERUSERNAME $POSTGRES_SUPERUID/" \
-        -e "s/PGUID/$POSTGRES_SUPERUID/" \
-    | postgres $BACKENDARGS template1
-
-    if (test $? -ne 0)
-    then
-        echo "$CMDNAME: could not create global classes."
-        if (test $noclean -eq 0); then
-            echo "$CMDNAME: cleaning up."
-            rm -rf $PGDATA
-        else
-            echo "$CMDNAME: cleanup not done (noclean mode set)."
-        fi
-        exit 1;
-    fi
-
-    echo
-
-    pg_version $PGDATA
-
-    cp $PG_HBA_SAMPLE $PGDATA/pg_hba.conf
-    cp $PG_GEQO_SAMPLE $PGDATA/pg_geqo.sample
-
-    echo "Adding template1 database to pg_database..."
-
-    echo "open pg_database" > /tmp/create.$$
-    echo "insert (template1 $POSTGRES_SUPERUID template1)" >> /tmp/create.$$
-    #echo "show" >> /tmp/create.$$
-    echo "close pg_database" >> /tmp/create.$$
-
-    echo "Running: postgres $BACKENDARGS template1 < /tmp/create.$$"
-
-    postgres $BACKENDARGS template1 < /tmp/create.$$ 
-
-    if [ $? -ne 0 ]; then
-        echo "$CMDNAME: could not log template database"
-        if [ $noclean -eq 0 ]; then
-            echo "$CMDNAME: cleaning up."
-            rm -rf $PGDATA
-        else
-            echo "$CMDNAME: cleanup not done (noclean mode set)."
-        fi
-        exit 1;
-    fi
-    rm -f /tmp/create.$$
-fi
-
-echo
-
-PGSQL_OPT="-o /dev/null -F -Q -D$PGDATA"
-
-# If the COPY is first, the VACUUM generates an error, so we vacuum first
-echo "vacuuming template1"
-echo "vacuum" | postgres $PGSQL_OPT template1 > /dev/null
-
-echo "COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'" | \
-       postgres $PGSQL_OPT template1 > /dev/null
-
-echo "creating public pg_user view"
-echo "CREATE TABLE xpg_user (          \
-           usename     name,           \
-           usesysid    int4,           \
-           usecreatedb bool,           \
-           usetrace    bool,           \
-           usesuper    bool,           \
-           usecatupd   bool,           \
-           passwd              text,           \
-           valuntil    abstime);" | postgres $PGSQL_OPT template1 > /dev/null
-
-#move it into pg_user
-echo "UPDATE pg_class SET relname = 'pg_user' WHERE relname = 'xpg_user';" |\
-       postgres $PGSQL_OPT template1 > /dev/null
-echo "UPDATE pg_type SET typname = 'pg_user' WHERE typname = 'xpg_user';" |\
-       postgres $PGSQL_OPT template1 > /dev/null
-mv $PGDATA/base/template1/xpg_user $PGDATA/base/template1/pg_user
-
-echo "CREATE RULE _RETpg_user AS ON SELECT TO pg_user DO INSTEAD       \
-           SELECT usename, usesysid, usecreatedb, usetrace,            \
-                  usesuper, usecatupd, '********'::text as passwd,     \
-                  valuntil FROM pg_shadow;" | \
-       postgres $PGSQL_OPT template1 > /dev/null
-echo "REVOKE ALL on pg_shadow FROM public" | \
-       postgres $PGSQL_OPT template1 > /dev/null
-
-echo "loading pg_description"
-echo "copy pg_description from '$TEMPLATE_DESCR'" | \
-       postgres $PGSQL_OPT template1 > /dev/null
-echo "copy pg_description from '$GLOBAL_DESCR'" | \
-       postgres $PGSQL_OPT template1 > /dev/null
-echo "vacuum analyze" | \
-       postgres $PGSQL_OPT template1 > /dev/null
diff --git a/src/bin/pg_encoding/Makefile b/src/bin/pg_encoding/Makefile
new file mode 100644 (file)
index 0000000..4830f0d
--- /dev/null
@@ -0,0 +1,36 @@
+#-------------------------------------------------------------------------
+#
+#    Makefile for bin/pg_encoding
+#
+# Copyright (c) 1998, PostgreSQL development group
+#
+#
+# IDENTIFICATION
+#    $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/Makefile,v 1.1 1998/07/24 03:32:10 scrappy Exp $
+#
+#-------------------------------------------------------------------------
+
+SRCDIR= ../..
+include ../../Makefile.global
+
+OBJS= pg_encoding.o
+
+CFLAGS+= -DMB=$(MB) -I$(SRCDIR)/include
+
+all: pg_encoding
+
+pg_encoding: $(OBJS) $(LIBPQDIR)/libpq.a
+       $(CC) -o pg_encoding $(OBJS) -L$(LIBPQDIR) -lpq $(LDFLAGS)
+
+install: pg_encoding
+       $(INSTALL) $(INSTL_EXE_OPTS) pg_encoding $(BINDIR)/pg_encoding
+
+depend dep:
+       $(CC) -MM $(CFLAGS) *.c >depend
+
+clean: 
+       rm -f pg_encoding pg_encoding.o
+
+ifeq (depend,$(wildcard depend))
+include depend
+endif
diff --git a/src/bin/pg_encoding/pg_encoding.c b/src/bin/pg_encoding/pg_encoding.c
new file mode 100644 (file)
index 0000000..38a87a4
--- /dev/null
@@ -0,0 +1,49 @@
+/*-------------------------------------------------------------------------
+ *
+ * pg_encoding.c--
+ *
+ *
+ * Copyright (c) 1998, PostgreSQL development group
+ *
+ *
+ * IDENTIFICATION
+ *       $Header: /cvsroot/pgsql/src/bin/pg_encoding/Attic/pg_encoding.c,v 1.1 1998/07/24 03:32:10 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include "postgres.h"
+#include "mb/pg_wchar.h"
+
+static void usage(void);
+
+int
+main(int argc, char **argv)
+{
+  char c;
+  char *p;
+  int rtn;
+
+  if (argc < 2) {
+    usage();
+    exit(1);
+  }
+  p = argv[1];
+  while((c = *p++)) {
+    if (c < '0' || c > '9') {
+      rtn = pg_char_to_encoding(argv[1]);
+      if (rtn >= 0) {
+       printf("%d\n",rtn);
+      }
+      exit(0);
+    }
+  }
+  printf("%s\n",pg_encoding_to_char(atoi(argv[1])));
+  exit(0);
+}
+
+static void usage()
+{
+  fprintf(stderr, "pg_encoding: encoding_name | encoding_number\n");
+}
index faa5ed26cfbe8e533b3cb6e8aa60af8e9e3d5aa4..ed77b319c9903a7b25469432b07f9f53880fa484 100644 (file)
@@ -5,7 +5,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: psqlHelp.h,v 1.46 1998/07/18 18:34:16 momjian Exp $
+ * $Id: psqlHelp.h,v 1.47 1998/07/24 03:32:12 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -292,7 +292,7 @@ static struct _helpStruct QL_HELP[] = {
        "set DateStyle to {'ISO' | 'SQL' | 'Postgres' | 'European' | 'US' | 'NonEuropean'}\n\
 set GEQO to {'ON[=#]' | 'OFF'}\n\
 set R_PLANS to {'ON' | 'OFF'}\n\
-set CLIENT_ENCODING to {'EUC_JP' | 'SJIS' | 'EUC_CN' | 'EUC_KR' | 'EUC_TW' | 'MULE_INTERNAL' | 'LATIN1'}"},
+set CLIENT_ENCODING to {'EUC_JP' | 'SJIS' | 'EUC_CN' | 'EUC_KR' | 'EUC_TW' | 'MULE_INTERNAL' | 'LATIN1' | 'LATIN2' | 'LATIN3' | 'LATIN4' | 'LATIN5'}"},
 #else
        "set DateStyle to {'ISO' | 'SQL' | 'Postgres' | 'European' | 'US' | 'NonEuropean'}\n\
 set GEQO to {'ON[=#]' | 'OFF'}\n\
index 74a0f4f5957f7ed1ef5c0bb6079aabbb133cf2e6..04361a259e8e696970199651a334d5d5fddb7482 100644 (file)
@@ -195,12 +195,12 @@ AC_ARG_WITH(mb,
     [  --with-mb=<encoding> enable multi-byte support ], 
     [
        case "$withval" in
-       EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1)
+       EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5)
             MB="$withval";
            AC_MSG_RESULT("enabled with $withval")
             ;;
        *)
-           AC_MSG_ERROR([*** You must supply an argument to the --with-mb option one of EUC_JP,EHC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1])
+           AC_MSG_ERROR([*** You must supply an argument to the --with-mb option one of EUC_JP,EHC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1-5])
          ;;
        esac
        MB="$withval"
index dfbc756824918ee1170ac93aaa900585b5212bd7..bf8257375113aa75f3218bf62aeb70c0c97619af 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: pg_proc.h,v 1.62 1998/07/18 18:34:17 momjian Exp $
+ * $Id: pg_proc.h,v 1.63 1998/07/24 03:32:16 scrappy Exp $
  *
  * NOTES
  *       The script catalog/genbki.sh reads this file and generates .bki
@@ -2077,12 +2077,15 @@ DESCR("trim both ends of string");
 DATA(insert OID =  885 (  btrim                   PGUID 14 f t f 1 f 25 "25" 100 0 0 100  "select btrim($1, \' \')" - ));
 DESCR("trim both ends of string");
 
+
 /* SEQUENCEs nextval & currval functions */
 DATA(insert OID =  1317 (  nextval        PGUID 11 f t f 1 f 23 "25" 100 0 0 100  foo bar ));
 DESCR("sequence next value");
 DATA(insert OID =  1319 (  currval        PGUID 11 f t f 1 f 23 "25" 100 0 0 100  foo bar ));
 DESCR("sequence current value");
 
+/* for multi-byte support */
+DATA(insert OID = 1039 (  getdatabaseencoding     PGUID 11 f t f 0 f 19 "0" 100 0 0 100  foo bar ));
 
 /*
  * prototypes for functions pg_proc.c
index 06a291070e9f32d59e52c3765cf622e9904cdd9a..8675afa5c71fb01d7e5754b8a6242c58399fbb61 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: dbcommands.h,v 1.2 1998/07/09 03:28:56 scrappy Exp $
+ * $Id: dbcommands.h,v 1.3 1998/07/24 03:32:19 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
  */
 #define SIGKILLDAEMON1 SIGTERM
 
+#ifdef MB
+extern void createdb(char *dbname, char *dbpath, int encoding);
+#else
 extern void createdb(char *dbname, char *dbpath);
+#endif
 extern void destroydb(char *dbname);
 
 #endif                                                 /* DBCOMMANDS_H */
similarity index 59%
rename from src/include/regex/pg_wchar.h
rename to src/include/mb/pg_wchar.h
index a37c253e1f255f49e4e3e0834301f110fdc180e2..8453f38558dea46be8c6815eecb1720c7f03f3b8 100644 (file)
@@ -1,9 +1,11 @@
-/* $Id: pg_wchar.h,v 1.4 1998/07/18 18:34:24 momjian Exp $ */
+/* $Id: pg_wchar.h,v 1.1 1998/07/24 03:32:24 scrappy Exp $ */
 
 #ifndef PG_WCHAR_H
 #define PG_WCHAR_H
 
 #include <sys/types.h>
+#include "postgres.h"
+#include "miscadmin.h" /* for getdatabaseencoding() */
 
 #define EUC_JP 0       /* EUC for Japanese */
 #define EUC_CN 1       /* EUC for Chinese */
 #define LATIN3 8       /* ISO-8859 Latin 3 */
 #define LATIN4 9       /* ISO-8859 Latin 4 */
 #define LATIN5 10      /* ISO-8859 Latin 5 */
+#define LATIN6 11      /* ISO-8859 Latin 6 */
+#define LATIN7 12      /* ISO-8859 Latin 7 */
+#define LATIN8 13      /* ISO-8859 Latin 8 */
+#define LATIN9 14      /* ISO-8859 Latin 9 */
 /* followings are for client encoding only */
-#define SJIS 16                /* Shift JIS */
+#define SJIS 32                /* Shift JIS */
 
-#ifdef MULTIBYTE
-# if LATIN1 <= MULTIBYTE && MULTIBYTE <= LATIN5
-typedef unsigned char pg_wchar;
-# else
+#ifdef MB
 typedef unsigned int pg_wchar;
-# endif
 #else
 #define pg_wchar char
 #endif
@@ -65,7 +67,25 @@ typedef unsigned int pg_wchar;
 #define        LC_CNS11643_6   0xf9    /* CNS 11643-1992 Plane 6 */
 #define        LC_CNS11643_7   0xfa    /* CNS 11643-1992 Plane 7 */
 
-#ifdef MULTIBYTE
+#ifdef MB
+typedef struct {
+  int encoding;                /* encoding symbol value */
+  char *name;          /* encoding name */
+  int is_client_only;  /* 0: server/client bothg supported
+                          1: client only */
+  void (*to_mic)();    /* client encoding to MIC */
+  void (*from_mic)();  /* MIC to client encoding */
+} pg_encoding_conv_tbl;
+
+extern pg_encoding_conv_tbl pg_conv_tbl[];
+
+typedef struct {
+  void (*mb2wchar_with_len)(); /* convert a multi-byte string to a wchar */
+  int  (*mblen)();             /* returns the length of a multi-byte word */
+} pg_wchar_tbl;
+
+extern pg_wchar_tbl pg_wchar_table[];
+
 extern void pg_mb2wchar(const unsigned char *, pg_wchar *);
 extern void pg_mb2wchar_with_len(const unsigned char *, pg_wchar *, int);
 extern int pg_char_and_wchar_strcmp(const char *, const pg_wchar *);
@@ -74,9 +94,29 @@ extern int pg_char_and_wchar_strncmp(const char *, const pg_wchar *, size_t);
 extern size_t pg_wchar_strlen(const pg_wchar *);
 extern int pg_mblen(const unsigned char *);
 extern int pg_encoding_mblen(int, const unsigned char *);
+extern int pg_mule_mblen(const unsigned char *);
 extern int pg_mic_mblen(const unsigned char *);
 extern int pg_mbstrlen(const unsigned char *);
 extern int pg_mbstrlen_with_len(const unsigned char *, int);
-#endif
+extern pg_encoding_conv_tbl *pg_get_encent_by_encoding(int);
+extern bool show_client_encoding(void);
+extern bool reset_client_encoding(void);
+extern bool parse_client_encoding(const char *);
+extern bool show_server_encoding(void);
+extern bool reset_server_encoding(void);
+extern bool parse_server_encoding(const char *);
+extern int pg_set_client_encoding(int);
+extern int pg_get_client_encoding(void);
+extern unsigned char *pg_client_to_server(unsigned char *, int);
+extern unsigned char *pg_server_to_client(unsigned char *, int);
+extern int pg_valid_client_encoding(const char *);
+extern const char *pg_encoding_to_char(int);
+extern int pg_char_to_encoding(const char *);
+extern int GetDatabaseEncoding(void);
+extern void SetDatabaseEncoding(int);
+extern void SetTemplateEncoding(int);
+extern int GetTemplateEncoding(void);
 
-#endif
+#endif /* MB */
+
+#endif /* PG_WCHAR_H */
index a6f22432994c966ea5852c947d15c5d2ad942959..74c8bf71f19d5b34ef9cb28114572e41219cee0d 100644 (file)
@@ -11,7 +11,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: miscadmin.h,v 1.27 1998/07/09 03:28:55 scrappy Exp $
+ * $Id: miscadmin.h,v 1.28 1998/07/24 03:32:13 scrappy Exp $
  *
  * NOTES
  *       some of the information in this file will be moved to
@@ -116,13 +116,22 @@ extern char *DatabaseName;
 extern char *DatabasePath;
 
 /* in utils/misc/database.c */
+#ifdef MB
+extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding);
+#else
 extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
+#endif
 extern int     GetDatabaseInfo(char *name, Oid *owner, char *path);
 extern char *ExpandDatabasePath(char *path);
 
 /* now in utils/init/miscinit.c */
 extern void SetDatabaseName(char *name);
 extern void SetDatabasePath(char *path);
+/* even if MB is not enabled, this function is neccesary
+ * since pg_proc.h does have.
+ */
+extern const char *getdatabaseencoding(void);
+
 extern char *getpgusername(void);
 extern void SetPgUserName(void);
 extern Oid     GetUserId(void);
index 95a014409d9a0ce5d923b95fef53dda780912df2..c2c2c0fc7bba41922f1446aa2ad9bdd69acc84bc 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: parsenodes.h,v 1.50 1998/07/12 21:29:31 momjian Exp $
+ * $Id: parsenodes.h,v 1.51 1998/07/24 03:32:26 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -480,6 +480,10 @@ typedef struct CreatedbStmt
        NodeTag         type;
        char       *dbname;                     /* database to create */
        char       *dbpath;                     /* location of database */
+#ifdef MB
+       int        encoding;                    /* default encoding
+                                                  (see regex/pg_wchar.h) */
+#endif
 } CreatedbStmt;
 
 /* ----------------------
index 672ed2a382fcb84ba436b3940358c13a768eaad1..c4a306e4c230bb449bc5b07c11265c6bcf4200f5 100644 (file)
@@ -41,7 +41,7 @@
 #define _REGEX_H_
 
 #include <sys/types.h>
-#include <regex/pg_wchar.h>
+#include <mb/pg_wchar.h>
 
 /* types */
 typedef off_t regoff_t;
index 6f7b7170d8fd9762751bc6b5bcf20cefdc7329fc..60994c9ff5018b12a6a6856c53615f4d855c60af 100644 (file)
@@ -7,7 +7,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.23 1998/07/12 18:48:06 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.24 1998/07/24 03:32:33 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -33,7 +33,7 @@ OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
       dllist.o pqsignal.o
 
 ifdef MB
-OBJS+= pqutils.o pqmbutils.o
+OBJS+= common.o wchar.o conv.o
 endif
 
 # Shared library stuff
index 7833f635ac0b6fd6b5c55ce603857cc7fc710fb6..5029ec028b93592572d16277a44a869b0c86dbd8 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.75 1998/07/18 18:34:30 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.76 1998/07/24 03:32:33 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -44,6 +44,9 @@
 #include <crypt.h>
 #endif
 
+#ifdef MB
+#include "mb/pg_wchar.h"
+#endif
 
 static ConnStatusType connectDB(PGconn *conn);
 static PGconn *makeEmptyPGconn(void);
@@ -789,6 +792,34 @@ PQsetenv(PGconn *conn)
 {
        struct EnvironmentOptions *eo;
        char            setQuery[80];   /* mjl: size okay? XXX */
+#ifdef MB
+       char    *envname = "PGCLIENTENCODING";
+       char    envbuf[64];
+       char    *env;
+       char    *encoding = 0;
+       PGresult   *rtn;
+#endif
+
+#ifdef MB
+       /* query server encoding */
+       env = getenv(envname);
+       if (!env) {
+         rtn = PQexec(conn, "select getdatabaseencoding()");
+         if (rtn && PQresultStatus(rtn) == PGRES_TUPLES_OK) {
+           encoding = PQgetvalue(rtn,0,0);
+           if (encoding) {
+             /* set client encoding */
+             sprintf(envbuf,"%s=%s",envname,encoding);
+             putenv(envbuf);
+           }
+           PQclear(rtn);
+         }
+         if (!encoding) {      /* this should not happen */
+           sprintf(envbuf,"%s=%s",envname,pg_encoding_to_char(MB));
+           putenv(envbuf);
+         }
+       }
+#endif
 
        for (eo = EnvironmentOptions; eo->envName; eo++)
        {
diff --git a/src/interfaces/libpq/pqmbutils.c b/src/interfaces/libpq/pqmbutils.c
deleted file mode 100644 (file)
index d902f3e..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "../../backend/commands/mbutils.c"
-
diff --git a/src/interfaces/libpq/pqutils.c b/src/interfaces/libpq/pqutils.c
deleted file mode 100644 (file)
index 7e7d7a1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-#include "../../backend/regex/utils.c"
diff --git a/src/test/mb/README b/src/test/mb/README
new file mode 100644 (file)
index 0000000..50797f8
--- /dev/null
@@ -0,0 +1,9 @@
+README for MB(multi-byte) regression test
+                                                       1998/7/22
+                                                       Tatsuo Ishii
+
+This directory contains a set of tests for MB(multi-byte) supporting
+extentions for PostgreSQL. To run the test, simply type:
+
+% mbregress.sh
+
diff --git a/src/test/mb/expected/euc_cn.out b/src/test/mb/expected/euc_cn.out
new file mode 100644 (file)
index 0000000..f35356b
--- /dev/null
@@ -0,0 +1,87 @@
+QUERY: drop table ¼ÆËã»úÊõÓï;
+ERROR:  Relation ¼ÆËã»úÊõÓï Does Not Exist!
+QUERY: create table ¼ÆËã»úÊõÓï(ÊõÓï text, ·ÖÀàºÅ varchar, ±¸×¢1A char(16));
+QUERY: create index ¼ÆËã»úÊõÓïindex1 on ¼ÆËã»úÊõÓï using btree(ÊõÓï);
+QUERY: create index ¼ÆËã»úÊõÓïindex2 on ¼ÆËã»úÊõÓï using btree(·ÖÀàºÅ);
+QUERY: insert into ¼ÆËã»úÊõÓï values('µçÄÔÏÔʾÆÁ','»úA01ÉÏ');
+QUERY: insert into ¼ÆËã»úÊõÓï values('µçÄÔͼÐÎ','·ÖB01ÖÐ');
+QUERY: insert into ¼ÆËã»úÊõÓï values('µçÄÔ³ÌÐòÔ±','ÈËZ01ÏÂ');
+QUERY: vacuum ¼ÆËã»úÊõÓï;
+QUERY: select * from ¼ÆËã»úÊõÓï;
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      
+(3 rows)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ = 'ÈËZ01ÏÂ';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      
+(1 row)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ ~* 'ÈËz01ÏÂ';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      
+(1 row)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ like '_Z01_';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      
+(1 row)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ like '_Z%';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      
+(1 row)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ÊõÓï ~ 'µçÄÔ[ÏÔͼ]';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      
+(2 rows)
+
+QUERY: select * from ¼ÆËã»úÊõÓï where ÊõÓï ~* 'µçÄÔ[ÏÔͼ]';
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a
+----------+-------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      
+(2 rows)
+
+QUERY: select *,character_length(ÊõÓï) from ¼ÆËã»úÊõÓï;
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a|length
+----------+-------+------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      |     5
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      |     4
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      |     5
+(3 rows)
+
+QUERY: select *,octet_length(ÊõÓï) from ¼ÆËã»úÊõÓï;
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a|octet_length
+----------+-------+------+------------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      |          10
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      |           8
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      |          10
+(3 rows)
+
+QUERY: select *,position('ÏÔ' in ÊõÓï) from ¼ÆËã»úÊõÓï;
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a|strpos
+----------+-------+------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      |     3
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      |     0
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      |     0
+(3 rows)
+
+QUERY: select *,substring(ÊõÓï from 3 for 4) from ¼ÆËã»úÊõÓï;
+ÊõÓï      |·ÖÀàºÅ |±¸×¢1a|substr
+----------+-------+------+------
+µçÄÔÏÔʾÆÁ|»úA01ÉÏ|      |ÏÔʾÆÁ
+µçÄÔͼÐΠ |·ÖB01ÖÐ|      |ͼÐΠ 
+µçÄÔ³ÌÐòÔ±|ÈËZ01ÏÂ|      |³ÌÐòÔ±
+(3 rows)
+
diff --git a/src/test/mb/expected/euc_jp.out b/src/test/mb/expected/euc_jp.out
new file mode 100644 (file)
index 0000000..f976010
--- /dev/null
@@ -0,0 +1,87 @@
+QUERY: drop table ·×»»µ¡ÍѸì;
+ERROR:  Relation ·×»»µ¡ÍѸì Does Not Exist!
+QUERY: create table ·×»»µ¡ÍѸì (ÍѸì text, Ê¬Îॳ¡¼¥É varchar, È÷¹Í1A¤À¤è char(16));
+QUERY: create index ·×»»µ¡ÍѸìindex1 on ·×»»µ¡ÍѸì using btree (ÍѸì);
+QUERY: create index ·×»»µ¡ÍѸìindex2 on ·×»»µ¡ÍѸì using hash (ʬÎॳ¡¼¥É);
+QUERY: insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤','µ¡A01¾å');
+QUERY: insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹','ʬB10Ãæ');
+QUERY: insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼','¿ÍZ01²¼');
+QUERY: vacuum ·×»»µ¡ÍѸì;
+QUERY: select * from ·×»»µ¡ÍѸì;
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+--------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼  |¿ÍZ01²¼   |          
+(3 rows)
+
+QUERY: select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É = '¿ÍZ01²¼';
+ÍѸ젠                  |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼|¿ÍZ01²¼   |          
+(1 row)
+
+QUERY: select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É ~* '¿Íz01²¼';
+ÍѸ젠                  |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼|¿ÍZ01²¼   |          
+(1 row)
+
+QUERY: select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É like '_Z01_';
+ÍѸ젠                  |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼|¿ÍZ01²¼   |          
+(1 row)
+
+QUERY: select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É like '_Z%';
+ÍѸ젠                  |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼|¿ÍZ01²¼   |          
+(1 row)
+
+QUERY: select * from ·×»»µ¡ÍѸì where ÍѸì ~ '¥³¥ó¥Ô¥å¡¼¥¿[¥Ç¥°]';
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+--------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          
+(2 rows)
+
+QUERY: select * from ·×»»µ¡ÍѸì where ÍѸì ~* '¥³¥ó¥Ô¥å¡¼¥¿[¥Ç¥°]';
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è
+--------------------------+----------+----------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          
+(2 rows)
+
+QUERY: select *,character_length(ÍѸì) from ·×»»µ¡ÍѸì;
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è|length
+--------------------------+----------+----------+------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          |    12
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          |    13
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼  |¿ÍZ01²¼   |          |    12
+(3 rows)
+
+QUERY: select *,octet_length(ÍѸì) from ·×»»µ¡ÍѸì;
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è|octet_length
+--------------------------+----------+----------+------------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          |          24
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          |          26
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼  |¿ÍZ01²¼   |          |          24
+(3 rows)
+
+QUERY: select *,position('¥Ç' in ÍѸì) from ·×»»µ¡ÍѸì;
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è|strpos
+--------------------------+----------+----------+------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          |     7
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          |     0
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼  |¿ÍZ01²¼   |          |     0
+(3 rows)
+
+QUERY: select *,substring(ÍѸì from 10 for 4) from ·×»»µ¡ÍѸì;
+ÍѸ젠                    |ʬÎॳ¡¼¥É|È÷¹Í1a¤À¤è|substr  
+--------------------------+----------+----------+--------
+¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤  |µ¡A01¾å   |          |¥×¥ì¥¤  
+¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹|ʬB10Ãæ   |          |¥£¥Ã¥¯¥¹
+¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼  |¿ÍZ01²¼   |          |¥é¥Þ¡¼  
+(3 rows)
+
diff --git a/src/test/mb/expected/euc_kr.out b/src/test/mb/expected/euc_kr.out
new file mode 100644 (file)
index 0000000..e0bf3e0
--- /dev/null
@@ -0,0 +1,87 @@
+QUERY: drop table Íªß©Ñ¦¿ë¾î;
+ERROR:  Relation Íªß©Ñ¦¿ë¾î Does Not Exist!
+QUERY: create table Íªß©Ñ¦¿ë¾î (¿ë¾î text, ÝÂ×¾ÄÚµå varchar, ºñ°í1A¶ó±¸ char(16));
+QUERY: create index Íªß©Ñ¦¿ë¾îindex1 on Íªß©Ñ¦¿ë¾î using btree (¿ë¾î);
+QUERY: create index Íªß©Ñ¦¿ë¾îindex2 on Íªß©Ñ¦¿ë¾î using hash (ÝÂ×¾ÄÚµå);
+QUERY: insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ', 'ѦA01ß¾');
+QUERY: insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»Åͱ׷¡ÇȽº', 'ÝÂB10ñé');
+QUERY: insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó', 'ìÑZ01ù»');
+QUERY: vacuum Íªß©Ñ¦¿ë¾î;
+QUERY: select * from Íªß©Ñ¦¿ë¾î;
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          
+(3 rows)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå = 'ìÑZ01ù»';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          
+(1 row)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå ~* 'ìÑz01ù»';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          
+(1 row)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå like '_Z01_';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          
+(1 row)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå like '_Z%';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          
+(1 row)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ¿ë¾î ~ 'ÄÄÇ»ÅÍ[µð±×]';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          
+(2 rows)
+
+QUERY: select * from Íªß©Ñ¦¿ë¾î where ¿ë¾î ~* 'ÄÄÇ»ÅÍ[µð±×]';
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸
+----------------+--------+----------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          
+(2 rows)
+
+QUERY: select *,character_length(¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸|length
+----------------+--------+----------+------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          |     8
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          |     7
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          |     8
+(3 rows)
+
+QUERY: select *,octet_length(¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸|octet_length
+----------------+--------+----------+------------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          |          16
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          |          14
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          |          16
+(3 rows)
+
+QUERY: select *,position('µð' in ¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸|strpos
+----------------+--------+----------+------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          |     4
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          |     0
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          |     0
+(3 rows)
+
+QUERY: select *,substring(¿ë¾î from 3 for 4) from Íªß©Ñ¦¿ë¾î;
+¿ë¾î            |ÝÂ×¾ÄÚµå|ºñ°í1a¶ó±¸|substr  
+----------------+--------+----------+--------
+ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ|ѦA01ß¾ |          |Å͵ð½ºÇÃ
+ÄÄÇ»Åͱ׷¡ÇȽº  |ÝÂB10ñé |          |Åͱ׷¡ÇÈ
+ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó|ìÑZ01ù» |          |ÅÍÇÁ·Î±×
+(3 rows)
+
diff --git a/src/test/mb/expected/mule_internal.out b/src/test/mb/expected/mule_internal.out
new file mode 100644 (file)
index 0000000..da81d55
--- /dev/null
@@ -0,0 +1,333 @@
+QUERY: drop table \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+ERROR:  Relation \92·×\92»»\92µ¡\92ÍÑ\92¸ì Does Not Exist!
+QUERY: create table \92·×\92»»\92µ¡\92ÍÑ\92¸ì (\92ÍÑ\92¸ì text, \92ʬ\92Îà\92¥³\92¡¼\92¥É varchar, \92È÷\92¹Í1A\92¤À\92¤è char(16));
+QUERY: create index \92·×\92»»\92µ¡\92ÍÑ\92¸ìindex1 on \92·×\92»»\92µ¡\92ÍÑ\92¸ì using btree (\92ÍÑ\92¸ì);
+QUERY: create index \92·×\92»»\92µ¡\92ÍÑ\92¸ìindex2 on \92·×\92»»\92µ¡\92ÍÑ\92¸ì using hash (\92ʬ\92Îà\92¥³\92¡¼\92¥É);
+QUERY: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤','\92µ¡A01\92¾å');
+QUERY: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹','\92ʬB10\92Ãæ');
+QUERY: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼','\92¿ÍZ01\92²¼');
+QUERY: vacuum \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+---------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼   |\92¿ÍZ01\92²¼      |              
+(3 rows)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É = '\92¿ÍZ01\92²¼';
+\92ÍÑ\92¸ì                              |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼|\92¿ÍZ01\92²¼      |              
+(1 row)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É ~* '\92¿Íz01\92²¼';
+\92ÍÑ\92¸ì                              |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼|\92¿ÍZ01\92²¼      |              
+(1 row)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É like '_Z01_';
+\92ÍÑ\92¸ì                              |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼|\92¿ÍZ01\92²¼      |              
+(1 row)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É like '_Z%';
+\92ÍÑ\92¸ì                              |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼|\92¿ÍZ01\92²¼      |              
+(1 row)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~ '\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿[\92¥Ç\92¥°]';
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+---------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              
+(2 rows)
+
+QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~* '\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿[\92¥Ç\92¥°]';
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
+---------------------------------------+---------------+--------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              
+(2 rows)
+
+QUERY: select *,character_length(\92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è|length
+---------------------------------------+---------------+--------------+------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              |    12
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              |    13
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼   |\92¿ÍZ01\92²¼      |              |    12
+(3 rows)
+
+QUERY: select *,octet_length(\92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è|octet_length
+---------------------------------------+---------------+--------------+------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              |          36
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              |          39
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼   |\92¿ÍZ01\92²¼      |              |          36
+(3 rows)
+
+QUERY: select *,position('\92¥Ç' in \92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è|strpos
+---------------------------------------+---------------+--------------+------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              |     7
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              |     0
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼   |\92¿ÍZ01\92²¼      |              |     0
+(3 rows)
+
+QUERY: select *,substring(\92ÍÑ\92¸ì from 10 for 4) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+\92ÍÑ\92¸ì                                 |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è|substr      
+---------------------------------------+---------------+--------------+------------
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤   |\92µ¡A01\92¾å      |              |\92¥×\92¥ì\92¥¤   
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹|\92ʬB10\92Ãæ      |              |\92¥£\92¥Ã\92¥¯\92¥¹
+\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼   |\92¿ÍZ01\92²¼      |              |\92¥é\92¥Þ\92¡¼   
+(3 rows)
+
+QUERY: drop table \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+ERROR:  Relation \91¼Æ\91Ëã\91»ú\91Êõ\91Óï Does Not Exist!
+QUERY: create table \91¼Æ\91Ëã\91»ú\91Êõ\91Óï(\91Êõ\91Óï text, \91·Ö\91Àà\91ºÅ varchar, \91±¸\91×¢1A char(16));
+QUERY: create index \91¼Æ\91Ëã\91»ú\91Êõ\91Óïindex1 on \91¼Æ\91Ëã\91»ú\91Êõ\91Óï using btree(\91Êõ\91Óï);
+QUERY: create index \91¼Æ\91Ëã\91»ú\91Êõ\91Óïindex2 on \91¼Æ\91Ëã\91»ú\91Êõ\91Óï using btree(\91·Ö\91Àà\91ºÅ);
+QUERY: insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ','\91»úA01\91ÉÏ');
+QUERY: insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91ͼ\91ÐÎ','\91·ÖB01\91ÖÐ');
+QUERY: insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±','\91ÈËZ01\91ÏÂ');
+QUERY: vacuum \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        
+(3 rows)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ = '\91ÈËZ01\91ÏÂ';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        
+(1 row)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ ~* '\91ÈËz01\91ÏÂ';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        
+(1 row)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ like '_Z01_';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        
+(1 row)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ like '_Z%';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        
+(1 row)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91Êõ\91Óï ~ '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        
+(2 rows)
+
+QUERY: select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91Êõ\91Óï ~* '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a
+---------------+---------+--------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        
+(2 rows)
+
+QUERY: select *,character_length(\91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a|length
+---------------+---------+--------+------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        |     5
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        |     4
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        |     5
+(3 rows)
+
+QUERY: select *,octet_length(\91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a|octet_length
+---------------+---------+--------+------------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        |          15
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        |          12
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        |          15
+(3 rows)
+
+QUERY: select *,position('\91ÏÔ' in \91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a|strpos
+---------------+---------+--------+------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        |     3
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        |     0
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        |     0
+(3 rows)
+
+QUERY: select *,substring(\91Êõ\91Óï from 3 for 4) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+\91Êõ\91Óï         |\91·Ö\91Àà\91ºÅ|\91±¸\91×¢1a|substr   
+---------------+---------+--------+---------
+\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ|        |\91ÏÔ\91ʾ\91ÆÁ
+\91µç\91ÄÔ\91ͼ\91ÐΠ  |\91·ÖB01\91ÖÐ|        |\91ͼ\91ÐΠ  
+\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±|\91ÈËZ01\91ÏÂ|        |\91³Ì\91Ðò\91Ô±
+(3 rows)
+
+QUERY: drop table \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+ERROR:  Relation \93ͪ\93ß©\93Ѧ\93¿ë\93¾î Does Not Exist!
+QUERY: create table \93ͪ\93ß©\93Ѧ\93¿ë\93¾î (\93¿ë\93¾î text, \93ÝÂ\93×¾\93ÄÚ\93µå varchar, \93ºñ\93°í1A\93¶ó\93±¸ char(16));
+QUERY: create index \93ͪ\93ß©\93Ѧ\93¿ë\93¾îindex1 on \93ͪ\93ß©\93Ѧ\93¿ë\93¾î using btree (\93¿ë\93¾î);
+QUERY: create index \93ͪ\93ß©\93Ѧ\93¿ë\93¾îindex2 on \93ͪ\93ß©\93Ѧ\93¿ë\93¾î using hash (\93ÝÂ\93×¾\93ÄÚ\93µå);
+QUERY: insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ', '\93ѦA01\93ß¾');
+QUERY: insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º', '\93ÝÂB10\93ñé');
+QUERY: insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó', '\93ìÑZ01\93ù»');
+QUERY: vacuum \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              
+(3 rows)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå = '\93ìÑZ01\93ù»';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              
+(1 row)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå ~* '\93ìÑz01\93ù»';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              
+(1 row)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå like '_Z01_';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              
+(1 row)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå like '_Z%';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              
+(1 row)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93¿ë\93¾î ~ '\93ÄÄ\93Ç»\93ÅÍ[\93µð\93±×]';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              
+(2 rows)
+
+QUERY: select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93¿ë\93¾î ~* '\93ÄÄ\93Ç»\93ÅÍ[\93µð\93±×]';
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸
+------------------------+------------+--------------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              
+(2 rows)
+
+QUERY: select *,character_length(\93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸|length
+------------------------+------------+--------------+------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              |     8
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              |     7
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              |     8
+(3 rows)
+
+QUERY: select *,octet_length(\93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸|octet_length
+------------------------+------------+--------------+------------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              |          24
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              |          21
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              |          24
+(3 rows)
+
+QUERY: select *,position('\93µð' in \93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸|strpos
+------------------------+------------+--------------+------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              |     4
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              |     0
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              |     0
+(3 rows)
+
+QUERY: select *,substring(\93¿ë\93¾î from 3 for 4) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+\93¿ë\93¾î                  |\93ÝÂ\93×¾\93ÄÚ\93µå|\93ºñ\93°í1a\93¶ó\93±¸|substr      
+------------------------+------------+--------------+------------
+\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ|\93ѦA01\93ß¾   |              |\93ÅÍ\93µð\93½º\93ÇÃ
+\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º   |\93ÝÂB10\93ñé   |              |\93ÅÍ\93±×\93·¡\93ÇÈ
+\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó|\93ìÑZ01\93ù»   |              |\93ÅÍ\93ÇÁ\93·Î\93±×
+(3 rows)
+
+QUERY: drop table test;
+ERROR:  Relation test Does Not Exist!
+QUERY: create table test (t text);
+QUERY: insert into test values('ENGLISH');
+QUERY: insert into test values('FRAN\81ÇAIS');
+QUERY: insert into test values('ESPA\81ÑOL');
+QUERY: insert into test values('\81ÍSLENSKA');
+QUERY: insert into test values('ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA');
+QUERY: vacuum test;
+QUERY: select * from test;
+t                                   
+------------------------------------
+ENGLISH                             
+FRAN\81ÇAIS                           
+ESPA\81ÑOL                            
+\81ÍSLENSKA                           
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA
+(5 rows)
+
+QUERY: select * from test where t = 'ESPA\81ÑOL';
+t       
+--------
+ESPA\81ÑOL
+(1 row)
+
+QUERY: select * from test where t ~* 'espa\81Ñol';
+t                                   
+------------------------------------
+ESPA\81ÑOL                            
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA
+(2 rows)
+
+QUERY: select *,character_length(t) from test;
+t                                   |length
+------------------------------------+------
+ENGLISH                             |     7
+FRAN\81ÇAIS                           |     8
+ESPA\81ÑOL                            |     7
+\81ÍSLENSKA                           |     8
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA|    33
+(5 rows)
+
+QUERY: select *,octet_length(t) from test;
+t                                   |octet_length
+------------------------------------+------------
+ENGLISH                             |           7
+FRAN\81ÇAIS                           |           9
+ESPA\81ÑOL                            |           8
+\81ÍSLENSKA                           |           9
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA|          36
+(5 rows)
+
+QUERY: select *,position('L' in t) from test;
+t                                   |strpos
+------------------------------------+------
+ENGLISH                             |     4
+FRAN\81ÇAIS                           |     0
+ESPA\81ÑOL                            |     7
+\81ÍSLENSKA                           |     3
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA|     4
+(5 rows)
+
+QUERY: select *,substring(t from 3 for 4) from test;
+t                                   |substr
+------------------------------------+------
+ENGLISH                             |GLIS  
+FRAN\81ÇAIS                           |AN\81ÇA 
+ESPA\81ÑOL                            |PA\81ÑO 
+\81ÍSLENSKA                           |LENS  
+ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA|GLIS  
+(5 rows)
+
diff --git a/src/test/mb/expected/sjis.out b/src/test/mb/expected/sjis.out
new file mode 100644 (file)
index 0000000..5126787
--- /dev/null
@@ -0,0 +1,90 @@
+QUERY: drop table \8cv\8eZ\8b@\97p\8cê;
+QUERY: create table \8cv\8eZ\8b@\97p\8cê (\97p\8cê text, \95ª\97Þ\83R\81[\83h varchar, \94õ\8dl1A\82¾\82æ char(16));
+QUERY: create index \8cv\8eZ\8b@\97p\8cêindex1 on \8cv\8eZ\8b@\97p\8cê using btree (\97p\8cê);
+QUERY: create index \8cv\8eZ\8b@\97p\8cêindex2 on \8cv\8eZ\8b@\97p\8cê using hash (\95ª\97Þ\83R\81[\83h);
+QUERY: insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C','\8b@A01\8fã');
+QUERY: insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X','\95ªB10\92\86');
+QUERY: insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[','\90lZ01\89º');
+QUERY: vacuum \8cv\8eZ\8b@\97p\8cê;
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê;
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+--------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[  |\90lZ01\89º   |          
+(3 rows)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h = '\90lZ01\89º';
+\97p\8cê                    |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[|\90lZ01\89º   |          
+(1 row)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h ~* '\90lz01\89º';
+\97p\8cê                    |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[|\90lZ01\89º   |          
+(1 row)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h like '_Z01_';
+\97p\8cê                    |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[|\90lZ01\89º   |          
+(1 row)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h like '_Z%';
+\97p\8cê                    |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[|\90lZ01\89º   |          
+(1 row)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \97p\8cê ~ '\83R\83\93\83s\83\85\81[\83^[\83f\83O]';
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+--------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          
+(2 rows)
+
+QUERY: select * from \8cv\8eZ\8b@\97p\8cê where \97p\8cê ~* '\83R\83\93\83s\83\85\81[\83^[\83f\83O]';
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ
+--------------------------+----------+----------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          
+(2 rows)
+
+QUERY: select *,character_length(\97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ|length
+--------------------------+----------+----------+------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          |    12
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          |    13
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[  |\90lZ01\89º   |          |    12
+(3 rows)
+
+QUERY: select *,octet_length(\97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ|octet_length
+--------------------------+----------+----------+------------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          |          24
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          |          26
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[  |\90lZ01\89º   |          |          24
+(3 rows)
+
+QUERY: select *,position('\83f' in \97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ|strpos
+--------------------------+----------+----------+------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          |     7
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          |     0
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[  |\90lZ01\89º   |          |     0
+(3 rows)
+
+QUERY: select *,substring(\97p\8cê from 10 for 4) from \8cv\8eZ\8b@\97p\8cê;
+\97p\8cê                      |\95ª\97Þ\83R\81[\83h|\94õ\8dl1a\82¾\82æ|substr  
+--------------------------+----------+----------+--------
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C  |\8b@A01\8fã   |          |\83v\83\8c\83C  
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X|\95ªB10\92\86   |          |\83B\83b\83N\83X
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[  |\90lZ01\89º   |          |\83\89\83}\81[  
+(3 rows)
+
+QUERY: copy \8cv\8eZ\8b@\97p\8cê to stdout;
+\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C       \8b@A01\8fã \N
+\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X     \95ªB10\92\86 \N
+\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[       \90lZ01\89º \N
diff --git a/src/test/mb/expected/unicode.out b/src/test/mb/expected/unicode.out
new file mode 100644 (file)
index 0000000..7c5f3f7
--- /dev/null
@@ -0,0 +1,87 @@
+QUERY: drop table 計算機用語;
+ERROR:  Relation 計算機用語 Does Not Exist!
+QUERY: create table 計算機用語 (用語 text, 分類コード varchar, 備考1Aだよ char(16));
+QUERY: create index 計算機用語index1 on 計算機用語 using btree (用語);
+QUERY: create index 計算機用語index2 on 計算機用語 using hash (分類コード);
+QUERY: insert into 計算機用語 values('コンピュータディスプレイ','機A01上');
+QUERY: insert into 計算機用語 values('コンピュータグラフィックス','分B10中');
+QUERY: insert into 計算機用語 values('コンピュータプログラマー','人Z01下');
+QUERY: vacuum 計算機用語;
+QUERY: select * from 計算機用語;
+用語                                 |分類コード|備考1aだよ
+---------------------------------------+---------------+--------------
+コンピュータディスプレイ   |機A01上      |              
+コンピュータグラフィックス|分B10中      |              
+コンピュータプログラマー   |人Z01下      |              
+(3 rows)
+
+QUERY: select * from 計算機用語 where 分類コード = '人Z01下';
+用語                              |分類コード|備考1aだよ
+------------------------------------+---------------+--------------
+コンピュータプログラマー|人Z01下      |              
+(1 row)
+
+QUERY: select * from 計算機用語 where 分類コード ~* '人z01下';
+用語                              |分類コード|備考1aだよ
+------------------------------------+---------------+--------------
+コンピュータプログラマー|人Z01下      |              
+(1 row)
+
+QUERY: select * from 計算機用語 where 分類コード like '_Z01_';
+用語                              |分類コード|備考1aだよ
+------------------------------------+---------------+--------------
+コンピュータプログラマー|人Z01下      |              
+(1 row)
+
+QUERY: select * from 計算機用語 where 分類コード like '_Z%';
+用語                              |分類コード|備考1aだよ
+------------------------------------+---------------+--------------
+コンピュータプログラマー|人Z01下      |              
+(1 row)
+
+QUERY: select * from 計算機用語 where 用語 ~ 'コンピュータ[デグ]';
+用語                                 |分類コード|備考1aだよ
+---------------------------------------+---------------+--------------
+コンピュータディスプレイ   |機A01上      |              
+コンピュータグラフィックス|分B10中      |              
+(2 rows)
+
+QUERY: select * from 計算機用語 where 用語 ~* 'コンピュータ[デグ]';
+用語                                 |分類コード|備考1aだよ
+---------------------------------------+---------------+--------------
+コンピュータディスプレイ   |機A01上      |              
+コンピュータグラフィックス|分B10中      |              
+(2 rows)
+
+QUERY: select *,character_length(用語) from 計算機用語;
+用語                                 |分類コード|備考1aだよ|length
+---------------------------------------+---------------+--------------+------
+コンピュータディスプレイ   |機A01上      |              |    12
+コンピュータグラフィックス|分B10中      |              |    13
+コンピュータプログラマー   |人Z01下      |              |    12
+(3 rows)
+
+QUERY: select *,octet_length(用語) from 計算機用語;
+用語                                 |分類コード|備考1aだよ|octet_length
+---------------------------------------+---------------+--------------+------------
+コンピュータディスプレイ   |機A01上      |              |          36
+コンピュータグラフィックス|分B10中      |              |          39
+コンピュータプログラマー   |人Z01下      |              |          36
+(3 rows)
+
+QUERY: select *,position('デ' in 用語) from 計算機用語;
+用語                                 |分類コード|備考1aだよ|strpos
+---------------------------------------+---------------+--------------+------
+コンピュータディスプレイ   |機A01上      |              |     7
+コンピュータグラフィックス|分B10中      |              |     0
+コンピュータプログラマー   |人Z01下      |              |     0
+(3 rows)
+
+QUERY: select *,substring(用語 from 10 for 4) from 計算機用語;
+用語                                 |分類コード|備考1aだよ|substr      
+---------------------------------------+---------------+--------------+------------
+コンピュータディスプレイ   |機A01上      |              |プレイ   
+コンピュータグラフィックス|分B10中      |              |ィックス
+コンピュータプログラマー   |人Z01下      |              |ラマー   
+(3 rows)
+
diff --git a/src/test/mb/mbregress.sh b/src/test/mb/mbregress.sh
new file mode 100644 (file)
index 0000000..cb37612
--- /dev/null
@@ -0,0 +1,48 @@
+#! /bin/sh
+# $Header: /cvsroot/pgsql/src/test/mb/mbregress.sh,v 1.1 1998/07/24 03:32:40 scrappy Exp $
+
+if echo '\c' | grep -s c >/dev/null 2>&1
+then
+       ECHO_N="echo -n"
+       ECHO_C=""
+else
+       ECHO_N="echo"
+       ECHO_C='\c'
+fi
+
+PSQL="psql -n -e -q"
+tests="euc_jp sjis euc_kr euc_cn unicode mule_internal"
+unset PGCLIENTENCODING
+for i in $tests
+do
+       $ECHO_N "${i} .. " $ECHO_C
+
+       if [ $i = sjis ];then
+               PGCLIENTENCODING=SJIS
+               export PGCLIENTENCODING
+               $PSQL euc_jp < sql/sjis.sql > results/sjis.out 2>&1
+               unset PGCLIENTENCODING
+       else
+               destroydb $i >/dev/null 2>&1
+               createdb -E `echo $i|tr "[a-z]" "[A-Z]"` $i
+               $PSQL $i < sql/${i}.sql > results/${i}.out 2>&1
+       fi
+
+       if [ -f expected/${i}-${SYSTEM}.out ]
+       then
+               EXPECTED="expected/${i}-${SYSTEM}.out"
+       else
+               EXPECTED="expected/${i}.out"
+       fi
+  
+       if [ `diff ${EXPECTED} results/${i}.out | wc -l` -ne 0 ]
+       then
+               ( diff -wC3 ${EXPECTED} results/${i}.out; \
+               echo "";  \
+               echo "----------------------"; \
+               echo "" ) >> regression.diffs
+               echo failed
+       else
+               echo ok
+       fi
+done
diff --git a/src/test/mb/sql/euc_cn.sql b/src/test/mb/sql/euc_cn.sql
new file mode 100644 (file)
index 0000000..7cd0b9b
--- /dev/null
@@ -0,0 +1,19 @@
+drop table ¼ÆËã»úÊõÓï;
+create table ¼ÆËã»úÊõÓï(ÊõÓï text, ·ÖÀàºÅ varchar, ±¸×¢1A char(16));
+create index ¼ÆËã»úÊõÓïindex1 on ¼ÆËã»úÊõÓï using btree(ÊõÓï);
+create index ¼ÆËã»úÊõÓïindex2 on ¼ÆËã»úÊõÓï using btree(·ÖÀàºÅ);
+insert into ¼ÆËã»úÊõÓï values('µçÄÔÏÔʾÆÁ','»úA01ÉÏ');
+insert into ¼ÆËã»úÊõÓï values('µçÄÔͼÐÎ','·ÖB01ÖÐ');
+insert into ¼ÆËã»úÊõÓï values('µçÄÔ³ÌÐòÔ±','ÈËZ01ÏÂ');
+vacuum ¼ÆËã»úÊõÓï;
+select * from ¼ÆËã»úÊõÓï;
+select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ = 'ÈËZ01ÏÂ';
+select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ ~* 'ÈËz01ÏÂ';
+select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ like '_Z01_';
+select * from ¼ÆËã»úÊõÓï where ·ÖÀàºÅ like '_Z%';
+select * from ¼ÆËã»úÊõÓï where ÊõÓï ~ 'µçÄÔ[ÏÔͼ]';
+select * from ¼ÆËã»úÊõÓï where ÊõÓï ~* 'µçÄÔ[ÏÔͼ]';
+select *,character_length(ÊõÓï) from ¼ÆËã»úÊõÓï;
+select *,octet_length(ÊõÓï) from ¼ÆËã»úÊõÓï;
+select *,position('ÏÔ' in ÊõÓï) from ¼ÆËã»úÊõÓï;
+select *,substring(ÊõÓï from 3 for 4) from ¼ÆËã»úÊõÓï;
diff --git a/src/test/mb/sql/euc_jp.sql b/src/test/mb/sql/euc_jp.sql
new file mode 100644 (file)
index 0000000..2021205
--- /dev/null
@@ -0,0 +1,19 @@
+drop table ·×»»µ¡ÍѸì;
+create table ·×»»µ¡ÍѸì (ÍѸì text, Ê¬Îॳ¡¼¥É varchar, È÷¹Í1A¤À¤è char(16));
+create index ·×»»µ¡ÍѸìindex1 on ·×»»µ¡ÍѸì using btree (ÍѸì);
+create index ·×»»µ¡ÍѸìindex2 on ·×»»µ¡ÍѸì using hash (ʬÎॳ¡¼¥É);
+insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥Ç¥£¥¹¥×¥ì¥¤','µ¡A01¾å');
+insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥°¥é¥Õ¥£¥Ã¥¯¥¹','ʬB10Ãæ');
+insert into ·×»»µ¡ÍѸì values('¥³¥ó¥Ô¥å¡¼¥¿¥×¥í¥°¥é¥Þ¡¼','¿ÍZ01²¼');
+vacuum ·×»»µ¡ÍѸì;
+select * from ·×»»µ¡ÍѸì;
+select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É = '¿ÍZ01²¼';
+select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É ~* '¿Íz01²¼';
+select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É like '_Z01_';
+select * from ·×»»µ¡ÍѸì where Ê¬Îॳ¡¼¥É like '_Z%';
+select * from ·×»»µ¡ÍѸì where ÍѸì ~ '¥³¥ó¥Ô¥å¡¼¥¿[¥Ç¥°]';
+select * from ·×»»µ¡ÍѸì where ÍѸì ~* '¥³¥ó¥Ô¥å¡¼¥¿[¥Ç¥°]';
+select *,character_length(ÍѸì) from ·×»»µ¡ÍѸì;
+select *,octet_length(ÍѸì) from ·×»»µ¡ÍѸì;
+select *,position('¥Ç' in ÍѸì) from ·×»»µ¡ÍѸì;
+select *,substring(ÍѸì from 10 for 4) from ·×»»µ¡ÍѸì;
diff --git a/src/test/mb/sql/euc_kr.sql b/src/test/mb/sql/euc_kr.sql
new file mode 100644 (file)
index 0000000..cf9e07f
--- /dev/null
@@ -0,0 +1,19 @@
+drop table Íªß©Ñ¦¿ë¾î;
+create table Íªß©Ñ¦¿ë¾î (¿ë¾î text, ÝÂ×¾ÄÚµå varchar, ºñ°í1A¶ó±¸ char(16));
+create index Íªß©Ñ¦¿ë¾îindex1 on Íªß©Ñ¦¿ë¾î using btree (¿ë¾î);
+create index Íªß©Ñ¦¿ë¾îindex2 on Íªß©Ñ¦¿ë¾î using hash (ÝÂ×¾ÄÚµå);
+insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»Å͵ð½ºÇ÷¹ÀÌ', 'ѦA01ß¾');
+insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»Åͱ׷¡ÇȽº', 'ÝÂB10ñé');
+insert into Íªß©Ñ¦¿ë¾î values('ÄÄÇ»ÅÍÇÁ·Î±×·¡¸Ó', 'ìÑZ01ù»');
+vacuum Íªß©Ñ¦¿ë¾î;
+select * from Íªß©Ñ¦¿ë¾î;
+select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå = 'ìÑZ01ù»';
+select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå ~* 'ìÑz01ù»';
+select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå like '_Z01_';
+select * from Íªß©Ñ¦¿ë¾î where ÝÂ×¾ÄÚµå like '_Z%';
+select * from Íªß©Ñ¦¿ë¾î where ¿ë¾î ~ 'ÄÄÇ»ÅÍ[µð±×]';
+select * from Íªß©Ñ¦¿ë¾î where ¿ë¾î ~* 'ÄÄÇ»ÅÍ[µð±×]';
+select *,character_length(¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+select *,octet_length(¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+select *,position('µð' in ¿ë¾î) from Íªß©Ñ¦¿ë¾î;
+select *,substring(¿ë¾î from 3 for 4) from Íªß©Ñ¦¿ë¾î;
diff --git a/src/test/mb/sql/mule_internal.sql b/src/test/mb/sql/mule_internal.sql
new file mode 100644 (file)
index 0000000..2e381f0
--- /dev/null
@@ -0,0 +1,72 @@
+drop table \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+create table \92·×\92»»\92µ¡\92ÍÑ\92¸ì (\92ÍÑ\92¸ì text, \92ʬ\92Îà\92¥³\92¡¼\92¥É varchar, \92È÷\92¹Í1A\92¤À\92¤è char(16));
+create index \92·×\92»»\92µ¡\92ÍÑ\92¸ìindex1 on \92·×\92»»\92µ¡\92ÍÑ\92¸ì using btree (\92ÍÑ\92¸ì);
+create index \92·×\92»»\92µ¡\92ÍÑ\92¸ìindex2 on \92·×\92»»\92µ¡\92ÍÑ\92¸ì using hash (\92ʬ\92Îà\92¥³\92¡¼\92¥É);
+insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥Ç\92¥£\92¥¹\92¥×\92¥ì\92¥¤','\92µ¡A01\92¾å');
+insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥°\92¥é\92¥Õ\92¥£\92¥Ã\92¥¯\92¥¹','\92ʬB10\92Ãæ');
+insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿\92¥×\92¥í\92¥°\92¥é\92¥Þ\92¡¼','\92¿ÍZ01\92²¼');
+vacuum \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É = '\92¿ÍZ01\92²¼';
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É ~* '\92¿Íz01\92²¼';
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É like '_Z01_';
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É like '_Z%';
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~ '\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿[\92¥Ç\92¥°]';
+select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~* '\92¥³\92¥ó\92¥Ô\92¥å\92¡¼\92¥¿[\92¥Ç\92¥°]';
+select *,character_length(\92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+select *,octet_length(\92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+select *,position('\92¥Ç' in \92ÍÑ\92¸ì) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+select *,substring(\92ÍÑ\92¸ì from 10 for 4) from \92·×\92»»\92µ¡\92ÍÑ\92¸ì;
+drop table \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+create table \91¼Æ\91Ëã\91»ú\91Êõ\91Óï(\91Êõ\91Óï text, \91·Ö\91Àà\91ºÅ varchar, \91±¸\91×¢1A char(16));
+create index \91¼Æ\91Ëã\91»ú\91Êõ\91Óïindex1 on \91¼Æ\91Ëã\91»ú\91Êõ\91Óï using btree(\91Êõ\91Óï);
+create index \91¼Æ\91Ëã\91»ú\91Êõ\91Óïindex2 on \91¼Æ\91Ëã\91»ú\91Êõ\91Óï using btree(\91·Ö\91Àà\91ºÅ);
+insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ','\91»úA01\91ÉÏ');
+insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91ͼ\91ÐÎ','\91·ÖB01\91ÖÐ');
+insert into \91¼Æ\91Ëã\91»ú\91Êõ\91Óï values('\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±','\91ÈËZ01\91ÏÂ');
+vacuum \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ = '\91ÈËZ01\91ÏÂ';
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ ~* '\91ÈËz01\91ÏÂ';
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ like '_Z01_';
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91·Ö\91Àà\91ºÅ like '_Z%';
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91Êõ\91Óï ~ '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
+select * from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï where \91Êõ\91Óï ~* '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
+select *,character_length(\91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+select *,octet_length(\91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+select *,position('\91ÏÔ' in \91Êõ\91Óï) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+select *,substring(\91Êõ\91Óï from 3 for 4) from \91¼Æ\91Ëã\91»ú\91Êõ\91Óï;
+drop table \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+create table \93ͪ\93ß©\93Ѧ\93¿ë\93¾î (\93¿ë\93¾î text, \93ÝÂ\93×¾\93ÄÚ\93µå varchar, \93ºñ\93°í1A\93¶ó\93±¸ char(16));
+create index \93ͪ\93ß©\93Ѧ\93¿ë\93¾îindex1 on \93ͪ\93ß©\93Ѧ\93¿ë\93¾î using btree (\93¿ë\93¾î);
+create index \93ͪ\93ß©\93Ѧ\93¿ë\93¾îindex2 on \93ͪ\93ß©\93Ѧ\93¿ë\93¾î using hash (\93ÝÂ\93×¾\93ÄÚ\93µå);
+insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93µð\93½º\93ÇÃ\93·¹\93ÀÌ', '\93ѦA01\93ß¾');
+insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93±×\93·¡\93ÇÈ\93½º', '\93ÝÂB10\93ñé');
+insert into \93ͪ\93ß©\93Ѧ\93¿ë\93¾î values('\93ÄÄ\93Ç»\93ÅÍ\93ÇÁ\93·Î\93±×\93·¡\93¸Ó', '\93ìÑZ01\93ù»');
+vacuum \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå = '\93ìÑZ01\93ù»';
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå ~* '\93ìÑz01\93ù»';
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå like '_Z01_';
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93ÝÂ\93×¾\93ÄÚ\93µå like '_Z%';
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93¿ë\93¾î ~ '\93ÄÄ\93Ç»\93ÅÍ[\93µð\93±×]';
+select * from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î where \93¿ë\93¾î ~* '\93ÄÄ\93Ç»\93ÅÍ[\93µð\93±×]';
+select *,character_length(\93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+select *,octet_length(\93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+select *,position('\93µð' in \93¿ë\93¾î) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+select *,substring(\93¿ë\93¾î from 3 for 4) from \93ͪ\93ß©\93Ѧ\93¿ë\93¾î;
+drop table test;
+create table test (t text);
+insert into test values('ENGLISH');
+insert into test values('FRAN\81ÇAIS');
+insert into test values('ESPA\81ÑOL');
+insert into test values('\81ÍSLENSKA');
+insert into test values('ENGLISH FRAN\81ÇAIS ESPA\81ÑOL \81ÍSLENSKA');
+vacuum test;
+select * from test;
+select * from test where t = 'ESPA\81ÑOL';
+select * from test where t ~* 'espa\81Ñol';
+select *,character_length(t) from test;
+select *,octet_length(t) from test;
+select *,position('L' in t) from test;
+select *,substring(t from 3 for 4) from test;
diff --git a/src/test/mb/sql/sjis.sql b/src/test/mb/sql/sjis.sql
new file mode 100644 (file)
index 0000000..dfa66fc
--- /dev/null
@@ -0,0 +1,20 @@
+drop table \8cv\8eZ\8b@\97p\8cê;
+create table \8cv\8eZ\8b@\97p\8cê (\97p\8cê text, \95ª\97Þ\83R\81[\83h varchar, \94õ\8dl1A\82¾\82æ char(16));
+create index \8cv\8eZ\8b@\97p\8cêindex1 on \8cv\8eZ\8b@\97p\8cê using btree (\97p\8cê);
+create index \8cv\8eZ\8b@\97p\8cêindex2 on \8cv\8eZ\8b@\97p\8cê using hash (\95ª\97Þ\83R\81[\83h);
+insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83f\83B\83X\83v\83\8c\83C','\8b@A01\8fã');
+insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83O\83\89\83t\83B\83b\83N\83X','\95ªB10\92\86');
+insert into \8cv\8eZ\8b@\97p\8cê values('\83R\83\93\83s\83\85\81[\83^\83v\83\8d\83O\83\89\83}\81[','\90lZ01\89º');
+vacuum \8cv\8eZ\8b@\97p\8cê;
+select * from \8cv\8eZ\8b@\97p\8cê;
+select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h = '\90lZ01\89º';
+select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h ~* '\90lz01\89º';
+select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h like '_Z01_';
+select * from \8cv\8eZ\8b@\97p\8cê where \95ª\97Þ\83R\81[\83h like '_Z%';
+select * from \8cv\8eZ\8b@\97p\8cê where \97p\8cê ~ '\83R\83\93\83s\83\85\81[\83^[\83f\83O]';
+select * from \8cv\8eZ\8b@\97p\8cê where \97p\8cê ~* '\83R\83\93\83s\83\85\81[\83^[\83f\83O]';
+select *,character_length(\97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+select *,octet_length(\97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+select *,position('\83f' in \97p\8cê) from \8cv\8eZ\8b@\97p\8cê;
+select *,substring(\97p\8cê from 10 for 4) from \8cv\8eZ\8b@\97p\8cê;
+copy \8cv\8eZ\8b@\97p\8cê to stdout;
diff --git a/src/test/mb/sql/unicode.sql b/src/test/mb/sql/unicode.sql
new file mode 100644 (file)
index 0000000..e722d3d
--- /dev/null
@@ -0,0 +1,19 @@
+drop table 計算機用語;
+create table 計算機用語 (用語 text, 分類コード varchar, 備考1Aだよ char(16));
+create index 計算機用語index1 on 計算機用語 using btree (用語);
+create index 計算機用語index2 on 計算機用語 using hash (分類コード);
+insert into 計算機用語 values('コンピュータディスプレイ','機A01上');
+insert into 計算機用語 values('コンピュータグラフィックス','分B10中');
+insert into 計算機用語 values('コンピュータプログラマー','人Z01下');
+vacuum 計算機用語;
+select * from 計算機用語;
+select * from 計算機用語 where 分類コード = '人Z01下';
+select * from 計算機用語 where 分類コード ~* '人z01下';
+select * from 計算機用語 where 分類コード like '_Z01_';
+select * from 計算機用語 where 分類コード like '_Z%';
+select * from 計算機用語 where 用語 ~ 'コンピュータ[デグ]';
+select * from 計算機用語 where 用語 ~* 'コンピュータ[デグ]';
+select *,character_length(用語) from 計算機用語;
+select *,octet_length(用語) from 計算機用語;
+select *,position('デ' in 用語) from 計算機用語;
+select *,substring(用語 from 10 for 4) from 計算機用語;