Skip to content

Commit 2277671

Browse files
committed
Commit Karel's patch.
------------------------------------------------------------------- Subject: Re: [PATCHES] encoding names From: Karel Zak <zakkr@zf.jcu.cz> To: Peter Eisentraut <peter_e@gmx.net> Cc: pgsql-patches <pgsql-patches@postgresql.org> Date: Fri, 31 Aug 2001 17:24:38 +0200 On Thu, Aug 30, 2001 at 01:30:40AM +0200, Peter Eisentraut wrote: > > - convert encoding 'name' to 'id' > > I thought we decided not to add functions returning "new" names until we > know exactly what the new names should be, and pending schema Ok, the patch not to add functions. > better > > ...(): encoding name too long Fixed. I found new bug in command/variable.c in parse_client_encoding(), nobody probably never see this error: if (pg_set_client_encoding(encoding)) { elog(ERROR, "Conversion between %s and %s is not supported", value, GetDatabaseEncodingName()); } because pg_set_client_encoding() returns -1 for error and 0 as true. It's fixed too. IMHO it can be apply. Karel PS: * following files are renamed: src/utils/mb/Unicode/KOI8_to_utf8.map --> src/utils/mb/Unicode/koi8r_to_utf8.map src/utils/mb/Unicode/WIN_to_utf8.map --> src/utils/mb/Unicode/win1251_to_utf8.map src/utils/mb/Unicode/utf8_to_KOI8.map --> src/utils/mb/Unicode/utf8_to_koi8r.map src/utils/mb/Unicode/utf8_to_WIN.map --> src/utils/mb/Unicode/utf8_to_win1251.map * new file: src/utils/mb/encname.c * removed file: src/utils/mb/common.c -- Karel Zak <zakkr@zf.jcu.cz> http://home.zf.jcu.cz/~zakkr/ C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
1 parent 50aa302 commit 2277671

File tree

21 files changed

+479
-402
lines changed

21 files changed

+479
-402
lines changed

src/backend/commands/dbcommands.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.79 2001/08/26 16:55:59 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.80 2001/09/06 04:57:28 ishii Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -36,6 +36,10 @@
3636
#include "utils/fmgroids.h"
3737
#include "utils/syscache.h"
3838

39+
#ifdef MULTIBYTE
40+
#include "mb/pg_wchar.h" /* encoding check */
41+
#endif
42+
3943

4044
/* non-export function prototypes */
4145
static bool get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP,
@@ -142,6 +146,13 @@ createdb(const char *dbname, const char *dbpath,
142146
if (encoding < 0)
143147
encoding = src_encoding;
144148

149+
#ifdef MULTIBYTE
150+
/* Some encodings are client only */
151+
if (!PG_VALID_BE_ENCODING( encoding ))
152+
elog(ERROR, "CREATE DATABASE: invalid backend encoding");
153+
#else
154+
Assert(encoding == 0); /* zero is PG_SQL_ASCII */
155+
#endif
145156
/*
146157
* Preassign OID for pg_database tuple, so that we can compute db
147158
* path.

src/backend/commands/variable.c

Lines changed: 8 additions & 9 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.51 2001/06/30 22:03:25 petere Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.52 2001/09/06 04:57:28 ishii Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -34,8 +34,8 @@
3434
#include "mb/pg_wchar.h"
3535
#else
3636
/* Grand unified hard-coded badness */
37-
#define pg_encoding_to_char(x) "SQL_ASCII"
38-
#define pg_get_client_encoding() 0
37+
#define pg_get_client_encoding_name() "SQL_ASCII"
38+
#define GetDatabaseEncodingName() "SQL_ASCII"
3939
#endif
4040

4141

@@ -559,15 +559,15 @@ parse_client_encoding(char *value)
559559
}
560560
else
561561
{
562-
if (pg_set_client_encoding(encoding))
562+
if (pg_set_client_encoding(encoding) < 0)
563563
{
564564
elog(ERROR, "Conversion between %s and %s is not supported",
565-
value, pg_encoding_to_char(GetDatabaseEncoding()));
565+
value, GetDatabaseEncodingName());
566566
}
567567
}
568568
#else
569569
if (value &&
570-
strcasecmp(value, pg_encoding_to_char(pg_get_client_encoding())) != 0)
570+
strcasecmp(value, pg_get_client_encoding_name()) != 0)
571571
elog(ERROR, "Client encoding %s is not supported", value);
572572
#endif
573573
return TRUE;
@@ -577,7 +577,7 @@ static bool
577577
show_client_encoding(void)
578578
{
579579
elog(NOTICE, "Current client encoding is %s",
580-
pg_encoding_to_char(pg_get_client_encoding()));
580+
pg_get_client_encoding_name());
581581
return TRUE;
582582
}
583583

@@ -619,8 +619,7 @@ parse_server_encoding(char *value)
619619
static bool
620620
show_server_encoding(void)
621621
{
622-
elog(NOTICE, "Current server encoding is %s",
623-
pg_encoding_to_char(GetDatabaseEncoding()));
622+
elog(NOTICE, "Current server encoding is %s", GetDatabaseEncodingName());
624623
return TRUE;
625624
}
626625

src/backend/parser/gram.y

Lines changed: 3 additions & 3 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.249 2001/08/26 16:55:59 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.250 2001/09/06 04:57:28 ishii Exp $
1515
*
1616
* HISTORY
1717
* AUTHOR DATE MAJOR EVENT
@@ -62,7 +62,7 @@
6262
#ifdef MULTIBYTE
6363
#include "mb/pg_wchar.h"
6464
#else
65-
#define GetStandardEncoding() 0 /* SQL_ASCII */
65+
#define GetStandardEncoding() 0 /* PG_SQL_ASCII */
6666
#define GetStandardEncodingName() "SQL_ASCII"
6767
#endif
6868

@@ -3027,7 +3027,7 @@ createdb_opt_item: LOCATION '=' Sconst
30273027
| ENCODING '=' Iconst
30283028
{
30293029
#ifdef MULTIBYTE
3030-
if (!pg_get_encent_by_encoding($3))
3030+
if (!pg_get_enconv_by_encoding($3))
30313031
elog(ERROR, "%d is not a valid encoding code", $3);
30323032
#else
30333033
if ($3 != GetStandardEncoding())

src/backend/utils/adt/ascii.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* ascii.c
33
*
4-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.8 2001/03/22 06:16:17 momjian Exp $
4+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.9 2001/09/06 04:57:29 ishii Exp $
55
*
66
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
77
*
@@ -78,7 +78,7 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
7878
#define RANGE_160 160
7979

8080

81-
if (enc == LATIN1)
81+
if (enc == PG_LATIN1)
8282
{
8383

8484
/*
@@ -87,7 +87,7 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
8787
ascii = " cL Y \"Ca -R 'u ., ?AAAAAAACEEEEIIII NOOOOOxOUUUUYTBaaaaaaaceeeeiiii nooooo/ouuuuyty";
8888
range = RANGE_160;
8989
}
90-
else if (enc == LATIN2)
90+
else if (enc == PG_LATIN2)
9191
{
9292

9393
/*
@@ -96,7 +96,7 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
9696
ascii = " A L LS \"SSTZ-ZZ a,l'ls ,sstz\"zzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt.";
9797
range = RANGE_160;
9898
}
99-
else if (enc == WIN1250)
99+
else if (enc == PG_WIN1250)
100100
{
101101

102102
/*

src/backend/utils/init/postinit.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.88 2001/08/25 18:52:42 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.89 2001/09/06 04:57:29 ishii Exp $
1212
*
1313
*
1414
*-------------------------------------------------------------------------
@@ -127,7 +127,7 @@ ReverifyMyDatabase(const char *name)
127127
#ifdef MULTIBYTE
128128
SetDatabaseEncoding(dbform->encoding);
129129
#else
130-
if (dbform->encoding != SQL_ASCII)
130+
if (dbform->encoding != PG_SQL_ASCII)
131131
elog(FATAL, "database was initialized with MULTIBYTE encoding %d,\n\tbut the backend was compiled without multibyte support.\n\tlooks like you need to initdb or recompile.",
132132
dbform->encoding);
133133
#endif

src/backend/utils/mb/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# Makefile for utils/mb
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.15 2000/11/30 20:36:11 petere Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.16 2001/09/06 04:57:29 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

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

15-
OBJS = common.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 big5.o
1616

1717
all: SUBSYS.o
1818

@@ -21,13 +21,13 @@ SUBSYS.o: $(OBJS)
2121

2222
utftest.o: utftest.c conv.c wchar.c mbutils.c
2323

24-
sjistest: sjistest.o palloc.o common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
24+
sjistest: sjistest.o palloc.o encnames.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
2525
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
2626

2727
liketest: liketest.o palloc.o $(OBJS)
2828
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
2929

30-
utftest: utftest.o palloc.o common.o wstrcmp.o wstrncmp.o big5.o
30+
utftest: utftest.o palloc.o encnames.o wstrcmp.o wstrncmp.o big5.o
3131
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
3232

3333
depend dep:

src/backend/utils/mb/Unicode/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright 2001 by PostgreSQL Global Development Group
66
#
7-
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Unicode/Makefile,v 1.2 2001/04/29 07:27:38 ishii Exp $
7+
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Unicode/Makefile,v 1.3 2001/09/06 04:57:29 ishii Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -18,8 +18,8 @@ ISO8859MAPS=iso8859_2_to_utf8.map iso8859_3_to_utf8.map \
1818
utf8_to_iso8859_4.map utf8_to_iso8859_5.map
1919

2020

21-
CYRILLICMAPS=KOI8_to_utf8.map WIN_to_utf8.map ALT_to_utf8.map\
22-
utf8_to_KOI8.map utf8_to_WIN.map utf8_to_ALT.map
21+
CYRILLICMAPS=koi8r_to_utf8.map win1251_to_utf8.map alt_to_utf8.map\
22+
utf8_to_koi8r.map utf8_to_win1251.map utf8_to_alt.map
2323

2424
MAPS= $(ISO8859MAPS) $(CYRILLICMAPS)\
2525
big5_to_utf8.map euc_cn_to_utf8.map euc_jp_to_utf8.map \

src/backend/utils/mb/Unicode/UCS_to_cyrillic.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Copyright 2001 by PostgreSQL Global Development Group
44
#
5-
# $Id: UCS_to_cyrillic.pl,v 1.1 2001/04/29 07:27:38 ishii Exp $
5+
# $Id: UCS_to_cyrillic.pl,v 1.2 2001/09/06 04:57:29 ishii Exp $
66
#
77
# Generate UTF-8 <--> ISO8859 code conversion tables from
88
# map files provided by Unicode organization.
@@ -15,10 +15,10 @@
1515
# # and Unicode name (not used in this script)
1616

1717
require "ucs2utf.pl";
18-
%filename = ('KOI8'=>'koi8-r.txt',
19-
'WIN'=>'cp1251.txt',
18+
%filename = ('KOI8R'=>'koi8-r.txt',
19+
'WIN1251'=>'cp1251.txt',
2020
'ALT'=>'cp866.txt');
21-
@charsets = ('KOI8','ALT','WIN');
21+
@charsets = ('KOI8R','ALT','WIN1251');
2222
foreach $charset (@charsets) {
2323

2424
#

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