Skip to content

Commit eb335a0

Browse files
committed
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
1 parent df432df commit eb335a0

File tree

13 files changed

+173
-2276
lines changed

13 files changed

+173
-2276
lines changed

src/backend/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.80 2002/07/16 05:46:35 momjian Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.81 2002/07/18 02:02:29 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -131,6 +131,7 @@ endif
131131
ifeq ($(enable_nls), yes)
132132
$(MAKE) -C po $@
133133
endif
134+
$(MAKE) -C utils/mb $@
134135

135136
install-bin: postgres $(POSTGRES_IMP) installdirs
136137
$(INSTALL_PROGRAM) postgres$(X) $(DESTDIR)$(bindir)/postgres$(X)

src/backend/commands/variable.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.69 2002/06/20 20:29:27 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.70 2002/07/18 02:02:29 ishii Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -27,15 +27,7 @@
2727
#include "utils/guc.h"
2828
#include "utils/syscache.h"
2929
#include "utils/tqual.h"
30-
31-
#ifdef MULTIBYTE
3230
#include "mb/pg_wchar.h"
33-
#else
34-
/* Grand unified hard-coded badness */
35-
#define pg_get_client_encoding_name() "SQL_ASCII"
36-
#define GetDatabaseEncodingName() "SQL_ASCII"
37-
#endif
38-
3931

4032
/*
4133
* DATESTYLE
@@ -472,43 +464,30 @@ show_random_seed(void)
472464

473465

474466
/*
475-
* MULTIBYTE-related functions
476-
*
477-
* If MULTIBYTE support was not compiled, we still allow these variables
478-
* to exist, but you can't set them to anything but "SQL_ASCII". This
479-
* minimizes interoperability problems between non-MB servers and MB-enabled
480-
* clients.
467+
* encoding handling functions
481468
*/
482469

483470
const char *
484471
assign_client_encoding(const char *value, bool doit, bool interactive)
485472
{
486-
#ifdef MULTIBYTE
487473
int encoding;
488-
int old_encoding = 0;
489474

490475
encoding = pg_valid_client_encoding(value);
491476
if (encoding < 0)
492477
return NULL;
493-
/*
494-
* Ugly API here ... can't test validity without setting new encoding...
478+
479+
/* XXX SetClientEncoding depends on namespace functions which are
480+
* not available at startup time. So we accept requested client
481+
* encoding anyway which might not be valid (e.g. no conversion
482+
* procs available).
495483
*/
496-
if (!doit)
497-
old_encoding = pg_get_client_encoding();
498-
if (pg_set_client_encoding(encoding) < 0)
484+
if (SetClientEncoding(encoding, doit) < 0)
499485
{
500486
if (interactive)
501487
elog(ERROR, "Conversion between %s and %s is not supported",
502488
value, GetDatabaseEncodingName());
503489
return NULL;
504490
}
505-
if (!doit)
506-
pg_set_client_encoding(old_encoding);
507-
#else
508-
if (strcasecmp(value, pg_get_client_encoding_name()) != 0)
509-
return NULL;
510-
#endif
511-
512491
return value;
513492
}
514493

src/backend/parser/gram.y

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.341 2002/07/16 22:12:20 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.342 2002/07/18 02:02:30 ishii Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -62,13 +62,7 @@
6262
#include "utils/numeric.h"
6363
#include "utils/datetime.h"
6464
#include "utils/date.h"
65-
66-
#ifdef MULTIBYTE
6765
#include "mb/pg_wchar.h"
68-
#else
69-
#define GetStandardEncoding() 0 /* PG_SQL_ASCII */
70-
#define GetStandardEncodingName() "SQL_ASCII"
71-
#endif
7266

7367
extern List *parsetree; /* final parse result is delivered here */
7468

@@ -3570,28 +3564,23 @@ createdb_opt_item:
35703564
| ENCODING opt_equal Sconst
35713565
{
35723566
int encoding;
3573-
#ifdef MULTIBYTE
3574-
encoding = pg_char_to_encoding($3);
3575-
if (encoding == -1)
3567+
3568+
if (pg_valid_server_encoding($3) < 0)
35763569
elog(ERROR, "%s is not a valid encoding name", $3);
3577-
#else
3578-
if (strcasecmp($3, GetStandardEncodingName()) != 0)
3579-
elog(ERROR, "Multi-byte support is not enabled");
3580-
encoding = GetStandardEncoding();
3581-
#endif
3570+
encoding = pg_char_to_encoding($3);
3571+
35823572
$$ = makeNode(DefElem);
35833573
$$->defname = "encoding";
35843574
$$->arg = (Node *)makeInteger(encoding);
35853575
}
35863576
| ENCODING opt_equal Iconst
35873577
{
3588-
#ifdef MULTIBYTE
3589-
if (!pg_get_enconv_by_encoding($3))
3578+
const char *encoding_name;
3579+
3580+
encoding_name = pg_encoding_to_char($3);
3581+
if (!strcmp(encoding_name,"") ||
3582+
pg_valid_server_encoding(encoding_name) < 0)
35903583
elog(ERROR, "%d is not a valid encoding code", $3);
3591-
#else
3592-
if ($3 != GetStandardEncoding())
3593-
elog(ERROR, "Multi-byte support is not enabled");
3594-
#endif
35953584
$$ = makeNode(DefElem);
35963585
$$->defname = "encoding";
35973586
$$->arg = (Node *)makeInteger($3);

src/backend/utils/mb/Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,31 @@
44
# Makefile for utils/mb
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.17 2001/09/22 08:44:47 ishii Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.18 2002/07/18 02:02:30 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/backend/utils/mb
1212
top_builddir = ../../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = encnames.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
15+
OBJS = encnames.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o
16+
DIRS = conversion_procs
1617

17-
all: SUBSYS.o
18+
all install installdirs uninstal distprep: SUBSYS.o
19+
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done
20+
21+
clean distclean maintainer-clean:
22+
rm -f SUBSYS.o $(OBJS)
23+
@for dir in $(DIRS); do $(MAKE) -C $$dir $@; done
1824

1925
SUBSYS.o: $(OBJS)
26+
@for dir in $(DIRS); do $(MAKE) -C $$dir all || exit; done
2027
$(LD) $(LDREL) $(LDOUT) SUBSYS.o $(OBJS)
2128

2229
depend dep:
2330
$(CC) -MM $(CFLAGS) *.c >depend
2431

25-
clean:
26-
rm -f SUBSYS.o $(OBJS)
27-
2832
ifeq (depend,$(wildcard depend))
2933
include depend
3034
endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy