File tree 1 file changed +16
-2
lines changed
1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.147 2000/11/14 01:15:06 momjian Exp $
11
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.148 2000/11/17 04:22:52 ishii Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1608,17 +1608,31 @@ PQsetenvPoll(PGconn *conn)
1608
1608
{
1609
1609
const char * env ;
1610
1610
1611
- /* query server encoding */
1612
1611
env = getenv (envname );
1613
1612
if (!env || * env == '\0' )
1614
1613
{
1614
+ /* query server encoding if PGCLIENTENCODING
1615
+ is not specified */
1615
1616
if (!PQsendQuery (conn ,
1616
1617
"select getdatabaseencoding()" ))
1617
1618
goto error_return ;
1618
1619
1619
1620
conn -> setenv_state = SETENV_STATE_ENCODINGS_WAIT ;
1620
1621
return PGRES_POLLING_READING ;
1621
1622
}
1623
+ else
1624
+ {
1625
+ /* otherwise set client encoding in pg_conn struct */
1626
+ int encoding = pg_char_to_encoding (env );
1627
+ if (encoding < 0 )
1628
+ {
1629
+ strcpy (conn -> errorMessage .data ,
1630
+ "PGCLIENTENCODING has no valid encoding name.\n" );
1631
+ goto error_return ;
1632
+ }
1633
+ conn -> client_encoding = encoding ;
1634
+ }
1635
+
1622
1636
}
1623
1637
1624
1638
case SETENV_STATE_ENCODINGS_WAIT :
You can’t perform that action at this time.
0 commit comments