aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-07-24 03:32:46 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-07-24 03:32:46 +0000
commitbf00bbb0c4940b80b46b7e5b379cd64184f2262f (patch)
treebf32bf3bafe6f367ee97249c83afb4c9e9a637af /src/include
parent6e66468f3a160878111578a93be2852635eb4f4d (diff)
downloadpostgresql-bf00bbb0c4940b80b46b7e5b379cd64184f2262f.tar.gz
postgresql-bf00bbb0c4940b80b46b7e5b379cd64184f2262f.zip
I really hope that I haven't missed anything in this one...
From: t-ishii@sra.co.jp Attached are patches to enhance the multi-byte support. (patches are against 7/18 snapshot) * determine encoding at initdb/createdb rather than compile time Now initdb/createdb has an option to specify the encoding. Also, I modified the syntax of CREATE DATABASE to accept encoding option. See README.mb for more details. For this purpose I have added new column "encoding" to pg_database. Also pg_attribute and pg_class are changed to catch up the modification to pg_database. Actually I haved added pg_database_mb.h, pg_attribute_mb.h and pg_class_mb.h. These are used only when MB is enabled. The reason having separate files is I couldn't find a way to use ifdef or whatever in those files. I have to admit it looks ugly. No way. * support for PGCLIENTENCODING when issuing COPY command commands/copy.c modified. * support for SQL92 syntax "SET NAMES" See gram.y. * support for LATIN2-5 * add UNICODE regression test case * new test suite for MB New directory test/mb added. * clean up source files Basic idea is to have MB's own subdirectory for easier maintenance. These are include/mb and backend/utils/mb.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/pg_proc.h5
-rw-r--r--src/include/commands/dbcommands.h6
-rw-r--r--src/include/mb/pg_wchar.h (renamed from src/include/regex/pg_wchar.h)60
-rw-r--r--src/include/miscadmin.h11
-rw-r--r--src/include/nodes/parsenodes.h6
-rw-r--r--src/include/regex/regex.h2
6 files changed, 75 insertions, 15 deletions
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index dfbc7568249..bf825737511 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.62 1998/07/18 18:34:17 momjian Exp $
+ * $Id: pg_proc.h,v 1.63 1998/07/24 03:32:16 scrappy Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2077,12 +2077,15 @@ DESCR("trim both ends of string");
DATA(insert OID = 885 ( btrim PGUID 14 f t f 1 f 25 "25" 100 0 0 100 "select btrim($1, \' \')" - ));
DESCR("trim both ends of string");
+
/* SEQUENCEs nextval & currval functions */
DATA(insert OID = 1317 ( nextval PGUID 11 f t f 1 f 23 "25" 100 0 0 100 foo bar ));
DESCR("sequence next value");
DATA(insert OID = 1319 ( currval PGUID 11 f t f 1 f 23 "25" 100 0 0 100 foo bar ));
DESCR("sequence current value");
+/* for multi-byte support */
+DATA(insert OID = 1039 ( getdatabaseencoding PGUID 11 f t f 0 f 19 "0" 100 0 0 100 foo bar ));
/*
* prototypes for functions pg_proc.c
diff --git a/src/include/commands/dbcommands.h b/src/include/commands/dbcommands.h
index 06a291070e9..8675afa5c71 100644
--- a/src/include/commands/dbcommands.h
+++ b/src/include/commands/dbcommands.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: dbcommands.h,v 1.2 1998/07/09 03:28:56 scrappy Exp $
+ * $Id: dbcommands.h,v 1.3 1998/07/24 03:32:19 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,7 +19,11 @@
*/
#define SIGKILLDAEMON1 SIGTERM
+#ifdef MB
+extern void createdb(char *dbname, char *dbpath, int encoding);
+#else
extern void createdb(char *dbname, char *dbpath);
+#endif
extern void destroydb(char *dbname);
#endif /* DBCOMMANDS_H */
diff --git a/src/include/regex/pg_wchar.h b/src/include/mb/pg_wchar.h
index a37c253e1f2..8453f38558d 100644
--- a/src/include/regex/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -1,9 +1,11 @@
-/* $Id: pg_wchar.h,v 1.4 1998/07/18 18:34:24 momjian Exp $ */
+/* $Id: pg_wchar.h,v 1.1 1998/07/24 03:32:24 scrappy Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
#include <sys/types.h>
+#include "postgres.h"
+#include "miscadmin.h" /* for getdatabaseencoding() */
#define EUC_JP 0 /* EUC for Japanese */
#define EUC_CN 1 /* EUC for Chinese */
@@ -16,15 +18,15 @@
#define LATIN3 8 /* ISO-8859 Latin 3 */
#define LATIN4 9 /* ISO-8859 Latin 4 */
#define LATIN5 10 /* ISO-8859 Latin 5 */
+#define LATIN6 11 /* ISO-8859 Latin 6 */
+#define LATIN7 12 /* ISO-8859 Latin 7 */
+#define LATIN8 13 /* ISO-8859 Latin 8 */
+#define LATIN9 14 /* ISO-8859 Latin 9 */
/* followings are for client encoding only */
-#define SJIS 16 /* Shift JIS */
+#define SJIS 32 /* Shift JIS */
-#ifdef MULTIBYTE
-# if LATIN1 <= MULTIBYTE && MULTIBYTE <= LATIN5
-typedef unsigned char pg_wchar;
-# else
+#ifdef MB
typedef unsigned int pg_wchar;
-# endif
#else
#define pg_wchar char
#endif
@@ -65,7 +67,25 @@ typedef unsigned int pg_wchar;
#define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */
#define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */
-#ifdef MULTIBYTE
+#ifdef MB
+typedef struct {
+ int encoding; /* encoding symbol value */
+ char *name; /* encoding name */
+ int is_client_only; /* 0: server/client bothg supported
+ 1: client only */
+ void (*to_mic)(); /* client encoding to MIC */
+ void (*from_mic)(); /* MIC to client encoding */
+} pg_encoding_conv_tbl;
+
+extern pg_encoding_conv_tbl pg_conv_tbl[];
+
+typedef struct {
+ void (*mb2wchar_with_len)(); /* convert a multi-byte string to a wchar */
+ int (*mblen)(); /* returns the length of a multi-byte word */
+} pg_wchar_tbl;
+
+extern pg_wchar_tbl pg_wchar_table[];
+
extern void pg_mb2wchar(const unsigned char *, pg_wchar *);
extern void pg_mb2wchar_with_len(const unsigned char *, pg_wchar *, int);
extern int pg_char_and_wchar_strcmp(const char *, const pg_wchar *);
@@ -74,9 +94,29 @@ extern int pg_char_and_wchar_strncmp(const char *, const pg_wchar *, size_t);
extern size_t pg_wchar_strlen(const pg_wchar *);
extern int pg_mblen(const unsigned char *);
extern int pg_encoding_mblen(int, const unsigned char *);
+extern int pg_mule_mblen(const unsigned char *);
extern int pg_mic_mblen(const unsigned char *);
extern int pg_mbstrlen(const unsigned char *);
extern int pg_mbstrlen_with_len(const unsigned char *, int);
-#endif
+extern pg_encoding_conv_tbl *pg_get_encent_by_encoding(int);
+extern bool show_client_encoding(void);
+extern bool reset_client_encoding(void);
+extern bool parse_client_encoding(const char *);
+extern bool show_server_encoding(void);
+extern bool reset_server_encoding(void);
+extern bool parse_server_encoding(const char *);
+extern int pg_set_client_encoding(int);
+extern int pg_get_client_encoding(void);
+extern unsigned char *pg_client_to_server(unsigned char *, int);
+extern unsigned char *pg_server_to_client(unsigned char *, int);
+extern int pg_valid_client_encoding(const char *);
+extern const char *pg_encoding_to_char(int);
+extern int pg_char_to_encoding(const char *);
+extern int GetDatabaseEncoding(void);
+extern void SetDatabaseEncoding(int);
+extern void SetTemplateEncoding(int);
+extern int GetTemplateEncoding(void);
-#endif
+#endif /* MB */
+
+#endif /* PG_WCHAR_H */
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index a6f22432994..74c8bf71f19 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -11,7 +11,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: miscadmin.h,v 1.27 1998/07/09 03:28:55 scrappy Exp $
+ * $Id: miscadmin.h,v 1.28 1998/07/24 03:32:13 scrappy Exp $
*
* NOTES
* some of the information in this file will be moved to
@@ -116,13 +116,22 @@ extern char *DatabaseName;
extern char *DatabasePath;
/* in utils/misc/database.c */
+#ifdef MB
+extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path, int *encoding);
+#else
extern void GetRawDatabaseInfo(char *name, Oid *owner, Oid *db_id, char *path);
+#endif
extern int GetDatabaseInfo(char *name, Oid *owner, char *path);
extern char *ExpandDatabasePath(char *path);
/* now in utils/init/miscinit.c */
extern void SetDatabaseName(char *name);
extern void SetDatabasePath(char *path);
+/* even if MB is not enabled, this function is neccesary
+ * since pg_proc.h does have.
+ */
+extern const char *getdatabaseencoding(void);
+
extern char *getpgusername(void);
extern void SetPgUserName(void);
extern Oid GetUserId(void);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 95a014409d9..c2c2c0fc7bb 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: parsenodes.h,v 1.50 1998/07/12 21:29:31 momjian Exp $
+ * $Id: parsenodes.h,v 1.51 1998/07/24 03:32:26 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -480,6 +480,10 @@ typedef struct CreatedbStmt
NodeTag type;
char *dbname; /* database to create */
char *dbpath; /* location of database */
+#ifdef MB
+ int encoding; /* default encoding
+ (see regex/pg_wchar.h) */
+#endif
} CreatedbStmt;
/* ----------------------
diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h
index 672ed2a382f..c4a306e4c23 100644
--- a/src/include/regex/regex.h
+++ b/src/include/regex/regex.h
@@ -41,7 +41,7 @@
#define _REGEX_H_
#include <sys/types.h>
-#include <regex/pg_wchar.h>
+#include <mb/pg_wchar.h>
/* types */
typedef off_t regoff_t;