diff options
author | Tatsuo Ishii <ishii@postgresql.org> | 2003-02-19 14:31:26 +0000 |
---|---|---|
committer | Tatsuo Ishii <ishii@postgresql.org> | 2003-02-19 14:31:26 +0000 |
commit | e2a618fe25f9e02f17dacff4c3d2f117b56c7715 (patch) | |
tree | eb789d9336e38269d0e97932325f313759e58ccd /src/backend/utils/mb/mbutils.c | |
parent | d5740d7e26ab59da1c4a037510defbb1334eaaf4 (diff) | |
download | postgresql-e2a618fe25f9e02f17dacff4c3d2f117b56c7715.tar.gz postgresql-e2a618fe25f9e02f17dacff4c3d2f117b56c7715.zip |
Fix for GUC client_encoding variable not being handled
correctly. 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)
Diffstat (limited to 'src/backend/utils/mb/mbutils.c')
-rw-r--r-- | src/backend/utils/mb/mbutils.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index d66444d78d8..560dffa8581 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.37 2002/11/26 02:22:29 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v 1.38 2003/02/19 14:31:26 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 bool 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 |