summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorBruce Momjian1998-06-16 07:29:54 +0000
committerBruce Momjian1998-06-16 07:29:54 +0000
commitcb7cbc16fa4b5933fb5d63052568e3ed6859857b (patch)
treebed17594c4880549288373de4d400512cbe2f82d /src/bin
parent0d8e7f6381291b85ad6264365e01143357d70a75 (diff)
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
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/pg_dump/pg_dump.c5
-rw-r--r--src/bin/psql/Makefile.in6
-rw-r--r--src/bin/psql/psql.c52
-rw-r--r--src/bin/psql/psqlHelp.h17
4 files changed, 71 insertions, 9 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 613b2a5b88a..d80a2676dc1 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -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;
diff --git a/src/bin/psql/Makefile.in b/src/bin/psql/Makefile.in
index 071ab34c509..d34abdef46c 100644
--- a/src/bin/psql/Makefile.in
+++ b/src/bin/psql/Makefile.in
@@ -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
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index 9f699ad8d74..1ed9e4561fd 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -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)
diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h
index 0ecfa7b6c94..91786543e4b 100644
--- a/src/bin/psql/psqlHelp.h
+++ b/src/bin/psql/psqlHelp.h
@@ -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>];"},