aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2003-02-19 14:14:58 +0000
committerTatsuo Ishii <ishii@postgresql.org>2003-02-19 14:14:58 +0000
commitd1bb0db8dd208236f84f54e3c4ef6eac2ae4e71e (patch)
tree8c2f831df8a4a0914f1f82912a274194c80a24ef
parent00cb9384a12f3bb5af5cd718c8a343087cfb10ea (diff)
downloadpostgresql-d1bb0db8dd208236f84f54e3c4ef6eac2ae4e71e.tar.gz
postgresql-d1bb0db8dd208236f84f54e3c4ef6eac2ae4e71e.zip
Back patch for GUC client_encoding variable not being handled
correctly. However the patch for PostgresPollingStatusType() is not included to avoid 7.3 libpq vs. pre-7.3 backend compatibility problem. See following thread for more details. Subject: [HACKERS] client_encoding directive is ignored in postgresql.conf From: Tatsuo Ishii <t-ishii@sra.co.jp> Date: Wed, 29 Jan 2003 22:24:04 +0900 (JST)
-rw-r--r--src/backend/utils/init/postinit.c5
-rw-r--r--src/backend/utils/mb/mbutils.c24
-rw-r--r--src/include/mb/pg_wchar.h3
3 files changed, 29 insertions, 3 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 94532e782f4..10921a64357 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.117.2.1 2002/11/21 06:36:27 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.117.2.2 2003/02/19 14:14:58 ishii Exp $
*
*
*-------------------------------------------------------------------------
@@ -397,6 +397,9 @@ InitPostgres(const char *dbname, const char *username)
/* set default namespace search path */
InitializeSearchPath();
+ /* initialize client encoding */
+ InitializeClientEncoding();
+
/*
* Set up process-exit callback to do pre-shutdown cleanup. This
* should be last because we want shmem_exit to call this routine
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c
index dc89f9a822d..154d58e84d1 100644
--- a/src/backend/utils/mb/mbutils.c
+++ b/src/backend/utils/mb/mbutils.c
@@ -4,7 +4,7 @@
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
*
- * $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.36.2.1 2002/11/26 02:37:13 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.36.2.2 2003/02/19 14:14:58 ishii Exp $
*/
#include "postgres.h"
@@ -37,6 +37,8 @@ static unsigned char *perform_default_encoding_conversion(unsigned char *src,
int len, bool is_client_to_server);
static int cliplen(const unsigned char *str, int len, int limit);
+/* Flag to we need to initialize client encoding info */
+static int need_to_init_client_encoding = -1;
/*
* Set the client encoding and save fmgrinfo for the converion
@@ -58,6 +60,13 @@ SetClientEncoding(int encoding, bool doit)
if (!PG_VALID_FE_ENCODING(encoding))
return (-1);
+ /* If we cannot actualy set client encoding info, remeber it
+ * so that we could set it using InitializeClientEncoding()
+ * in InitPostgres()
+ */
+ if (current_server_encoding != encoding && !IsTransactionState())
+ need_to_init_client_encoding = encoding;
+
if (current_server_encoding == encoding ||
(current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII))
{
@@ -115,6 +124,19 @@ SetClientEncoding(int encoding, bool doit)
return 0;
}
+/* Initialize client encoding if necessary.
+ * called from InitPostgres() once during backend starting up.
+ */
+void
+InitializeClientEncoding()
+{
+ if (need_to_init_client_encoding > 0)
+ {
+ SetClientEncoding(need_to_init_client_encoding, 1);
+ need_to_init_client_encoding = -1;
+ }
+}
+
/*
* returns the current client encoding */
int
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index a73a16277b5..d5fd497b6a6 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -1,4 +1,4 @@
-/* $Id: pg_wchar.h,v 1.44 2002/09/04 20:31:42 momjian Exp $ */
+/* $Id: pg_wchar.h,v 1.44.2.1 2003/02/19 14:14:58 ishii Exp $ */
#ifndef PG_WCHAR_H
#define PG_WCHAR_H
@@ -295,6 +295,7 @@ extern int pg_database_encoding_max_length(void);
extern void SetDefaultClientEncoding(void);
extern int SetClientEncoding(int encoding, bool doit);
+extern void InitializeClientEncoding(void);
extern int pg_get_client_encoding(void);
extern const char *pg_get_client_encoding_name(void);