1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-13 07:41:39 +03:00

I have committed many support files for CREATE CONVERSION. Default

conversion procs and conversions are added in initdb. Currently
supported conversions are:

UTF-8(UNICODE) <--> SQL_ASCII, ISO-8859-1 to 16, EUC_JP, EUC_KR,
		    EUC_CN, EUC_TW, SJIS, BIG5, GBK, GB18030, UHC,
		    JOHAB, TCVN

EUC_JP <--> SJIS
EUC_TW <--> BIG5
MULE_INTERNAL <--> EUC_JP, SJIS, EUC_TW, BIG5

Note that initial contents of pg_conversion system catalog are created
in the initdb process. So doing initdb required is ideal, it's
possible to add them to your databases by hand, however. To accomplish
this:

psql -f your_postgresql_install_path/share/conversion_create.sql your_database

So I did not bump up the version in cataversion.h.

TODO:
Add more conversion procs
Add [CASCADE|RESTRICT] to DROP CONVERSION
Add tuples to pg_depend
Add regression tests
Write docs
Add SQL99 CONVERT command?
--
Tatsuo Ishii
This commit is contained in:
Tatsuo Ishii
2002-07-18 02:02:30 +00:00
parent df432df9fa
commit eb335a034b
13 changed files with 173 additions and 2276 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.69 2002/06/20 20:29:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.70 2002/07/18 02:02:29 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@ -27,15 +27,7 @@
#include "utils/guc.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#else
/* Grand unified hard-coded badness */
#define pg_get_client_encoding_name() "SQL_ASCII"
#define GetDatabaseEncodingName() "SQL_ASCII"
#endif
/*
* DATESTYLE
@ -472,43 +464,30 @@ show_random_seed(void)
/*
* MULTIBYTE-related functions
*
* If MULTIBYTE support was not compiled, we still allow these variables
* to exist, but you can't set them to anything but "SQL_ASCII". This
* minimizes interoperability problems between non-MB servers and MB-enabled
* clients.
* encoding handling functions
*/
const char *
assign_client_encoding(const char *value, bool doit, bool interactive)
{
#ifdef MULTIBYTE
int encoding;
int old_encoding = 0;
encoding = pg_valid_client_encoding(value);
if (encoding < 0)
return NULL;
/*
* Ugly API here ... can't test validity without setting new encoding...
/* XXX SetClientEncoding depends on namespace functions which are
* not available at startup time. So we accept requested client
* encoding anyway which might not be valid (e.g. no conversion
* procs available).
*/
if (!doit)
old_encoding = pg_get_client_encoding();
if (pg_set_client_encoding(encoding) < 0)
if (SetClientEncoding(encoding, doit) < 0)
{
if (interactive)
elog(ERROR, "Conversion between %s and %s is not supported",
value, GetDatabaseEncodingName());
return NULL;
}
if (!doit)
pg_set_client_encoding(old_encoding);
#else
if (strcasecmp(value, pg_get_client_encoding_name()) != 0)
return NULL;
#endif
return value;
}