-postgresql 6.3 multi-byte (MB) support README April 21 1998
+postgresql 6.4 multi-byte (MB) support README Jun 5 1998
Tatsuo Ishii
t-ishii@sra.co.jp
http://www.sra.co.jp/people/t-ishii/PostgreSQL/
-Introduction
+0. Introduction
The MB support is intended for allowing PostgreSQL to handle
multi-byte character sets such as EUC(Extended Unix Code), Unicode and
and a few French characters could be used with the patch. Please let
me know if you find any problem while using 8-bit characters)
-How to use
+1. How to use
create src/Makefile.custom with a line including:
EUC_TW Taiwan EUC
UNICODE Unicode(UTF-8)
MULE_INTERNAL Mule internal
+ LATIN1 ISO 8859-1 English and some European laguages
Example:
If MB is disabled, nothing is changed except better supporting for
8-bit single byte character sets.
-References
+2. PGCLIENTENCODING
+
+If an environment variable PGCLIENTENCODING is defined on the
+frontend, automatic encoding translation is done by the backend. For
+example, if the backend has been compiled with MB=EUC_JP and
+PGCLIENTENCODING=SJIS(Shift JIS: yet another Japanese encoding
+system), then any SJIS strings coming from the frontend would be
+translated to EUC_JP before going into the parser. Outputs from the
+backend would be translated to SJIS of course.
+
+Supported encodings for PGCLIENTENCODING are:
+
+ EUC_JP Japanese EUC
+ SJIS Yet another Japanese encoding
+ EUC_CN Chinese EUC
+ EUC_KR Korean EUC
+ EUC_TW Taiwan EUC
+ MULE_INTERNAL Mule internal
+ LATIN1 ISO 8859-1 English and some European laguages
+
+Note that UNICODE is not supported(yet). Also note that the
+translation is not always possible. Suppose you choose EUC_JP for the
+backend, LATIN1 for the frotend, then some Japanese characters cannot
+be translated into latin. In this case, a letter cannot be represented
+in the Latin character set, would be transformed as:
+
+ (HEXA DECIMAL)
+
+3. SET CLIENT_ENCODING TO command
+
+Actually setting the frontend side encoding information is done by a
+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:
+
+ SHOW CLIENT_ENCODING;
+
+To return to the default encoding:
+
+ RESET CLIENT_ENCODING;
+
+This would reset the frontend encoding to same as the backend
+encoding, thus no endoing translation would be performed.
+
+4. References
These are good sources to start learning various kind of encoding
systems.
RFC 2044
UTF-8 is defined here.
-History
+5. History
+
+Jun 5, 1988
+ * add support for the encoding translation between the backend
+ and the frontend
+ * new command SET CLIENT_ENCODING etc. added
+ * add support for LATIN1 character set
+ * enhance 8 bit cleaness
April 21, 1998 some enhancements/fixes
* character_length(), position(), substring() are now aware of
-postgresql 6.3.2 multi-byte (MB) support README 1998/4/21 \e$B:n@.\e(B
+postgresql 6.3.2 multi-byte (MB) support README 1998/5/25 \e$B:n@.\e(B
\e$B@P0fC#IW\e(B
t-ishii@sra.co.jp
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 \e$B$,%3%s%Q%$%k;~$KA*Br2DG=!#%G!<%?%Y!<%9$K$O\e(B
- \e$B$3$N%3!<%I$N$^$^3JG<$5$l$^$9!#\e(B
+ mule internal code, ISO-8859-1 \e$B$,%3%s%Q%$%k;~$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)
3.\e$B%+%i%`L>$K%^%k%A%P%$%HJ8;z$,;HMQ2DG=\e(B
6.\e$B%^%k%A%P%$%HJ8;z$N\e(B LIKE \e$B8!:w$,;HMQ2DG=\e(B
7.character_length(), position(), substring() \e$B$G$N%^%k%A%P%$%H\e(B
\e$B%5%]!<%H\e(B
+ 8.\e$B4D6-JQ?t\e(B PGCLIENTENCODING \e$B$K$h$j!"%/%i%$%"%s%HB&$NJ8;z%3!<%I\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$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
\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
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
+\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$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
+ \e$B$a$7$F$$$k$o$1$8$c$J$$$G$9$,\e(B)\e$B!#\e(B
+
+ \e$B$?$H$($P!"\e(BMB=EUC_JP \e$B$G\e(B PostgeSQL \e$B$,%$%s%9%H!<%k$5$l$F$$$k>l9g!"\e(B
+ postmaster \e$B$rN)$A>e$2$k$H$-$K4D6-JQ?t\e(B PGCLIENTENCODING \e$B$K\e(B SJIS \e$B$r@_\e(B
+ \e$BDj$9$k$H!"%/%i%$%"%s%H$O\e(B SJIS \e$B%3!<%I$G\e(B PostgreSQL \e$B$K%"%/%;%9$G$-$k$h\e(B
+ \e$B$&$K$J$j$^$9!#$?$@$7!"%G!<%?%Y!<%9$K3JG<$5$l$k%G!<%?<+BN$O$"$/$^$G\e(B
+ MB \e$B$G;XDj$7$?\e(B EUC_JP \e$B$N$^$^$G$9!#\e(B
+
+ \e$B%/%i%$%"%s%HB&$G%;%C%7%g%sKh$KJ8;z%3!<%I$rJQ$($k$3$H$b$G$-$^$9!#\e(B
+ \e$B%;%C%7%g%s3+;O;~$K4D6-JQ?t\e(B PGCLIENTENCODING \e$B$,%;%C%H$5$l$F$$$k$H!"$=\e(B
+ \e$B$l$,M%@h$5$l$F%/%i%$%"%s%HB&$NJ8;z%3!<%I$K:NMQ$5$l$^$9!#$3$N5!G=$rMx\e(B
+ \e$BMQ$9$k$H!"$"$k%f!<%6$O\e(B EUC_JP \e$B$G!"JL$J%f!<%6$O\e(B SJIS \e$B$GF1$8%G!<%?%Y!<\e(B
+ \e$B%9$K%"%/%;%9$9$k$H$$$&$h$&$J$3$H$,$G$-$k$h$&$K$J$j$^$9!#\e(B
+
+ MB=MULE_INTERNAL \e$B$G\e(B PostgreSQL \e$B$r%$%s%9%H!<%k$7$F$*$/$H!"IaCJ$O\e(B
+ EUC_JP \e$B$G%/%i%$%"%s%H$rMxMQ$7!"J#?t$NJ8;z=89g$r:.:_$5$;$k$H$-$@$1%/\e(B
+ \e$B%i%$%"%s%H$r\e(B MULE_INTERNAL \e$B$K@_Dj$9$k$J$I$N;H$$J,$1$,$G$-$FJXMx$G$9!#\e(B
+ \e$B$?$@!"0lHL$K\e(B EUC_JP \e$B$KHf$Y!"\e(BMULE_INTERNAL \e$B$K$h$k%G!<%?I=8=$O$d$d%9%Z!<\e(B
+ \e$B%9$r6t$&$N$G!"$=$N$X$s$O9MN8$7$F$*$/I,MW$,$"$j$^$9!#$?$H$($P!"\e(B2\e$B%P%$\e(B
+ \e$B%H$GI=8=$G$-$k4A;z$O\e(B MULE_INTERNAL \e$B$G$O\e(B 3\e$B%P%$%H$rMW$7$^$9!#\e(B
+
+ \e$BCm0U$7$F$*$/I,MW$,$"$k$N$O!"%5!<%PB&$NJ8;z%3!<%I$H%/%i%$%"%s%HB&$NJ8\e(B
+ \e$B;z%3!<%I$,$$$D$bAj8_JQ49$G$-$k$H$O8B$i$J$$$3$H$G$9!#6KC<$JOC!"%5!<%P\e(B
+ \e$BB&$,\e(B EUC_JP \e$B$J$N$K!"%/%i%$%"%s%HB&$,\e(B EUC_KR \e$B$@$C$?$i$I$&$J$k$G$7$g$&!#\e(B
+ \e$B$3$N>l9g\e(B PostgreSQL \e$B$OJQ49$G$-$J$$%3!<%I$r\e(B 16\e$B?JI=8=$KJQ49$7$F$7$^$$\e(B
+ \e$B$^$9!#$?$H$($P!"\e(B"(bdae)" \e$B$N$h$&$K!#$J$*!"$3$N\e(B 16\e$B?JI=8=$O\e(B mule
+ internalcode \e$B$N%3!<%I$G$"$k$3$H$KCm0U$7$F2<$5$$!#$3$l$O!"D>@\%/%i%$\e(B
+ \e$B%"%s%H\e(B <--> \e$B%5!<%P$NJ8;z%3!<%I$rJQ49$9$k$N$G$O$J$/!"0lEYFbItI=8=$G$"\e(B
+ \e$B$k\e(B mule internal code \e$B$r7PM3$7$F$$$k$?$a$G$9!#\e(B
+
+ \e$B%/%i%$%"%s%HB&$NJ8;z%3!<%I$N@_Dj$O!"\e(B"set client_encoding" \e$B%3%^%s%I$G\e(B
+ \e$B$b2DG=$G$9!#$?$H$($P!"\e(B
+
+ set client_encoding to 'sjis';
+
+ \e$B$GL@<(E*$K%/%i%$%"%s%HB&$NJ8;z%3!<%I$r\e(B SJIS \e$B$K@_Dj$G$-$^$9!#<B:]!"%/\e(B
+ \e$B%i%$%"%s%H$,%5!<%P$K@\B3$9$k:]$K$O\e(B libpq \e$B$NCf$G\e(B "set
+ client_encoding" \e$B%3%^%s%I$rH/9T$7$F$$$^$9!#%;%C%7%g%sCf$K\e(B
+ set client_encoding" \e$B%3%^%s%I$rH/9T$9$l$P!"F0E*$KJ8;z%3!<%I$N@ZBX$(\e(B
+ \e$B$,$G$-$^$9$,!"$=$N:]$K$O4D6-JQ?t\e(B PGCLIENTENCODING \e$B$rF1;~$K%/%i%$%"%s\e(B
+ \e$B%H%"%W%j%1!<%7%g%s$NCf$G@_Dj$7D>$9I,MW$,$"$j$^$9!#\e(B(psql \e$B$K$O8=:_$3$N\e(B
+ \e$B5!G=$,$J$$$?$a!";v<B>eF0E*$K%/%i%$%"%s%HB&$NJ8;z%3!<%I$r@_Dj$9$k$3$H\e(B
+ \e$B$,$G$-$^$;$s!#\e(B)
+
+ \e$B8=:_@_Dj$5$l$F$$$k%/%i%$%"%s%HB&$NJ8;z%3!<%I$O\e(B
+
+ show client_encoding;
+
+ \e$B$G;2>H$G$-$^$9!#$^$?!"\e(B
+
+ reset client_encoding;
+
+ \e$B$O!"%G%U%)%k%H$N%/%i%$%"%s%HJ8;z%3!<%I@_Dj$KI|5"$5$;$^$9!#\e(Bpostmaster
+ \e$B$rN)$A>e$2$k$H$-$K4D6-JQ?t\e(B PGCLIENTENCODING \e$B$,@_Dj$5$l$F$$$k$H$=$NJ8\e(B
+ \e$B;z%3!<%I$K!"$=$&$G$J$1$l$P%3%s%Q%$%k;~$K;XDj$7$?%5!<%PB&$NJ8;z%3!<%I\e(B
+ \e$B$HF1$8$K$J$j$^$9!#\e(B
+
+\e$B@)8B;v9`!'\e(B
+
+ SJIS \e$B$r;HMQ$9$k>l9g!"\e(BPostgreSQL \e$B$N%/%i%$%"%s%H$G$^$H$b$KBP1~$7$F$$$k\e(B
+ \e$B$N$O\e(B psql \e$B$@$1$G$9!#\e(BTcl/Tk\e$B!"$=$N$[$+$OBP1~$7$F$^$;$s!#\e(B
+
\e$B<U<-!'\e(B
+
o \e$B3F<oJ8;z%;%C%H!"%3!<%I7O$K$D$$$F!"F|K\8l\e(B PostgreSQL \e$B%a!<%j%s%0%j%9%H\e(B
\e$B$N%a%s%P$NJ}$+$i%"%I%P%$%9$rD:$-$^$7$?!#$3$3$K46<U$7$^$9!#\e(B
+ \e$B$^$?!"\e(BSJIS \e$BBP1~$K$D$$$F$O!";T@n\e(B@\e$B$*CcBg$5$s$N%Q%C%A$r;29M$K$5$;$F$$\e(B
+ \e$B$?$@$-$^$7$?!#\e(B
\e$B2~DjMzNr!'\e(B
- 1998/4/21 \e$B5!G=DI2C!?%P%0=$@5\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)
+
+ 1998/5/18 \e$B5!G=DI2C!?%P%0=$@5\e(B(mb_b2.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)
+ * \e$B4D6-JQ?t\e(B PGCLIENTENCODING \e$B$N%5%]!<%H!#%/%i%$%"%s%HB&$N\e(B
+ \e$BJ8;z%3!<%I$r;XDj$9$k!#8=:_!"\e(BSJIS, EUC_*, MULE_INTERNAL, LATIN1
+ \e$B$,;XDj$G$-$k!#$^$?!"\e(B
+ set client_encoding to 'sjis';
+ \e$B$G$b2DG=\e(B
+ * 8bit \e$BJ8;z$,EO$k$HLdBj$,5/$-$k2U=j$K$G$-$k$@$1BP1~\e(B
+
+ 1998/4/21 \e$B5!G=DI2C!?%P%0=$@5\e(B(mb_b1.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$F$$$k\e(B)
* character_length(), position(), substring() \e$B$N%^%k%A%P%$%H\e(B
\e$BBP1~\e(B
* octet_length() \e$BDI2C\e(B \e$B"*\e(B initdb \e$B$N$d$jD>$7I,MW\e(B
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.42 1998/05/12 15:42:08 momjian Exp $
+# $Header: /cvsroot/pgsql/src/Makefile.global.in,v 1.43 1998/06/16 07:29:15 momjian Exp $
#
# NOTES
# Essentially all Postgres make files include this file and use the
#
# enable multi-byte support
# choose one of:
-# EUC_JP,EHC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL
+# EUC_JP,EUC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL,LATIN1
MB=@MB@
##############################################################################
# Makefile for access/common
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/access/common/Makefile,v 1.10 1998/04/06 00:20:44 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/access/common/Makefile,v 1.11 1998/06/16 07:29:18 momjian Exp $
#
#-------------------------------------------------------------------------
CFLAGS+=-I../..
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
+
OBJS = heaptuple.o heapvalid.o indextuple.o indexvalid.o printtup.o \
scankey.o tupdesc.o
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.28 1998/05/14 17:18:12 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.29 1998/06/16 07:29:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <libpq/libpq.h>
#include <utils/syscache.h>
+#ifdef MB
+#include <commands/variable.h>
+#endif
+
/* ----------------------------------------------------------------
* printtup / debugtup support
* ----------------------------------------------------------------
Datum attr;
bool isnull;
Oid typoutput;
+#ifdef MB
+ unsigned char *p;
+#endif
/* ----------------
* tell the frontend to expect new tuple data
outputstr = fmgr(typoutput, attr,
gettypelem(typeinfo->attrs[i]->atttypid),
typeinfo->attrs[i]->atttypmod);
+#ifdef MB
+ p = pg_server_to_client(outputstr, strlen(outputstr));
+ pq_putint(strlen(p) + VARHDRSZ, VARHDRSZ);
+ pq_putnchar(p, strlen(p));
+#else
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
pq_putnchar(outputstr, strlen(outputstr));
+#endif
pfree(outputstr);
}
}
/* variable length, assume a varlena structure */
len = VARSIZE(attr) - VARHDRSZ;
+#ifdef MB
+ pq_putncharlen(VARDATA(attr), len);
+#else
pq_putint(len, VARHDRSZ);
pq_putnchar(VARDATA(attr), len);
+#endif
#ifdef IPORTAL_DEBUG
{
char *d = VARDATA(attr);
# Makefile for commands
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.12 1998/04/06 00:22:19 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.13 1998/06/16 07:29:20 momjian Exp $
#
#-------------------------------------------------------------------------
CFLAGS += -I..
+ifdef MB
+CFLAGS += -DMB=$(MB)
+endif
+
OBJS = async.o creatinh.o command.o copy.o defind.o define.o \
remove.o rename.o vacuum.o version.o view.o cluster.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)
* Routines for handling of 'SET var TO',
* 'SHOW var' and 'RESET var' statements.
*
- * $Id: variable.c,v 1.6 1998/06/15 19:28:17 momjian Exp $
+ * $Id: variable.c,v 1.7 1998/06/16 07:29:21 momjian Exp $
*
*/
#include "commands/variable.h"
#include "utils/builtins.h"
#include "optimizer/internal.h"
+#ifdef MB
+#include "regex/pg_wchar.h"
+#endif
extern Cost _cpu_page_wight_;
extern Cost _cpu_index_page_wight_;
return TRUE;
} /* reset_timezone() */
+#ifdef MB
+/*-----------------------------------------------------------------------*/
+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(MB));
+ }
+ }
+ 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 = MB;
+ }
+ } else {
+ encoding = MB;
+ }
+ pg_set_client_encoding(encoding);
+ return TRUE;
+}
+
+/*-----------------------------------------------------------------------*/
+#endif
+
/*-----------------------------------------------------------------------*/
struct VariableParsers
{
{
"r_plans", parse_r_plans, show_r_plans, reset_r_plans
},
+#ifdef MB
+ {
+ "client_encoding", parse_client_encoding, show_client_encoding, reset_client_encoding
+ },
+#endif
{
NULL, NULL, NULL, NULL
}
# Makefile for libpq subsystem (backend half of libpq interface)
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.11 1998/04/06 00:22:39 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/libpq/Makefile,v 1.12 1998/06/16 07:29:22 momjian Exp $
#
#-------------------------------------------------------------------------
LDFLAGS+= $(KRBLIBS)
endif
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
+
OBJS = be-dumpdata.o be-fsstubs.o be-pqexec.o pqcomprim.o\
auth.o hba.o crypt.o pqcomm.o portal.o util.o portalbuf.o pqpacket.o pqsignal.o \
password.o
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.44 1998/06/15 19:28:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.45 1998/06/16 07:29:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* pq_putstr - send a null terminated string to connection
* pq_putnchar - send n characters to connection
* pq_putint - send an integer to connection
+ * pq_putncharlen - send n characters to connection
+ * (also send an int header indicating
+ * the length)
* pq_getinaddr - initialize address from host and port number
* pq_getinserv - initialize address from host and service name
* pq_connect - create remote input / output connection
#include "libpq/auth.h"
#include "libpq/libpq.h" /* where the declarations go */
#include "storage/ipc.h"
+#ifdef MB
+#include "commands/variable.h"
+#endif
/* ----------------
* declarations
{
int c = '\0';
+#ifdef MB
+ unsigned char *p, *ps;
+ int len;
+
+ ps = s;
+ len = maxlen;
+#endif
+
if (Pfin == (FILE *) NULL)
{
/* elog(DEBUG, "Input descriptor is null"); */
*s++ = c;
*s = '\0';
+#ifdef MB
+ p = pg_client_to_server(ps, len);
+ if (ps != p) { /* actual conversion has been done? */
+ strcpy(ps, p);
+ }
+#endif
+
/* -----------------
* If EOF reached let caller know.
* (This will only happen if we hit EOF before the string
void
pq_putstr(char *s)
{
+#ifdef MB
+ unsigned char *p;
+
+ p = pg_server_to_client(s, strlen(s));
+ if (pqPutString(p, Pfout))
+#else
if (pqPutString(s, Pfout))
+#endif
{
sprintf(PQerrormsg,
"FATAL: pq_putstr: fputs() failed: errno=%d\n", errno);
return (STATUS_OK);
}
+
+#ifdef MB
+void
+pq_putncharlen(char *s, int n)
+{
+ unsigned char *p;
+ int len;
+
+ p = pg_server_to_client(s, n);
+ len = strlen(p);
+ pq_putint(len, sizeof(int));
+ pq_putnchar(p, len);
+}
+#endif
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.21 1998/06/15 19:28:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.22 1998/06/16 07:29:25 momjian Exp $
*/
#define FLEX_SCANNER
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.21 1998/06/15 19:28:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.22 1998/06/16 07:29:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
BEGIN(xm);
for(i = 0; yytext[i]; i++)
- if (isupper(yytext[i]))
+ if (isascii((unsigned char)yytext[i]) &&
+ isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
keyword = ScanKeywordLookup((char*)yytext);
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 336 "scan.l"
+#line 337 "scan.l"
{
char* endptr;
YY_BREAK
case 35:
YY_RULE_SETUP
-#line 354 "scan.l"
+#line 355 "scan.l"
{
char* endptr;
YY_BREAK
case 36:
YY_RULE_SETUP
-#line 365 "scan.l"
+#line 366 "scan.l"
{
char* endptr;
YY_BREAK
case 37:
YY_RULE_SETUP
-#line 382 "scan.l"
+#line 383 "scan.l"
{
char* endptr;
YY_BREAK
case 38:
YY_RULE_SETUP
-#line 394 "scan.l"
+#line 395 "scan.l"
{
int i;
ScanKeyword *keyword;
for(i = 0; yytext[i]; i++)
- if (isupper(yytext[i]))
+ if (isascii((unsigned char)yytext[i]) &&
+ isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
keyword = ScanKeywordLookup((char*)yytext);
YY_BREAK
case 39:
YY_RULE_SETUP
-#line 412 "scan.l"
+#line 414 "scan.l"
{ /* ignore */ }
YY_BREAK
case 40:
YY_RULE_SETUP
-#line 414 "scan.l"
+#line 416 "scan.l"
{ return (yytext[0]); }
YY_BREAK
case 41:
YY_RULE_SETUP
-#line 416 "scan.l"
+#line 418 "scan.l"
ECHO;
YY_BREAK
-#line 1305 "lex.yy.c"
+#line 1307 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(xb):
case YY_STATE_EOF(xc):
return 0;
}
#endif
-#line 416 "scan.l"
+#line 418 "scan.l"
void yyerror(char message[])
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.39 1998/05/09 23:15:20 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.40 1998/06/16 07:29:27 momjian Exp $
*
*-------------------------------------------------------------------------
*/
BEGIN(xm);
for(i = 0; yytext[i]; i++)
- if (isupper(yytext[i]))
+ if (isascii((unsigned char)yytext[i]) &&
+ isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
keyword = ScanKeywordLookup((char*)yytext);
ScanKeyword *keyword;
for(i = 0; yytext[i]; i++)
- if (isupper(yytext[i]))
+ if (isascii((unsigned char)yytext[i]) &&
+ isupper(yytext[i]))
yytext[i] = tolower(yytext[i]);
keyword = ScanKeywordLookup((char*)yytext);
# elif MB == UNICODE
# define NONCHAR(c) ((c) > USHRT_MAX)
# define NNONCHAR (CODEMAX-USHRT_MAX)
+# else /* assume 1 byte code such as ISO8859-1 */
+# define NONCHAR(c) ((c) > UCHAR_MAX)
+# define NNONCHAR (CODEMAX-UCHAR_MAX)
# endif
#else
# define NONCHAR(c) ((c) > CHAR_MAX)
for (i = 0; i < css; i++)
if (CHIN(cs, i))
- return ((char) i);
+ return (i);
assert(never);
return (0); /* arbitrary */
}
/*
* misc conversion functions between pg_wchar and other encodings.
* Tatsuo Ishii
- * $Id: utils.c,v 1.2 1998/04/27 17:07:53 scrappy Exp $
+ * $Id: utils.c,v 1.3 1998/06/16 07:29:29 momjian Exp $
*/
#include <regex/pg_wchar.h>
+
/*
- * convert EUC to pg_wchar (EUC process code)
- * caller should allocate enough space for "to"
+ * conversion to pg_wchar is done by "table driven."
+ * to add an encoding support, define mb2wchar_with_len(), mblen()
+ * for the particular encoding. Note that if the encoding is only
+ * supported in the client, you don't need to define
+ * mb2wchar_with_len() function (SJIS is the case).
*/
-static void pg_euc2wchar(const unsigned char *from, pg_wchar *to)
-{
- while (*from) {
- if (*from == SS2) {
- from++;
- *to = *from++;
- } else if (*from == SS3) {
- from++;
- *to = *from++ << 8;
- *to |= 0x3f & *from++;
- } else if (*from & 0x80) {
- *to = *from++ << 8;
- *to |= *from++;
- } else {
- *to = *from++;
- }
- to++;
- }
- *to = 0;
-}
-
-static void pg_eucjp2wchar(const unsigned char *from, pg_wchar *to)
-{
- pg_euc2wchar(from,to);
-}
-
-static void pg_euckr2wchar(const unsigned char *from, pg_wchar *to)
-{
- pg_euc2wchar(from,to);
-}
+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_eucch2wchar(const unsigned char *from, pg_wchar *to)
+static void pg_euc2wchar_with_len
+(const unsigned char *from, pg_wchar *to, int len)
{
- while (*from) {
+ while (*from && len > 0) {
if (*from == SS2) {
from++;
- *to = 0x3f00 & (*from++ << 8);
- *to = *from++;
+ len--;
+ *to = 0xff & *from++;
+ len--;
} else if (*from == SS3) {
from++;
*to = *from++ << 8;
*to |= 0x3f & *from++;
+ len -= 3;
} else if (*from & 0x80) {
*to = *from++ << 8;
*to |= *from++;
+ len -= 2;
} else {
*to = *from++;
+ len--;
}
to++;
}
*to = 0;
}
-static void pg_euccn2wchar(const unsigned char *from, pg_wchar *to)
+static int pg_euc_mblen(const unsigned char *s)
{
- while (*from) {
- if (*from == SS2) {
- from++;
- *to = *from++ << 16;
- *to |= *from++ << 8;
- *to |= *from++;
- } else if (*from == SS3) {
- from++;
- *to = *from++ << 8;
- *to |= 0x3f & *from++;
- } else if (*from & 0x80) {
- *to = *from++ << 8;
- *to |= *from++;
- } else {
- *to = *from++;
- }
- to++;
+ int len;
+
+ if (*s == SS2) {
+ len = 2;
+ } else if (*s == SS3) {
+ len = 3;
+ } else if (*s & 0x80) {
+ len = 2;
+ } else {
+ len = 1;
}
- *to = 0;
+ return(len);
}
/*
- * convert UTF-8 to pg_wchar (UCS-2)
- * caller should allocate enough space for "to"
+ * EUC_JP
*/
-static void pg_utf2wchar(const unsigned char *from, pg_wchar *to)
+static void pg_eucjp2wchar_with_len
+(const unsigned char *from, pg_wchar *to, int len)
{
- unsigned char c1,c2,c3;
- while (*from) {
- if ((*from & 0x80) == 0) {
- *to = *from++;
- } else if ((*from & 0xe0) == 0xc0) {
- c1 = *from++ & 0x1f;
- c2 = *from++ & 0x3f;
- *to = c1 << 6;
- *to |= c2;
- } else if ((*from & 0xe0) == 0xe0) {
- c1 = *from++ & 0x0f;
- c2 = *from++ & 0x3f;
- c3 = *from++ & 0x3f;
- *to = c1 << 12;
- *to |= c2 << 6;
- *to |= c3;
- }
- to++;
- }
- *to = 0;
+ pg_euc2wchar_with_len(from,to,len);
}
-/*
- * convert mule internal code to pg_wchar.
- * in this case pg_wchar consists of following 4 bytes:
- *
- * 0x00(unused)
- * 0x00(ASCII)|leading character (one of LC1, LC12, LC2 or LC22)
- * 0x00(ASCII,1 byte code)|other than 0x00(2 byte code)
- * the lowest byte of the code
- *
- * note that Type N (variable length byte encoding) cannot be represented by
- * this schema. sorry.
- * caller should allocate enough space for "to"
- */
-static void pg_mule2wchar(const unsigned char *from, pg_wchar *to)
+static int pg_eucjp_mblen(const unsigned char *s)
{
- while (*from) {
- if (IS_LC1(*from)) {
- *to = *from++ << 16;
- *to |= *from++;
- } else if (IS_LCPRV1(*from)) {
- from++;
- *to = *from++ << 16;
- *to |= *from++;
- } else if (IS_LC2(*from)) {
- *to = *from++ << 16;
- *to |= *from++ << 8;
- *to |= *from++;
- } else if (IS_LCPRV2(*from)) {
- from++;
- *to = *from++ << 16;
- *to |= *from++ << 8;
- *to |= *from++;
- } else { /* assume ASCII */
- *to = *from++;
- }
- to++;
- }
- *to = 0;
+ return(pg_euc_mblen(s));
}
/*
- * convert EUC to pg_wchar (EUC process code)
- * caller should allocate enough space for "to"
- * len: length of from.
- * "from" not necessarily null terminated.
+ * EUC_KR
*/
-static void pg_euc2wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
-{
- while (*from && len > 0) {
- if (*from == SS2) {
- from++;
- len--;
- *to = 0xff & *from++;
- len--;
- } else if (*from == SS3) {
- from++;
- *to = *from++ << 8;
- *to |= 0x3f & *from++;
- len -= 3;
- } else if (*from & 0x80) {
- *to = *from++ << 8;
- *to |= *from++;
- len -= 2;
- } else {
- *to = *from++;
- len--;
- }
- to++;
- }
- *to = 0;
-}
-
-static void pg_eucjp2wchar_with_len
+static void pg_euckr2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
{
pg_euc2wchar_with_len(from,to,len);
}
-static void pg_euckr2wchar_with_len
-(const unsigned char *from, pg_wchar *to, int len)
+static int pg_euckr_mblen(const unsigned char *s)
{
- pg_euc2wchar_with_len(from,to,len);
+ return(pg_euc_mblen(s));
}
-static void pg_eucch2wchar_with_len
+/*
+ * EUC_CN
+ */
+static void pg_euccn2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
{
while (*from && len > 0) {
*to = 0;
}
-static void pg_euccn2wchar_with_len
+static int pg_euccn_mblen(const unsigned char *s)
+{
+ int len;
+
+ if (*s == SS2) {
+ len = 3;
+ } else if (*s == SS3) {
+ len = 3;
+ } else if (*s & 0x80) {
+ len = 2;
+ } else {
+ len = 1;
+ }
+ return(len);
+}
+
+/*
+ * EUC_TW
+ */
+static void pg_euctw2wchar_with_len
(const unsigned char *from, pg_wchar *to, int len)
{
while (*from && len > 0) {
*to = 0;
}
+static int pg_euctw_mblen(const unsigned char *s)
+{
+ int len;
+
+ if (*s == SS2) {
+ len = 4;
+ } else if (*s == SS3) {
+ len = 3;
+ } else if (*s & 0x80) {
+ len = 2;
+ } else {
+ len = 1;
+ }
+ return(len);
+}
+
/*
* convert UTF-8 to pg_wchar (UCS-2)
* caller should allocate enough space for "to"
*to = 0;
}
+static int pg_utf_mblen(const unsigned char *s)
+{
+ int len = 1;
+
+ if ((*s & 0x80) == 0) {
+ len = 1;
+ } else if ((*s & 0xe0) == 0xc0) {
+ len = 2;
+ } else if ((*s & 0xe0) == 0xe0) {
+ len = 3;
+ }
+ return(len);
+}
+
/*
* convert mule internal code to pg_wchar
* caller should allocate enough space for "to"
*to = 0;
}
-static int pg_euc_mblen(const unsigned char *s)
+static int pg_mule_mblen(const unsigned char *s)
{
int len;
- if (*s == SS2) {
- len = 2;
- } else if (*s == SS3) {
- len = 3;
- } else if (*s & 0x80) {
+ if (IS_LC1(*s)) {
len = 2;
- } else {
- len = 1;
- }
- return(len);
-}
-
-static int pg_eucjp_mblen(const unsigned char *s)
-{
- return(pg_euc_mblen(s));
-}
-
-static int pg_euckr_mblen(const unsigned char *s)
-{
- return(pg_euc_mblen(s));
-}
-
-static int pg_eucch_mblen(const unsigned char *s)
-{
- int len;
-
- if (*s == SS2) {
+ } else if (IS_LCPRV1(*s)) {
len = 3;
- } else if (*s == SS3) {
+ } else if (IS_LC2(*s)) {
len = 3;
- } else if (*s & 0x80) {
- len = 2;
- } else {
+ } else if (IS_LCPRV2(*s)) {
+ len = 4;
+ } else { /* assume ASCII */
len = 1;
}
return(len);
}
-static int pg_euccn_mblen(const unsigned char *s)
+/*
+ * ISO8859-1
+ */
+static void pg_latin12wchar_with_len(const unsigned char *from, pg_wchar *to, int len)
{
- int len;
-
- if (*s == SS2) {
- len = 4;
- } else if (*s == SS3) {
- len = 3;
- } else if (*s & 0x80) {
- len = 2;
- } else {
- len = 1;
+ while (*from && len-- > 0) {
+ *to++ = *from++;
}
- return(len);
+ *to = 0;
}
-static int pg_utf_mblen(const unsigned char *s)
+static int pg_latin1_mblen(const unsigned char *s)
{
- int len = 1;
-
- if ((*s & 0x80) == 0) {
- len = 1;
- } else if ((*s & 0xe0) == 0xc0) {
- len = 2;
- } else if ((*s & 0xe0) == 0xe0) {
- len = 3;
- }
- return(len);
+ return(1);
}
-static int pg_mule_mblen(const unsigned char *s)
+/*
+ * SJIS
+ */
+static int pg_sjis_mblen(const unsigned char *s)
{
int len;
- if (IS_LC1(*s)) {
+ if (*s >= 0xa1 && *s <= 0xdf) { /* 1 byte kana? */
+ len = 1;
+ } else if (*s > 0x7f) { /* kanji? */
len = 2;
- } else if (IS_LCPRV1(*s)) {
- len = 3;
- } else if (IS_LC2(*s)) {
- len = 3;
- } else if (IS_LCPRV2(*s)) {
- len = 4;
- } else { /* assume ASCII */
+ } else { /* should be ASCII */
len = 1;
}
return(len);
}
-typedef struct {
- void (*mb2wchar)(); /* convert a multi-byte string to a wchar */
- void (*mb2wchar_with_len)(); /* convert a multi-byte string to a wchar
- with a limited length */
- int (*mblen)(); /* returns the length of a multi-byte word */
-} pg_wchar_tbl;
-
static pg_wchar_tbl pg_wchar_table[] = {
- {pg_eucjp2wchar, pg_eucjp2wchar_with_len, pg_eucjp_mblen},
- {pg_eucch2wchar, pg_eucch2wchar_with_len, pg_eucch_mblen},
- {pg_euckr2wchar, pg_euckr2wchar_with_len, pg_euckr_mblen},
- {pg_euccn2wchar, pg_euccn2wchar_with_len, pg_euccn_mblen},
- {pg_utf2wchar, pg_utf2wchar_with_len, pg_utf_mblen},
- {pg_mule2wchar, pg_mule2wchar_with_len, pg_mule_mblen}};
+ {pg_eucjp2wchar_with_len, pg_eucjp_mblen},
+ {pg_euccn2wchar_with_len, pg_euccn_mblen},
+ {pg_euckr2wchar_with_len, pg_euckr_mblen},
+ {pg_euctw2wchar_with_len, pg_euctw_mblen},
+ {pg_utf2wchar_with_len, pg_utf_mblen},
+ {pg_mule2wchar_with_len, pg_mule_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, 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[MB].mb2wchar)(from,to);
+ (*pg_wchar_table[MB].mb2wchar_with_len)(from,to,strlen(from));
}
/* convert a multi-byte string to a wchar with a limited length */
return((*pg_wchar_table[MB].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)
{
# Makefile for tcop
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/tcop/Makefile,v 1.16 1998/04/06 00:26:05 momjian Exp $
+# $Header: /cvsroot/pgsql/src/backend/tcop/Makefile,v 1.17 1998/06/16 07:29:30 momjian Exp $
#
#-------------------------------------------------------------------------
CFLAGS+= -I..
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
+
ifeq ($(CC), gcc)
CFLAGS+= -Wno-error
endif
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.76 1998/06/15 19:29:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.77 1998/06/16 07:29:30 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
#include "nodes/memnodes.h"
#endif
+#ifdef MB
+#include "commands/variable.h"
+#endif
+
/* ----------------
* global variables
* ----------------
InitPostgres(DBName);
+#ifdef MB
+ /* set default client encoding */
+ if (!Quiet)
+ {
+ puts("\treset_client_encoding()..");
+ }
+ reset_client_encoding();
+ if (!Quiet)
+ {
+ puts("\treset_client_encoding() done.");
+ }
+#endif
+
/* ----------------
* if an exception is encountered, processing resumes here
* so we abort the current transaction and start a new one.
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface");
- puts("$Revision: 1.76 $ $Date: 1998/06/15 19:29:27 $");
+ puts("$Revision: 1.77 $ $Date: 1998/06/16 07:29:30 $");
}
/* ----------------
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.73 1998/06/16 06:52:15 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.74 1998/06/16 07:29:32 momjian Exp $
*
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
*
tablename = strdup(optarg);
for (i = 0; tablename[i]; i++)
- if (isupper(tablename[i]))
+ if (isascii((unsigned char)tablename[i]) &&
+ isupper(tablename[i]))
tablename[i] = tolower(tablename[i]);
}
break;
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.11 1998/04/06 16:51:44 momjian Exp $
+# $Header: /cvsroot/pgsql/src/bin/psql/Attic/Makefile.in,v 1.12 1998/06/16 07:29:37 momjian Exp $
#
#-------------------------------------------------------------------------
CFLAGS+= $(KRBFLAGS)
endif
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
+
OBJS= psql.o stringutils.o @STRDUP@
all: submake psql
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.145 1998/06/15 19:30:07 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.146 1998/06/16 07:29:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
{
+#ifdef MB
+ for (i = 0; table[i]; i += PQmblen(table+i))
+#else
for (i = 0; table[i]; i++)
- if (isupper(table[i]))
+#endif
+ if (isascii((unsigned char)table[i]) &&
+ isupper(table[i]))
table[i] = tolower(table[i]);
}
}
else
{
+#ifdef MB
+ for (i = 0; object[i]; i += PQmblen(object+i))
+#else
for (i = 0; object[i]; i++)
+#endif
if (isupper(object[i]))
object[i] = tolower(object[i]);
}
{
int i;
- was_bslash = false;
+#ifdef MB
+ int mblen = 1;
+#endif
+ was_bslash = false;
+#ifdef MB
+ for (i = 0; i < len; mblen=PQmblen(line+i), i+=mblen)
+#else
for (i = 0; i < len; i++)
+#endif
{
if (line[i] == '\\' && !in_quote)
{
/* start an extended comment? */
}
- if (querySent && !isspace(line[i]))
+ if (querySent &&
+ isascii((unsigned char)(line[i])) &&
+ !isspace(line[i]))
{
query[0] = '\0';
querySent = false;
if (was_bslash)
was_bslash = false;
+#ifdef MB
+ else if (i > 0 && line[i - mblen] == '\\')
+#else
else if (i > 0 && line[i - 1] == '\\')
+#endif
was_bslash = true;
/* inside a quote? */
else if (xcomment != NULL) /* inside an extended
* comment? */
{
+#ifdef MB
+ if (line[i] == '*' && line[i + mblen] == '/')
+#else
if (line[i] == '*' && line[i + 1] == '/')
+#endif
{
xcomment = NULL;
+#ifdef MB
+ i += mblen;
+#else
i++;
+#endif
}
}
/* possible backslash command? */
+#ifdef MB
+ else if (line[i] == '/' && line[i + mblen] == '*')
+#else
else if (line[i] == '/' && line[i + 1] == '*')
+#endif
{
xcomment = line + i;
+#ifdef MB
+ i += mblen;
+#else
i++;
-
+#endif
}
/* single-line comment? truncate line */
+#ifdef MB
+ else if ((line[i] == '-' && line[i + mblen] == '-') ||
+ (line[i] == '/' && line[i + mblen] == '/'))
+#else
else if ((line[i] == '-' && line[i + 1] == '-') ||
(line[i] == '/' && line[i + 1] == '/'))
+#endif
{
/* print comment at top of query */
if (pset->singleStep)
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: psqlHelp.h,v 1.43 1998/06/15 18:39:49 momjian Exp $
+ * $Id: psqlHelp.h,v 1.44 1998/06/16 07:29:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
"notify <class_name>"},
{"reset",
"set run-time environment back to default",
+#ifdef MB
+ "reset {DateStyle | GEQO | R_PLANS | CLIENT_ENCODING}"},
+#else
"reset {DateStyle | GEQO | R_PLANS}"},
+#endif
{"revoke",
"revoke access control from a user or group",
"revoke <privilege[,privilege,...]> on <rel1>[,...<reln>] from \n\
\t[union [all] select ...];"},
{"set",
"set run-time environment",
+#ifdef MB
+ "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'}"},
+#else
"set DateStyle to {'ISO' | 'SQL' | 'Postgres' | 'European' | 'US' | 'NonEuropean'}\n\
set GEQO to {'ON[=#]' | 'OFF'}\n\
set R_PLANS to {'ON' | 'OFF'}"},
+#endif
{"show",
"show current run-time environment",
+#ifdef MB
+ "show {DateStyle | GEQO | R_PLANS | CLIENT_ENCODING}"},
+#else
"show {DateStyle | GEQO | R_PLANS}"},
+#endif
{"update",
"update tuples",
"update <class_name> set <attr1>=<expr1>,...<attrN>=<exprN> [from <from_clause>] [where <qual>];"},
withval="$with_mb"
case "$withval" in
- EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL)
+ EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1)
MB="$withval";
echo "$ac_t"""enabled with $withval"" 1>&6
;;
*)
- { echo "configure: error: *** You must supply an argument to the --with-mb option one of EUC_JP,EHC_CN,EUC_KR,EUC_TW,UNICODE,MULE_INTERNAL" 1>&2; exit 1; }
+ { echo "configure: 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" 1>&2; exit 1; }
;;
esac
MB="$withval"
[ --with-mb=<encoding> enable multi-byte support ],
[
case "$withval" in
- EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL)
+ EUC_JP|EHC_CN|EUC_KR|EUC_TW|UNICODE|MULE_INTERNAL|LATIN1)
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])
+ 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])
;;
esac
MB="$withval"
* Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var'
* statements
*
- * $Id: variable.h,v 1.2 1998/02/26 04:41:13 momjian Exp $
+ * $Id: variable.h,v 1.3 1998/06/16 07:29:40 momjian Exp $
*
*/
#ifndef VARIABLE_H
extern bool show_geqo(void);
extern bool reset_geqo(void);
extern bool parse_geqo(const char *);
+#ifdef MB
+extern bool show_client_encoding(void);
+extern bool reset_client_encoding(void);
+extern bool parse_client_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 *);
+#endif
#endif /* VARIABLE_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq.h,v 1.15 1998/05/29 17:00:24 momjian Exp $
+ * $Id: libpq.h,v 1.16 1998/06/16 07:29:41 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern int pq_recvoob(char *msgPtr, int len);
extern int pq_getinaddr(struct sockaddr_in * sin, char *host, int port);
extern int pq_getinserv(struct sockaddr_in * sin, char *host, char *serv);
+
+#ifdef MB
+extern void pq_putncharlen(char *s, int n);
+#endif
+
extern int
pq_connect(char *dbname, char *user, char *args, char *hostName,
char *debugTty, char *execFile, short portName);
-/* $Id: pg_wchar.h,v 1.2 1998/04/27 17:09:12 scrappy Exp $ */
+/* $Id: pg_wchar.h,v 1.3 1998/06/16 07:29:43 momjian Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
#define EUC_TW 3 /* EUC for Taiwan */
#define UNICODE 4 /* Unicode UTF-8 */
#define MULE_INTERNAL 5 /* Mule internal code */
+#define LATIN1 6 /* ISO-8859 Latin 1 */
+#define LATIN2 7 /* ISO-8859 Latin 2 */
+#define LATIN3 8 /* ISO-8859 Latin 3 */
+#define LATIN4 9 /* ISO-8859 Latin 4 */
+#define LATIN5 10 /* ISO-8859 Latin 5 */
+/* followings are for client encoding only */
+#define SJIS 16 /* Shift JIS */
#ifdef MB
+# if LATIN1 <= MB && MB <= LATIN5
+typedef unsigned char pg_wchar;
+# else
typedef unsigned int pg_wchar;
+# endif
#else
#define pg_wchar char
#endif
#define IS_LC2(c) ((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99)
#define IS_LCPRV2(c) ((unsigned char)(c) == 0x9c || (unsigned char)(c) == 0x9d)
+/*
+ * leading characters
+ */
+#define LC_ISO8859_1 0x81 /* ISO8859 Latin 1 */
+#define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */
+#define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */
+#define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */
+#define LC_ISO8859_5 0x8d /* ISO8859 Latin 5 */
+#define LC_JISX0201K 0x89 /* Japanese 1 byte kana */
+#define LC_JISX0201R 0x90 /* Japanese 1 byte Roman */
+#define LC_GB2312_80 0x91 /* Chinese */
+#define LC_JISX0208 0x92 /* Japanese Kanji */
+#define LC_KS5601 0x93 /* Korean */
+#define LC_JISX0212 0x94 /* Japanese Kanji (JISX0212) */
+#define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */
+#define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */
+#define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */
+#define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */
+#define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */
+#define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */
+#define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */
+
#ifdef MB
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_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_mic_mblen(const unsigned char *);
extern int pg_mbstrlen(const unsigned char *);
extern int pg_mbstrlen_with_len(const unsigned char *, int);
#endif
# define OUT (USHRT_MAX+1) /* 2 bytes */
# elif MB == UNICODE
# define OUT (USHRT_MAX+1) /* 2 bytes. assuming UCS-2 */
+# else
+# define OUT (UCHAR_MAX+1) /* other codes. assuming 1 byte */
# endif
#else
# define OUT (CHAR_MAX+1) /* a non-character value */
#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.21 1998/06/16 03:17:47 momjian Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.22 1998/06/16 07:29:45 momjian Exp $
#
#-------------------------------------------------------------------------
CFLAGS+= $(KRBFLAGS)
endif
+ifdef MB
+CFLAGS+= -DMB=$(MB)
+endif
+
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
+endif
+
# Shared library stuff
shlib :=
install-shlib-dep :=
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.67 1998/06/15 19:30:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.68 1998/06/16 07:29:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
"PGTZ", "timezone"
},
-
+#ifdef MB
+ {
+ "PGCLIENTENCODING", "client_encoding"
+ },
+#endif
/* internal performance-related settings */
{
"PGCOSTHEAP", "cost_heap"
}
else
for (i = 0; conn->dbName[i]; i++)
- if (isupper(conn->dbName[i]))
+ if (isascii((unsigned char)conn->dbName[i]) &&
+ isupper(conn->dbName[i]))
conn->dbName[i] = tolower(conn->dbName[i]);
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.53 1998/06/15 19:30:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.54 1998/06/16 07:29:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
else
for (i = 0; field_case[i]; i++)
- if (isupper(field_case[i]))
+ if (isascii((unsigned char)field_case[i]) &&
+ isupper(field_case[i]))
field_case[i] = tolower(field_case[i]);
for (i = 0; i < res->numAttributes; i++)
return res->tuples[tup_num][field_num].value;
}
-
-
/* PQgetlength:
returns the length of a field value in bytes. If res is binary,
i.e. a result of a binary portal, then the length returned does
* didn't really belong there.
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.4 1998/06/16 06:57:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.5 1998/06/16 07:29:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <termios.h>
#endif
+#ifdef MB
+#include "regex/pg_wchar.h"
+#include "commands/variable.h"
+#endif
#ifdef TIOCGWINSZ
static struct winsize screen_size;
}
}
-
+#ifdef MB
+/*
+ * returns the byte length of the word beginning s.
+ * Client side encoding is determined by the environment variable
+ * "PGCLIENTENCODING".
+ * if this variable is not defined, the same encoding as
+ * the backend is assumed.
+ */
+int PQmblen(unsigned char *s)
+{
+ char *str;
+ int encoding = -1;
+
+ str = getenv("PGCLIENTENCODING");
+ if (str) {
+ encoding = pg_char_to_encoding(str);
+ }
+ if (encoding < 0) {
+ encoding = MB;
+ }
+ return(pg_encoding_mblen(encoding, s));
+}
+#endif
static void
do_field(PQprintOpt *po, PGresult *res,
if (!skipit)
{
+#ifdef MB
+ int len;
+
+ for (p = pval, o = buf; *p;
+ len = PQmblen(p),memcpy(o,p,len),
+ o+=len, p+=len)
+#else
for (p = pval, o = buf; *p; *(o++) = *(p++))
+#endif
{
if ((fs_len == 1 && (*p == *(po->fieldSep))) || *p == '\\' || *p == '\n')
*(o++) = '\\';
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: libpq-fe.h,v 1.29 1998/05/06 23:51:16 momjian Exp $
+ * $Id: libpq-fe.h,v 1.30 1998/06/16 07:29:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* 0, use variable width */
);
+#ifdef MB
+ extern int PQmblen(unsigned char *s);
+#endif
+
/* === in fe-auth.c === */
extern MsgType fe_getauthsvc(char *PQerrormsg);
extern void fe_setauthsvc(const char *name, char *PQerrormsg);
µçÄÔͼÐÎ |·Ö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)
+
ÄÄÇ»Åͱ׷¡ÇȽº |ÝÂ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)
+
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: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ','\91»úA01\91ÉÏ');
-QUERY: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91ͼ\91ÐÎ','\91·ÖB01\91ÖÐ');
-QUERY: insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±','\91ÈËZ01\91ÏÂ');
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²¼ |
-\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ |\91»úA01\91ÉÏ |
-\91µç\91ÄÔ\91ͼ\91ÐÎ |\91·ÖB01\91ÖÐ |
-\91µç\91ÄÔ\91³Ì\91Ðò\91Ô± |\91ÈËZ01\91Ï |
-(6 rows)
+(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¥É ~ 'Z01';
+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²¼ |
-\91µç\91ÄÔ\91³Ì\91Ðò\91Ô± |\91ÈËZ01\91Ï |
-(2 rows)
-
-QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É ~* '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²¼ |
-\91µç\91ÄÔ\91³Ì\91Ðò\91Ô± |\91ÈËZ01\91Ï |
-(2 rows)
+(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²¼ |
-\91µç\91ÄÔ\91³Ì\91Ðò\91Ô± |\91ÈËZ01\91Ï |
-(2 rows)
+(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²¼ |
-\91µç\91ÄÔ\91³Ì\91Ðò\91Ô± |\91ÈËZ01\91Ï |
-(2 rows)
+(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¥¹|\92ʬB10\92Ãæ |
(2 rows)
-QUERY: select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~ '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
-\92ÍÑ\92¸ì |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
----------------+---------------+--------------
-\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ |
-\91µç\91ÄÔ\91ͼ\91ÐÎ |\91·ÖB01\91ÖÐ |
+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 \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~* '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
-\92ÍÑ\92¸ì |\92ʬ\92Îà\92¥³\92¡¼\92¥É|\92È÷\92¹Í1a\92¤À\92¤è
----------------+---------------+--------------
-\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ|\91»úA01\91ÉÏ |
-\91µç\91ÄÔ\91ͼ\91ÐÎ |\91·ÖB01\91ÖÐ |
+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)
+
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 ¼ÆËã»úÊõÓï;
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 ͪߩѦ¿ë¾î;
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²¼');
-insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91ÏÔ\91ʾ\91ÆÁ','\91»úA01\91ÉÏ');
-insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91ͼ\91ÐÎ','\91·ÖB01\91ÖÐ');
-insert into \92·×\92»»\92µ¡\92ÍÑ\92¸ì values('\91µç\91ÄÔ\91³Ì\91Ðò\91Ô±','\91ÈËZ01\91ÏÂ');
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¥É ~ 'Z01';
-select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ʬ\92Îà\92¥³\92¡¼\92¥É ~* 'z01';
+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 * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~ '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
-select * from \92·×\92»»\92µ¡\92ÍÑ\92¸ì where \92ÍÑ\92¸ì ~* '\91µç\91ÄÔ[\91ÏÔ\91ͼ]';
+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;