8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.119 2000/02/15 20:49:28 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.120 2000/02/19 05:04:54 ishii Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1461,15 +1461,15 @@ PQsetenvPoll(PGconn *conn)
1461
1461
1462
1462
case SETENV_STATE_ENCODINGS_WAIT :
1463
1463
{
1464
- const char * encoding = 0 ;
1465
-
1466
1464
if (PQisBusy (handle -> conn ))
1467
1465
return PGRES_POLLING_READING ;
1468
1466
1469
1467
handle -> res = PQgetResult (handle -> conn );
1470
1468
1471
1469
if (handle -> res )
1472
1470
{
1471
+ char * encoding ;
1472
+
1473
1473
if (PQresultStatus (handle -> res ) != PGRES_TUPLES_OK )
1474
1474
{
1475
1475
PQclear (handle -> res );
@@ -1478,13 +1478,10 @@ PQsetenvPoll(PGconn *conn)
1478
1478
1479
1479
encoding = PQgetvalue (handle -> res , 0 , 0 );
1480
1480
if (!encoding ) /* this should not happen */
1481
- encoding = SQL_ASCII ;
1482
-
1483
- if (encoding )
1484
- {
1481
+ conn -> client_encoding = SQL_ASCII ;
1482
+ else
1485
1483
/* set client encoding to pg_conn struct */
1486
- conn -> client_encoding = atoi (encoding );
1487
- }
1484
+ conn -> client_encoding = pg_char_to_encoding (encoding );
1488
1485
PQclear (handle -> res );
1489
1486
/* We have to keep going in order to clear up the query */
1490
1487
goto keep_going ;
@@ -2395,6 +2392,9 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
2395
2392
if (!conn || conn -> status != CONNECTION_OK )
2396
2393
return -1 ;
2397
2394
2395
+ if (!encoding )
2396
+ return -1 ;
2397
+
2398
2398
/* check query buffer overflow */
2399
2399
if (sizeof (qbuf ) < (sizeof (query ) + strlen (encoding )))
2400
2400
return -1 ;
0 commit comments