diff options
author | Bruce Momjian <bruce@momjian.us> | 1998-06-16 07:29:54 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1998-06-16 07:29:54 +0000 |
commit | cb7cbc16fa4b5933fb5d63052568e3ed6859857b (patch) | |
tree | bed17594c4880549288373de4d400512cbe2f82d /src/backend/commands | |
parent | 0d8e7f6381291b85ad6264365e01143357d70a75 (diff) | |
download | postgresql-cb7cbc16fa4b5933fb5d63052568e3ed6859857b.tar.gz postgresql-cb7cbc16fa4b5933fb5d63052568e3ed6859857b.zip |
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/backend/commands')
-rw-r--r-- | src/backend/commands/Makefile | 10 | ||||
-rw-r--r-- | src/backend/commands/variable.c | 58 |
2 files changed, 66 insertions, 2 deletions
diff --git a/src/backend/commands/Makefile b/src/backend/commands/Makefile index 7e4fe415c3b..fc2b7199ab0 100644 --- a/src/backend/commands/Makefile +++ b/src/backend/commands/Makefile @@ -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) diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 9e138b82a91..51f9d871bdf 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -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 } |