88 *
99 *
1010 * 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 $
1212 *
1313 *-------------------------------------------------------------------------
1414 */
@@ -1461,15 +1461,15 @@ PQsetenvPoll(PGconn *conn)
14611461
14621462case SETENV_STATE_ENCODINGS_WAIT :
14631463{
1464- const char * encoding = 0 ;
1465-
14661464if (PQisBusy (handle -> conn ))
14671465return PGRES_POLLING_READING ;
14681466
14691467handle -> res = PQgetResult (handle -> conn );
14701468
14711469if (handle -> res )
14721470{
1471+ char * encoding ;
1472+
14731473if (PQresultStatus (handle -> res )!= PGRES_TUPLES_OK )
14741474{
14751475PQclear (handle -> res );
@@ -1478,13 +1478,10 @@ PQsetenvPoll(PGconn *conn)
14781478
14791479encoding = PQgetvalue (handle -> res ,0 ,0 );
14801480if (!encoding )/* this should not happen */
1481- encoding = SQL_ASCII ;
1482-
1483- if (encoding )
1484- {
1481+ conn -> client_encoding = SQL_ASCII ;
1482+ else
14851483/* set client encoding to pg_conn struct */
1486- conn -> client_encoding = atoi (encoding );
1487- }
1484+ conn -> client_encoding = pg_char_to_encoding (encoding );
14881485PQclear (handle -> res );
14891486/* We have to keep going in order to clear up the query */
14901487gotokeep_going ;
@@ -2395,6 +2392,9 @@ PQsetClientEncoding(PGconn *conn, const char *encoding)
23952392if (!conn || conn -> status != CONNECTION_OK )
23962393return -1 ;
23972394
2395+ if (!encoding )
2396+ return -1 ;
2397+
23982398/* check query buffer overflow */
23992399if (sizeof (qbuf )< (sizeof (query )+ strlen (encoding )))
24002400return -1 ;