aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2000-02-19 05:04:54 +0000
committerTatsuo Ishii <ishii@postgresql.org>2000-02-19 05:04:54 +0000
commit4fec86f1f6baac423fdb8a899aee790c4f3ec452 (patch)
tree38a6b1bf0dfed89df0211c03180976d6220d7340 /src
parenteb089e7f766f6d366641d582e38ac59a2bb57123 (diff)
downloadpostgresql-4fec86f1f6baac423fdb8a899aee790c4f3ec452.tar.gz
postgresql-4fec86f1f6baac423fdb8a899aee790c4f3ec452.zip
Fix nasty bug in setting client_encoding
Diffstat (limited to 'src')
-rw-r--r--src/interfaces/libpq/fe-connect.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 9202cb23c96..a2c01d0883c 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.119 2000/02/15 20:49:28 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.120 2000/02/19 05:04:54 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1461,8 +1461,6 @@ PQsetenvPoll(PGconn *conn)
case SETENV_STATE_ENCODINGS_WAIT:
{
- const char *encoding = 0;
-
if (PQisBusy(handle->conn))
return PGRES_POLLING_READING;
@@ -1470,6 +1468,8 @@ PQsetenvPoll(PGconn *conn)
if (handle->res)
{
+ char *encoding;
+
if (PQresultStatus(handle->res) != PGRES_TUPLES_OK)
{
PQclear(handle->res);
@@ -1478,13 +1478,10 @@ PQsetenvPoll(PGconn *conn)
encoding = PQgetvalue(handle->res, 0, 0);
if (!encoding) /* this should not happen */
- encoding = SQL_ASCII;
-
- if (encoding)
- {
+ conn->client_encoding = SQL_ASCII;
+ else
/* set client encoding to pg_conn struct */
- conn->client_encoding = atoi(encoding);
- }
+ conn->client_encoding = pg_char_to_encoding(encoding);
PQclear(handle->res);
/* We have to keep going in order to clear up the query */
goto keep_going;
@@ -2395,6 +2392,9 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
if (!conn || conn->status != CONNECTION_OK)
return -1;
+ if (!encoding)
+ return -1;
+
/* check query buffer overflow */
if (sizeof(qbuf) < (sizeof(query) + strlen(encoding)))
return -1;