Commit cb7cbc16 authored by Bruce Momjian's avatar Bruce Momjian

Hi, here are the patches to enhance existing MB handling. This time

I have implemented a framework of encoding translation between the
backend and the frontend. Also I have added a new variable setting
command:

SET CLIENT_ENCODING TO 'encoding';

Other features include:
	Latin1 support more 8 bit cleaness

See doc/README.mb for more details. Note that the pacthes are
against May 30 snapshot.

Tatsuo Ishii
parent 0d8e7f63
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
......@@ -18,7 +18,7 @@ have been fixed. I just confirmed that the regression test ran fine
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:
......@@ -36,6 +36,7 @@ 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
Example:
......@@ -49,7 +50,54 @@ 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.
......@@ -64,7 +112,14 @@ Unicode: http://www.unicode.org/
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 $B:n@.(B
postgresql 6.3.2 multi-byte (MB) support README 1998/5/25 $B:n@.(B
$B@P0fC#IW(B
t-ishii@sra.co.jp
......@@ -9,8 +9,8 @@ postgresql 6.3.2 multi-byte (MB) support README 1998/4/21 $B:n@.(B
PostgreSQL $B$K$*$1$k%^%k%A%P%$%H%5%]!<%H$O0J2<$N$h$&$JFCD'$r;}$C$F$$$^$9!#(B
1.$B%^%k%A%P%$%HJ8;z$H$7$F!"F|K\8l!"Cf9q8l$J$I$N3F9q$N(B EUC$B!"(BUnicode$B!"(B
mule internal code $B$,%3%s%Q%$%k;~$KA*Br2DG=!#%G!<%?%Y!<%9$K$O(B
$B$3$N%3!<%I$N$^$^3JG<$5$l$^$9!#(B
mule internal code, ISO-8859-1 $B$,%3%s%Q%$%k;~$KA*Br2DG=!#(B
$B%G!<%?%Y!<%9$K$O$3$N%3!<%I$N$^$^3JG<$5$l$^$9!#(B
2.$B%F!<%V%kL>$K%^%k%A%P%$%HJ8;z$,;HMQ2DG=(B($B$?$@$7!"(BOS $B$,%^%k%A%P%$%H(B
$B$N%U%!%$%kL>$r5v$7$F$$$k$3$H$,I,MW(B)
3.$B%+%i%`L>$K%^%k%A%P%$%HJ8;z$,;HMQ2DG=(B
......@@ -19,6 +19,8 @@ postgresql 6.3.2 multi-byte (MB) support README 1998/4/21 $B:n@.(B
6.$B%^%k%A%P%$%HJ8;z$N(B LIKE $B8!:w$,;HMQ2DG=(B
7.character_length(), position(), substring() $B$G$N%^%k%A%P%$%H(B
$B%5%]!<%H(B
8.$B4D6-JQ?t(B PGCLIENTENCODING $B$K$h$j!"%/%i%$%"%s%HB&$NJ8;z%3!<%I(B
$B$,%P%C%/%(%s%IB&$H0[$k>l9g$K!"<+F0E*$K%3!<%IJQ49$r9T$J$$$^$9!#(B
$B%$%s%9%H!<%k!'(B
$B%G%U%)%k%H$G$O(B PostgreSQL $B$O%^%k%A%P%$%H$r%5%]!<%H$7$F$$$^$;$s!#(B
......@@ -46,6 +48,9 @@ postgresql 6.3.2 multi-byte (MB) support README 1998/4/21 $B:n@.(B
$B$9$J$o$A(B 0xffff $B$^$G$G$9!#(B
MULE_INTERNAL mule $B$NFbIt%3!<%I!#$?$@$7!"(BType N $B$NITDjD9J8;z$O(B
$B%5%]!<%H$7$F$$$^$;$s!#(B
LATIN1 ISO8859 Latin 1$B!#%7%s%0%k%P%$%H$J$s$G$9$1$I!"(B
$B;n$7$H$$$&$3$H$G(B:-)$B$A$J$_$K!"(BLATIN2 etc. $B$O(B
$BL$%5%]!<%H!#(B
$BA*Br$NL\0B$H$7$F$O!"1Q8l$HF|K\8l$7$+;H$o$J$$>l9g$O(B EUC_JP($BF1MM$K!"Cf(B
$B9q8l$7$+;H$o$J$$>l9g$O(B EUC_CN... $B$J$I$H$J$j$^$9(B)$B!"$=$NB>$N8@8l$b;H$$$?(B
......@@ -64,13 +69,101 @@ postgresql 6.3.2 multi-byte (MB) support README 1998/4/21 $B:n@.(B
http://www.sra.co.jp/people/t-ishii/PostgreSQL/ $B$G$b4JC1$J%$%s%9%H!<(B
$B%kJ}K!$r>R2p$7$F$$$^$9!#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$F2<$5$$!#$3$l$O!"D>@\%/%i%$(B
$B%"%s%H(B <--> $B%5!<%P$NJ8;z%3!<%I$rJQ49$9$k$N$G$O$J$/!"0lEYFbItI=8=$G$"(B
$B$k(B mule internal code $B$r7PM3$7$F$$$k$?$a$G$9!#(B
$B%/%i%$%"%s%HB&$NJ8;z%3!<%I$N@_Dj$O!"(B"set client_encoding" $B%3%^%s%I$G(B
$B$b2DG=$G$9!#$?$H$($P!"(B
set client_encoding to 'sjis';
$B$GL@<(E*$K%/%i%$%"%s%HB&$NJ8;z%3!<%I$r(B SJIS $B$K@_Dj$G$-$^$9!#<B:]!"%/(B
$B%i%$%"%s%H$,%5!<%P$K@\B3$9$k:]$K$O(B libpq $B$NCf$G(B "set
client_encoding" $B%3%^%s%I$rH/9T$7$F$$$^$9!#%;%C%7%g%sCf$K(B
set client_encoding" $B%3%^%s%I$rH/9T$9$l$P!"F0E*$KJ8;z%3!<%I$N@ZBX$((B
$B$,$G$-$^$9$,!"$=$N:]$K$O4D6-JQ?t(B PGCLIENTENCODING $B$rF1;~$K%/%i%$%"%s(B
$B%H%"%W%j%1!<%7%g%s$NCf$G@_Dj$7D>$9I,MW$,$"$j$^$9!#(B(psql $B$K$O8=:_$3$N(B
$B5!G=$,$J$$$?$a!";v<B>eF0E*$K%/%i%$%"%s%HB&$NJ8;z%3!<%I$r@_Dj$9$k$3$H(B
$B$,$G$-$^$;$s!#(B)
$B8=:_@_Dj$5$l$F$$$k%/%i%$%"%s%HB&$NJ8;z%3!<%I$O(B
show client_encoding;
$B$G;2>H$G$-$^$9!#$^$?!"(B
reset client_encoding;
$B$O!"%G%U%)%k%H$N%/%i%$%"%s%HJ8;z%3!<%I@_Dj$KI|5"$5$;$^$9!#(Bpostmaster
$B$rN)$A>e$2$k$H$-$K4D6-JQ?t(B PGCLIENTENCODING $B$,@_Dj$5$l$F$$$k$H$=$NJ8(B
$B;z%3!<%I$K!"$=$&$G$J$1$l$P%3%s%Q%$%k;~$K;XDj$7$?%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G$O(B 6.4 snapshot $B$K<h$j9~$^$l$F$$$k(B)
* character_length(), position(), substring() $B$N%^%k%A%P%$%H(B
$BBP1~(B
* octet_length() $BDI2C(B $B"*(B initdb $B$N$d$jD>$7I,MW(B
......
......@@ -7,7 +7,7 @@
#
#
# 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
......@@ -150,7 +150,7 @@ X11_LIBS= -lX11 @X_EXTRA_LIBS@
#
# 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@
##############################################################################
......
......@@ -4,7 +4,7 @@
# 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 $
#
#-------------------------------------------------------------------------
......@@ -13,6 +13,10 @@ include ../../../Makefile.global
CFLAGS+=-I../..
ifdef MB
CFLAGS+= -DMB=$(MB)
endif
OBJS = heaptuple.o heapvalid.o indextuple.o indexvalid.o printtup.o \
scankey.o tupdesc.o
......
......@@ -8,7 +8,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -23,6 +23,10 @@
#include <libpq/libpq.h>
#include <utils/syscache.h>
#ifdef MB
#include <commands/variable.h>
#endif
/* ----------------------------------------------------------------
* printtup / debugtup support
* ----------------------------------------------------------------
......@@ -80,6 +84,9 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
Datum attr;
bool isnull;
Oid typoutput;
#ifdef MB
unsigned char *p;
#endif
/* ----------------
* tell the frontend to expect new tuple data
......@@ -125,8 +132,14 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
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);
}
}
......@@ -268,8 +281,12 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
/* 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);
......
......@@ -4,7 +4,7 @@
# 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 $
#
#-------------------------------------------------------------------------
......@@ -13,11 +13,19 @@ include ../../Makefile.global
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)
......
......@@ -2,7 +2,7 @@
* 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 $
*
*/
......@@ -15,6 +15,9 @@
#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_;
......@@ -519,6 +522,54 @@ reset_timezone()
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
{
......@@ -547,6 +598,11 @@ 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
}
......
......@@ -4,7 +4,7 @@
# 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 $
#
#-------------------------------------------------------------------------
......@@ -19,6 +19,10 @@ CFLAGS+= $(KRBFLAGS)
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
......
......@@ -7,7 +7,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -23,6 +23,9 @@
* 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
......@@ -66,6 +69,9 @@
#include "libpq/auth.h"
#include "libpq/libpq.h" /* where the declarations go */
#include "storage/ipc.h"
#ifdef MB
#include "commands/variable.h"
#endif
/* ----------------
* declarations
......@@ -180,6 +186,14 @@ pq_getstr(char *s, int maxlen)
{
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"); */
......@@ -190,6 +204,13 @@ pq_getstr(char *s, int maxlen)
*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
......@@ -325,7 +346,14 @@ pq_getint(int b)
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);
......@@ -788,3 +816,17 @@ StreamOpen(char *hostName, short portName, Port *port)
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
......@@ -555,7 +555,7 @@ char *yytext;
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -1178,7 +1178,8 @@ YY_RULE_SETUP
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);
......@@ -1194,7 +1195,7 @@ YY_RULE_SETUP
YY_BREAK
case 34:
YY_RULE_SETUP
#line 336 "scan.l"
#line 337 "scan.l"
{
char* endptr;
......@@ -1216,7 +1217,7 @@ YY_RULE_SETUP
YY_BREAK
case 35:
YY_RULE_SETUP
#line 354 "scan.l"
#line 355 "scan.l"
{
char* endptr;
......@@ -1231,7 +1232,7 @@ YY_RULE_SETUP
YY_BREAK
case 36:
YY_RULE_SETUP
#line 365 "scan.l"
#line 366 "scan.l"
{
char* endptr;
......@@ -1252,7 +1253,7 @@ YY_RULE_SETUP
YY_BREAK
case 37:
YY_RULE_SETUP
#line 382 "scan.l"
#line 383 "scan.l"
{
char* endptr;
......@@ -1266,13 +1267,14 @@ YY_RULE_SETUP
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);
......@@ -1288,20 +1290,20 @@ YY_RULE_SETUP
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):
......@@ -2187,7 +2189,7 @@ int main()
return 0;
}
#endif
#line 416 "scan.l"
#line 418 "scan.l"
void yyerror(char message[])
......
......@@ -8,7 +8,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -320,7 +320,8 @@ other .
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);
......@@ -396,7 +397,8 @@ other .
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);
......
......@@ -127,6 +127,9 @@ extern "C"
# 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)
......
......@@ -1344,7 +1344,7 @@ cset *cs;
for (i = 0; i < css; i++)
if (CHIN(cs, i))
return ((char) i);
return (i);
assert(never);
return (0); /* arbitrary */
}
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
# 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 $
#
#-------------------------------------------------------------------------
......@@ -13,6 +13,10 @@ include ../../Makefile.global
CFLAGS+= -I..
ifdef MB
CFLAGS+= -DMB=$(MB)
endif
ifeq ($(CC), gcc)
CFLAGS+= -Wno-error
endif
......
......@@ -7,7 +7,7 @@
*
*
* 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
......@@ -83,6 +83,10 @@
#include "nodes/memnodes.h"
#endif
#ifdef MB
#include "commands/variable.h"
#endif
/* ----------------
* global variables
* ----------------
......@@ -1270,6 +1274,19 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
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.
......@@ -1308,7 +1325,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
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 $");
}
/* ----------------
......
......@@ -21,7 +21,7 @@
*
*
* 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
*
......@@ -597,7 +597,8 @@ main(int argc, char **argv)
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;
......
......@@ -7,7 +7,7 @@
#
#
# 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 $
#
#-------------------------------------------------------------------------
......@@ -24,6 +24,10 @@ LDFLAGS+= $(KRBLIBS)
CFLAGS+= $(KRBFLAGS)
endif
ifdef MB
CFLAGS+= -DMB=$(MB)
endif
OBJS= psql.o stringutils.o @STRDUP@
all: submake psql
......
......@@ -7,7 +7,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -639,8 +639,13 @@ tableDesc(PsqlSettings *pset, char *table, FILE *fout)
}
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]);
}
......@@ -811,7 +816,11 @@ objectDescription(PsqlSettings *pset, char *object, FILE *fout)
}
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]);
}
......@@ -2296,9 +2305,16 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
{
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)
{
......@@ -2322,7 +2338,9 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
/* start an extended comment? */
}
if (querySent && !isspace(line[i]))
if (querySent &&
isascii((unsigned char)(line[i])) &&
!isspace(line[i]))
{
query[0] = '\0';
querySent = false;
......@@ -2330,7 +2348,11 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
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? */
......@@ -2339,22 +2361,42 @@ MainLoop(PsqlSettings *pset, char *query, FILE *source)
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)
......
......@@ -5,7 +5,7 @@
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -263,7 +263,11 @@ static struct _helpStruct QL_HELP[] = {
"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\
......@@ -284,12 +288,23 @@ static struct _helpStruct QL_HELP[] = {
\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>];"},
......
......@@ -807,12 +807,12 @@ if test "${with_mb+set}" = set; then
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"
......
......@@ -194,12 +194,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)
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"
......
......@@ -2,7 +2,7 @@
* 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
......@@ -54,5 +54,17 @@ extern bool set_geqo(void);
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 */
......@@ -6,7 +6,7 @@
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -272,6 +272,11 @@ extern int pq_sendoob(char *msg, int len);
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
......@@ -11,9 +11,20 @@
#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
......@@ -32,6 +43,28 @@ typedef unsigned int pg_wchar;
#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);
......@@ -40,6 +73,8 @@ extern int pg_wchar_strncmp(const pg_wchar *, const pg_wchar *, size_t);
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
......
......@@ -203,6 +203,8 @@ struct re_guts
# 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 */
......
......@@ -7,7 +7,7 @@
#
#
# 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 $
#
#-------------------------------------------------------------------------
......@@ -25,9 +25,17 @@ ifdef KRBVERS
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 :=
......
......@@ -7,7 +7,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -120,7 +120,11 @@ struct EnvironmentOptions
{
"PGTZ", "timezone"
},
#ifdef MB
{
"PGCLIENTENCODING", "client_encoding"
},
#endif
/* internal performance-related settings */
{
"PGCOSTHEAP", "cost_heap"
......@@ -371,7 +375,8 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, cons
}
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]);
}
......
......@@ -7,7 +7,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -1264,7 +1264,8 @@ PQfnumber(PGresult *res, const char *field_name)
}
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++)
......@@ -1466,8 +1467,6 @@ PQgetvalue(PGresult *res, int tup_num, int field_num)
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
......
......@@ -9,7 +9,7 @@
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -28,6 +28,10 @@
#include <termios.h>
#endif
#ifdef MB
#include "regex/pg_wchar.h"
#include "commands/variable.h"
#endif
#ifdef TIOCGWINSZ
static struct winsize screen_size;
......@@ -469,7 +473,29 @@ PQprintTuples(PGresult *res,
}
}
#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,
......@@ -504,7 +530,15 @@ 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++) = '\\';
......
......@@ -6,7 +6,7 @@
*
* 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 $
*
*-------------------------------------------------------------------------
*/
......@@ -364,6 +364,10 @@ extern "C"
* 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);
......
......@@ -53,3 +53,35 @@ QUERY: select * from
电脑图形 |分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)
......@@ -53,3 +53,35 @@ QUERY: select * from 計算機
컴퓨터그래픽스 |分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)
This diff is collapsed.
......@@ -13,3 +13,7 @@ select * 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 计算机术语;
......@@ -13,3 +13,7 @@ select * 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 計算機용어;
......@@ -5,17 +5,68 @@ create index
insert into גђ values('Ԓ咡ǒג쒥','A01');
insert into גђ values('Ԓ咡钥ՒÒ','ʬB10');
insert into גђ values('Ԓ咡ג풥钥ޒ','Z01');
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 ʬ ~* 'z01';
select * from גђ where ʬ ~* 'z01';
select * from גђ where ʬ like '_Z01_';
select * from גђ where ʬ like '_Z%';
select * from גђ where ђ ~ 'Ԓ咡[ǒ]';
select * from גђ where ђ ~* 'Ԓ咡[ǒ]';
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 גђ;
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 Ƒ㑻;
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 ͪߩѦ듾;
drop table test;
create table test (t text);
insert into test values('ENGLISH');
insert into test values('FRANAIS');
insert into test values('ESPAOL');
insert into test values('SLENSKA');
insert into test values('ENGLISH FRANAIS ESPAOL SLENSKA');
vacuum test;
select * from test;
select * from test where t = 'ESPAOL';
select * from test where t ~* 'espaol';
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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment