Commit eb335a03 authored by Tatsuo Ishii's avatar Tatsuo Ishii

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
parent df432df9
......@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.80 2002/07/16 05:46:35 momjian Exp $
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.81 2002/07/18 02:02:29 ishii Exp $
#
#-------------------------------------------------------------------------
......@@ -131,6 +131,7 @@ endif
ifeq ($(enable_nls), yes)
$(MAKE) -C po $@
endif
$(MAKE) -C utils/mb $@
install-bin: postgres $(POSTGRES_IMP) installdirs
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -4,7 +4,7 @@
# Makefile for utils/mb
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.17 2001/09/22 08:44:47 ishii Exp $
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.18 2002/07/18 02:02:30 ishii Exp $
#
#-------------------------------------------------------------------------
......@@ -12,19 +12,23 @@ subdir = src/backend/utils/mb
top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
OBJS = encnames.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
OBJS = encnames.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o
DIRS = conversion_procs
all: SUBSYS.o
all install installdirs uninstal distprep: SUBSYS.o
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
clean distclean maintainer-clean:
rm -f SUBSYS.o $(OBJS)
@for dir in $(DIRS); do $(MAKE) -C $$dir $@; done
SUBSYS.o: $(OBJS)
@for dir in $(DIRS); do $(MAKE) -C $$dir all || exit; done
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
depend dep:
$(CC) -MM $(CFLAGS) *.c >depend
clean:
rm -f SUBSYS.o $(OBJS)
ifeq (depend,$(wildcard depend))
include depend
endif
/*
* conversion between BIG5 and Mule Internal Code(CNS 116643-1992
* plane 1 and plane 2).
* This program is partially copied from lv(Multilingual file viewer)
* and slightly modified. lv is written and copyrighted by NARITA Tomio
* (nrt@web.ad.jp).
*
* 1999/1/15 Tatsuo Ishii
*
* $Id: big5.c,v 1.8 2001/10/25 05:49:51 momjian Exp $
*/
/* can be used in either frontend or backend */
#include "postgres_fe.h"
#include "mb/pg_wchar.h"
typedef struct
{
unsigned short code,
peer;
} codes_t;
/* map Big5 Level 1 to CNS 11643-1992 Plane 1 */
static codes_t big5Level1ToCnsPlane1[25] = { /* range */
{0xA140, 0x2121},
{0xA1F6, 0x2258},
{0xA1F7, 0x2257},
{0xA1F8, 0x2259},
{0xA2AF, 0x2421},
{0xA3C0, 0x4221},
{0xa3e1, 0x0000},
{0xA440, 0x4421},
{0xACFE, 0x5753},
{0xacff, 0x0000},
{0xAD40, 0x5323},
{0xAFD0, 0x5754},
{0xBBC8, 0x6B51},
{0xBE52, 0x6B50},
{0xBE53, 0x6F5C},
{0xC1AB, 0x7536},
{0xC2CB, 0x7535},
{0xC2CC, 0x7737},
{0xC361, 0x782E},
{0xC3B9, 0x7865},
{0xC3BA, 0x7864},
{0xC3BB, 0x7866},
{0xC456, 0x782D},
{0xC457, 0x7962},
{0xc67f, 0x0000}
};
/* map CNS 11643-1992 Plane 1 to Big5 Level 1 */
static codes_t cnsPlane1ToBig5Level1[26] = { /* range */
{0x2121, 0xA140},
{0x2257, 0xA1F7},
{0x2258, 0xA1F6},
{0x2259, 0xA1F8},
{0x234f, 0x0000},
{0x2421, 0xA2AF},
{0x2571, 0x0000},
{0x4221, 0xA3C0},
{0x4242, 0x0000},
{0x4421, 0xA440},
{0x5323, 0xAD40},
{0x5753, 0xACFE},
{0x5754, 0xAFD0},
{0x6B50, 0xBE52},
{0x6B51, 0xBBC8},
{0x6F5C, 0xBE53},
{0x7535, 0xC2CB},
{0x7536, 0xC1AB},
{0x7737, 0xC2CC},
{0x782D, 0xC456},
{0x782E, 0xC361},
{0x7864, 0xC3BA},
{0x7865, 0xC3B9},
{0x7866, 0xC3BB},
{0x7962, 0xC457},
{0x7d4c, 0x0000}
};
/* map Big5 Level 2 to CNS 11643-1992 Plane 2 */
static codes_t big5Level2ToCnsPlane2[48] = { /* range */
{0xC940, 0x2121},
{0xc94a, 0x0000},
{0xC94B, 0x212B},
{0xC96C, 0x214D},
{0xC9BE, 0x214C},
{0xC9BF, 0x217D},
{0xC9ED, 0x224E},
{0xCAF7, 0x224D},
{0xCAF8, 0x2439},
{0xD77A, 0x3F6A},
{0xD77B, 0x387E},
{0xDBA7, 0x3F6B},
{0xDDFC, 0x4176},
{0xDDFD, 0x4424},
{0xE8A3, 0x554C},
{0xE976, 0x5723},
{0xEB5B, 0x5A29},
{0xEBF1, 0x554B},
{0xEBF2, 0x5B3F},
{0xECDE, 0x5722},
{0xECDF, 0x5C6A},
{0xEDAA, 0x5D75},
{0xEEEB, 0x642F},
{0xEEEC, 0x6039},
{0xF056, 0x5D74},
{0xF057, 0x6243},
{0xF0CB, 0x5A28},
{0xF0CC, 0x6337},
{0xF163, 0x6430},
{0xF16B, 0x6761},
{0xF16C, 0x6438},
{0xF268, 0x6934},
{0xF269, 0x6573},
{0xF2C3, 0x664E},
{0xF375, 0x6762},
{0xF466, 0x6935},
{0xF4B5, 0x664D},
{0xF4B6, 0x6962},
{0xF4FD, 0x6A4C},
{0xF663, 0x6A4B},
{0xF664, 0x6C52},
{0xF977, 0x7167},
{0xF9C4, 0x7166},
{0xF9C5, 0x7234},
{0xF9C6, 0x7240},
{0xF9C7, 0x7235},
{0xF9D2, 0x7241},
{0xf9d6, 0x0000}
};
/* map CNS 11643-1992 Plane 2 to Big5 Level 2 */
static codes_t cnsPlane2ToBig5Level2[49] = { /* range */
{0x2121, 0xC940},
{0x212B, 0xC94B},
{0x214C, 0xC9BE},
{0x214D, 0xC96C},
{0x217D, 0xC9BF},
{0x224D, 0xCAF7},
{0x224E, 0xC9ED},
{0x2439, 0xCAF8},
{0x387E, 0xD77B},
{0x3F6A, 0xD77A},
{0x3F6B, 0xDBA7},
{0x4424, 0x0000},
{0x4176, 0xDDFC},
{0x4177, 0x0000},
{0x4424, 0xDDFD},
{0x554B, 0xEBF1},
{0x554C, 0xE8A3},
{0x5722, 0xECDE},
{0x5723, 0xE976},
{0x5A28, 0xF0CB},
{0x5A29, 0xEB5B},
{0x5B3F, 0xEBF2},
{0x5C6A, 0xECDF},
{0x5D74, 0xF056},
{0x5D75, 0xEDAA},
{0x6039, 0xEEEC},
{0x6243, 0xF057},
{0x6337, 0xF0CC},
{0x642F, 0xEEEB},
{0x6430, 0xF163},
{0x6438, 0xF16C},
{0x6573, 0xF269},
{0x664D, 0xF4B5},
{0x664E, 0xF2C3},
{0x6761, 0xF16B},
{0x6762, 0xF375},
{0x6934, 0xF268},
{0x6935, 0xF466},
{0x6962, 0xF4B6},
{0x6A4B, 0xF663},
{0x6A4C, 0xF4FD},
{0x6C52, 0xF664},
{0x7166, 0xF9C4},
{0x7167, 0xF977},
{0x7234, 0xF9C5},
{0x7235, 0xF9C7},
{0x7240, 0xF9C6},
{0x7241, 0xF9D2},
{0x7245, 0x0000}
};
/* Big Five Level 1 Correspondence to CNS 11643-1992 Plane 4 */
static unsigned short b1c4[][2] = {
{0xC879, 0x2123},
{0xC87B, 0x2124},
{0xC87D, 0x212A},
{0xC8A2, 0x2152}
};
/* Big Five Level 2 Correspondence to CNS 11643-1992 Plane 3 */
static unsigned short b2c3[][2] = {
{0xF9D6, 0x4337},
{0xF9D7, 0x4F50},
{0xF9D8, 0x444E},
{0xF9D9, 0x504A},
{0xF9DA, 0x2C5D},
{0xF9DB, 0x3D7E},
{0xF9DC, 0x4B5C}
};
static unsigned short BinarySearchRange
(codes_t *array, int high, unsigned short code)
{
int low,
mid,
distance,
tmp;
low = 0;
mid = high >> 1;
for (; low <= high; mid = (low + high) >> 1)
{
if ((array[mid].code <= code) && (array[mid + 1].code > code))
{
if (0 == array[mid].peer)
return 0;
if (code >= 0xa140U)
{
/* big5 to cns */
tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8;
high = code & 0x00ff;
low = array[mid].code & 0x00ff;
/*
* NOTE: big5 high_byte: 0xa1-0xfe, low_byte: 0x40-0x7e,
* 0xa1-0xfe (radicals: 0x00-0x3e, 0x3f-0x9c) big5 radix
* is 0x9d. [region_low, region_high]
* We should remember big5 has two different regions
* (above). There is a bias for the distance between these
* regions. 0xa1 - 0x7e + bias = 1 (Distance between 0xa1
* and 0x7e is 1.) bias = - 0x22.
*/
distance = tmp * 0x9d + high - low +
(high >= 0xa1 ? (low >= 0xa1 ? 0 : -0x22)
: (low >= 0xa1 ? +0x22 : 0));
/*
* NOTE: we have to convert the distance into a code
* point. The code point's low_byte is 0x21 plus mod_0x5e.
* In the first, we extract the mod_0x5e of the starting
* code point, subtracting 0x21, and add distance to it.
* Then we calculate again mod_0x5e of them, and restore
* the final codepoint, adding 0x21.
*/
tmp = (array[mid].peer & 0x00ff) + distance - 0x21;
tmp = (array[mid].peer & 0xff00) + ((tmp / 0x5e) << 8)
+ 0x21 + tmp % 0x5e;
return tmp;
}
else
{
/* cns to big5 */
tmp = ((code & 0xff00) - (array[mid].code & 0xff00)) >> 8;
/*
* NOTE: ISO charsets ranges between 0x21-0xfe
* (94charset). Its radix is 0x5e. But there is no
* distance bias like big5.
*/
distance = tmp * 0x5e
+ ((int) (code & 0x00ff) - (int) (array[mid].code & 0x00ff));
/*
* NOTE: Similar to big5 to cns conversion, we extract
* mod_0x9d and restore mod_0x9d into a code point.
*/
low = array[mid].peer & 0x00ff;
tmp = low + distance - (low >= 0xa1 ? 0x62 : 0x40);
low = tmp % 0x9d;
tmp = (array[mid].peer & 0xff00) + ((tmp / 0x9d) << 8)
+ (low > 0x3e ? 0x62 : 0x40) + low;
return tmp;
}
}
else if (array[mid].code > code)
high = mid - 1;
else
low = mid + 1;
}
return 0;
}
unsigned short
BIG5toCNS(unsigned short big5, unsigned char *lc)
{
unsigned short cns = 0;
int i;
if (big5 < 0xc940U)
{
/* level 1 */
for (i = 0; i < sizeof(b1c4) / sizeof(unsigned short); i++)
{
if (b1c4[i][0] == big5)
{
*lc = LC_CNS11643_4;
return (b1c4[i][1] | 0x8080U);
}
}
if (0 < (cns = BinarySearchRange(big5Level1ToCnsPlane1, 23, big5)))
*lc = LC_CNS11643_1;
}
else if (big5 == 0xc94aU)
{
/* level 2 */
*lc = LC_CNS11643_1;
cns = 0x4442;
}
else
{
/* level 2 */
for (i = 0; i < sizeof(b2c3) / sizeof(unsigned short); i++)
{
if (b2c3[i][0] == big5)
{
*lc = LC_CNS11643_3;
return (b2c3[i][1] | 0x8080U);
}
}
if (0 < (cns = BinarySearchRange(big5Level2ToCnsPlane2, 46, big5)))
*lc = LC_CNS11643_2;
}
if (0 == cns)
{ /* no mapping Big5 to CNS 11643-1992 */
*lc = 0;
return (unsigned short) '?';
}
return cns | 0x8080;
}
unsigned short
CNStoBIG5(unsigned short cns, unsigned char lc)
{
int i;
unsigned int big5 = 0;
cns &= 0x7f7f;
switch (lc)
{
case LC_CNS11643_1:
big5 = BinarySearchRange(cnsPlane1ToBig5Level1, 24, cns);
break;
case LC_CNS11643_2:
big5 = BinarySearchRange(cnsPlane2ToBig5Level2, 47, cns);
break;
case LC_CNS11643_3:
for (i = 0; i < sizeof(b2c3) / sizeof(unsigned short); i++)
{
if (b2c3[i][1] == cns)
return (b2c3[i][0]);
}
break;
case LC_CNS11643_4:
for (i = 0; i < sizeof(b1c4) / sizeof(unsigned short); i++)
{
if (b1c4[i][1] == cns)
return (b1c4[i][0]);
}
default:
break;
}
return big5;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -5,7 +5,7 @@
* command, configuration file, and command line options.
* See src/backend/utils/misc/README for more information.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.71 2002/07/13 01:02:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.72 2002/07/18 02:02:30 ishii Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
......@@ -28,6 +28,7 @@
#include "fmgr.h"
#include "libpq/auth.h"
#include "libpq/pqcomm.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "optimizer/cost.h"
#include "optimizer/geqo.h"
......@@ -1115,11 +1116,9 @@ InitializeGUCOptions(void)
if (env != NULL)
SetConfigOption("timezone", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
#ifdef MULTIBYTE
env = getenv("PGCLIENTENCODING");
if (env != NULL)
SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
#endif
}
......
......@@ -27,7 +27,7 @@
# Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.158 2002/07/16 17:48:46 tgl Exp $
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.159 2002/07/18 02:02:30 ishii Exp $
#
#-------------------------------------------------------------------------
......@@ -994,6 +994,11 @@ EOF
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
echo "ok"
# Create pg_conversion and support functions
$ECHO_N "creating conversions... "$ECHO_C
cat $datadir/conversion_create.sql | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
echo "ok"
# Set most system catalogs and built-in functions as world-accessible.
# Some objects may require different permissions by default, so we
# make sure we don't overwrite privilege sets that have already been
......
......@@ -3,7 +3,7 @@
*
* Copyright 2000 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.73 2002/07/15 01:56:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.74 2002/07/18 02:02:30 ishii Exp $
*/
#include "postgres_fe.h"
#include "command.h"
......@@ -38,14 +38,7 @@
#include "print.h"
#include "settings.h"
#include "variables.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#else
/* Grand unified hard-coded badness */
#define pg_encoding_to_char(x) "SQL_ASCII"
#endif
/* functions for use in this file */
......@@ -457,10 +450,9 @@ exec_command(const char *cmd,
puts(pg_encoding_to_char(pset.encoding));
else
{
#ifdef MULTIBYTE
/* set encoding */
if (PQsetClientEncoding(pset.db, encoding) == -1)
psql_error("%s: invalid encoding name\n", encoding);
psql_error("%s: invalid encoding name or conversion proc not found\n", encoding);
else
{
......@@ -468,9 +460,6 @@ exec_command(const char *cmd,
pset.encoding = PQclientEncoding(pset.db);
SetVariable(pset.vars, "ENCODING", pg_encoding_to_char(pset.encoding));
}
#else
psql_error("\\%s: multibyte support is not enabled\n", cmd);
#endif
free(encoding);
}
}
......
/* $Id: pg_wchar.h,v 1.39 2002/06/13 08:30:22 ishii Exp $ */
/* $Id: pg_wchar.h,v 1.40 2002/07/18 02:02:30 ishii Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
......@@ -145,7 +145,7 @@ typedef unsigned int pg_wchar;
* Encoding numeral identificators
*
* WARNING: the order of this table must be same as order
* in the pg_enconv[] (mb/conv.c) and pg_enc2name[] (mb/encnames.c) array!
* in the pg_enc2name[] (mb/encnames.c) array!
*
* If you add some encoding don'y forget check
* PG_ENCODING_[BE|FE]_LAST macros.
......@@ -248,30 +248,6 @@ extern pg_encname *pg_char_to_encname_struct(const char *name);
extern int pg_char_to_encoding(const char *s);
extern const char *pg_encoding_to_char(int encoding);
typedef void (*to_mic_converter) (unsigned char *l, unsigned char *p, int len);
typedef void (*from_mic_converter) (unsigned char *mic, unsigned char *p, int len);
/*
* The backend encoding conversion routines
* Careful:
*
* if (PG_VALID_ENCODING(enc))
* pg_encconv_tbl[ enc ]->foo
*/
#ifndef FRONTEND
typedef struct pg_enconv
{
pg_enc encoding; /* encoding identifier */
to_mic_converter to_mic; /* client encoding to MIC */
from_mic_converter from_mic; /* MIC to client encoding */
to_mic_converter to_unicode; /* client encoding to UTF-8 */
from_mic_converter from_unicode; /* UTF-8 to client encoding */
} pg_enconv;
extern pg_enconv pg_enconv_tbl[];
extern pg_enconv *pg_get_enconv_by_encoding(int encoding);
#endif /* FRONTEND */
/*
* pg_wchar stuff
*/
......@@ -325,7 +301,8 @@ extern int pg_mbcharcliplen(const unsigned char *, int, int);
extern int pg_encoding_max_length(int);
extern int pg_database_encoding_max_length(void);
extern int pg_set_client_encoding(int);
extern void SetDefaultClientEncoding(void);
extern int SetClientEncoding(int encoding, bool doit);
extern int pg_get_client_encoding(void);
extern const char *pg_get_client_encoding_name(void);
......@@ -337,12 +314,9 @@ extern int pg_valid_client_encoding(const char *name);
extern int pg_valid_server_encoding(const char *name);
extern int pg_utf_mblen(const unsigned char *);
extern int pg_find_encoding_converters(int src, int dest,
to_mic_converter *src_to_mic,
from_mic_converter *dest_from_mic);
extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len,
to_mic_converter src_to_mic,
from_mic_converter dest_from_mic);
int src_encoding,
int dest_encoding);
extern unsigned char *pg_client_to_server(unsigned char *, int);
extern unsigned char *pg_server_to_client(unsigned char *, int);
......@@ -350,7 +324,18 @@ extern unsigned char *pg_server_to_client(unsigned char *, int);
extern unsigned short BIG5toCNS(unsigned short, unsigned char *);
extern unsigned short CNStoBIG5(unsigned short, unsigned char);
extern void LocalToUtf(unsigned char *iso, unsigned char *utf,
pg_local_to_utf *map, int size, int encoding, int len);
extern void UtfToLocal(unsigned char *utf, unsigned char *iso,
pg_utf_to_local *map, int size, int len);
char *pg_verifymbstr(const unsigned char *, int);
void pg_ascii2mic(unsigned char *src, unsigned char *dest, int len);
void pg_mic2ascii(unsigned char *src, unsigned char *dest, int len);
void pg_print_bogus_char(unsigned char **mic, unsigned char **p);
#endif /* MULTIBYTE */
#endif /* PG_WCHAR_H */
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.188 2002/06/20 20:29:53 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.189 2002/07/18 02:02:30 ishii Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -2714,7 +2714,6 @@ PQclientEncoding(const PGconn *conn)
return conn->client_encoding;
}
#ifdef MULTIBYTE
int
PQsetClientEncoding(PGconn *conn, const char *encoding)
{
......@@ -2751,15 +2750,6 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
return (status);
}
#else /* without multibytle support */
int
PQsetClientEncoding(PGconn *conn, const char *encoding)
{
return -1;
}
#endif
void
PQtrace(PGconn *conn, FILE *debug_port)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment