1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-24 09:27:52 +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

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.341 2002/07/16 22:12:20 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.342 2002/07/18 02:02:30 ishii Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -62,13 +62,7 @@
#include "utils/numeric.h"
#include "utils/datetime.h"
#include "utils/date.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#else
#define GetStandardEncoding() 0 /* PG_SQL_ASCII */
#define GetStandardEncodingName() "SQL_ASCII"
#endif
extern List *parsetree; /* final parse result is delivered here */
@@ -3570,28 +3564,23 @@ createdb_opt_item:
| ENCODING opt_equal Sconst
{
int encoding;
#ifdef MULTIBYTE
encoding = pg_char_to_encoding($3);
if (encoding == -1)
if (pg_valid_server_encoding($3) < 0)
elog(ERROR, "%s is not a valid encoding name", $3);
#else
if (strcasecmp($3, GetStandardEncodingName()) != 0)
elog(ERROR, "Multi-byte support is not enabled");
encoding = GetStandardEncoding();
#endif
encoding = pg_char_to_encoding($3);
$$ = makeNode(DefElem);
$$->defname = "encoding";
$$->arg = (Node *)makeInteger(encoding);
}
| ENCODING opt_equal Iconst
{
#ifdef MULTIBYTE
if (!pg_get_enconv_by_encoding($3))
const char *encoding_name;
encoding_name = pg_encoding_to_char($3);
if (!strcmp(encoding_name,"") ||
pg_valid_server_encoding(encoding_name) < 0)
elog(ERROR, "%d is not a valid encoding code", $3);
#else
if ($3 != GetStandardEncoding())
elog(ERROR, "Multi-byte support is not enabled");
#endif
$$ = makeNode(DefElem);
$$->defname = "encoding";
$$->arg = (Node *)makeInteger($3);