Skip to content

Commit 5eb1d0d

Browse files
committed
Add builtin functions:
pg_char_to_encoding() pg_encoding_to_char()
1 parent d58fa76 commit 5eb1d0d

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

src/backend/utils/init/miscinit.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.39 2000/01/13 18:26:11 petere Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.40 2000/01/18 05:10:29 ishii Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -67,12 +67,24 @@ SetDatabaseName(const char *name)
6767

6868
#ifndef MULTIBYTE
6969
/* even if MULTIBYTE is not enabled, this function is neccesary
70-
* since pg_proc.h has an entry for it.
70+
* since pg_proc.h has entries for them.
7171
*/
7272
const char *
7373
getdatabaseencoding()
7474
{
75-
elog(ERROR, "MultiByte strings (MB) must be enabled to use this function");
75+
elog(ERROR, "MultiByte support must be enabled to use this function");
76+
return ("");
77+
}
78+
79+
const char *pg_encoding_to_char(int encoding)
80+
{
81+
elog(ERROR, "MultiByte support must be enabled to use this function");
82+
return ("");
83+
}
84+
85+
int pg_char_to_encoding(const char *encoding_string)
86+
{
87+
elog(ERROR, "MultiByte support must be enabled to use this function");
7688
return ("");
7789
}
7890

src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*
3737
* Copyright (c) 1994, Regents of the University of California
3838
*
39-
* $Id: catversion.h,v 1.7 2000/01/14 00:53:50 tgl Exp $
39+
* $Id: catversion.h,v 1.8 2000/01/18 05:08:29 ishii Exp $
4040
*
4141
*-------------------------------------------------------------------------
4242
*/
@@ -52,6 +52,6 @@
5252
*/
5353

5454
/* yyyymmddN */
55-
#define CATALOG_VERSION_NO 200001131
55+
#define CATALOG_VERSION_NO 200001171
5656

5757
#endif

src/include/catalog/pg_proc.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.113 2000/01/17 00:40:51 tgl Exp $
9+
* $Id: pg_proc.h,v 1.114 2000/01/18 05:08:29 ishii Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2110,6 +2110,13 @@ DESCR("sequence set value");
21102110

21112111
/* for multi-byte support */
21122112
DATA(insert OID = 1039 ( getdatabaseencoding PGUID 11 f t f 0 f 19 "0" 100 0 0 100 getdatabaseencoding - ));
2113+
DESCR("encoding name of current database");
2114+
2115+
DATA(insert OID = 1295 ( pg_char_to_encoding PGUID 11 f t f 1 f 23 "19" 100 0 0 100 pg_char_to_encoding - ));
2116+
DESCR("convert encoding name to encoding id");
2117+
2118+
DATA(insert OID = 1597 ( pg_encoding_to_char PGUID 11 f t f 1 f 19 "23" 100 0 0 100 pg_encoding_to_char - ));
2119+
DESCR("convert encoding id to encoding name");
21132120

21142121
/* System-view support functions */
21152122
DATA(insert OID = 1640 ( pg_get_ruledef PGUID 11 f t f 1 f 25 "19" 100 0 0 100 pg_get_ruledef - ));

src/include/mb/pg_wchar.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Id: pg_wchar.h,v 1.12 2000/01/15 18:30:35 petere Exp $ */
1+
/* $Id: pg_wchar.h,v 1.13 2000/01/18 05:08:31 ishii Exp $ */
22

33
#ifndef PG_WCHAR_H
44
#define PG_WCHAR_H
@@ -121,8 +121,13 @@ extern int pg_get_client_encoding(void);
121121
extern unsigned char *pg_client_to_server(unsigned char *, int);
122122
extern unsigned char *pg_server_to_client(unsigned char *, int);
123123
extern int pg_valid_client_encoding(const char *);
124+
125+
/* moved to miscadmin.h
126+
* pg_proc.h now have them.
124127
extern const char *pg_encoding_to_char(int);
125128
extern int pg_char_to_encoding(const char *);
129+
*/
130+
126131
extern int GetDatabaseEncoding(void);
127132
extern void SetDatabaseEncoding(int);
128133
extern void SetTemplateEncoding(int);

src/include/miscadmin.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $Id: miscadmin.h,v 1.47 2000/01/13 18:26:15 petere Exp $
14+
* $Id: miscadmin.h,v 1.48 2000/01/18 05:08:29 ishii Exp $
1515
*
1616
* NOTES
1717
* some of the information in this file will be moved to
@@ -119,10 +119,12 @@ extern char *ExpandDatabasePath(const char *path);
119119
extern void SetDatabaseName(const char *name);
120120
extern void SetDatabasePath(const char *path);
121121

122-
/* even if MB is not enabled, this function is neccesary
122+
/* even if MULTIBYTE is not enabled, this function is neccesary
123123
* since pg_proc.h does have.
124124
*/
125125
extern const char *getdatabaseencoding(void);
126+
extern const char *pg_encoding_to_char(int);
127+
extern int pg_char_to_encoding(const char *);
126128

127129
extern char *getpgusername(void);
128130
extern void SetPgUserName(void);

0 commit comments

Comments
 (0)