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/variable.c | |
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/variable.c')
-rw-r--r-- | src/backend/commands/variable.c | 58 |
1 files changed, 57 insertions, 1 deletions
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 } |