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.127 2000/05/21 21:19:53 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.127.2.1 2000/11/17 04:25:29 ishii Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -1505,17 +1505,31 @@ PQsetenvPoll(PGconn *conn)
1505
1505
{
1506
1506
const char * env ;
1507
1507
1508
- /* query server encoding */
1509
1508
env = getenv (envname );
1510
1509
if (!env || * env == '\0' )
1511
1510
{
1511
+ /* query server encoding if PGCLIENTENCODING
1512
+ is not specified */
1512
1513
if (!PQsendQuery (conn ,
1513
1514
"select getdatabaseencoding()" ))
1514
1515
goto error_return ;
1515
1516
1516
1517
conn -> setenv_state = SETENV_STATE_ENCODINGS_WAIT ;
1517
1518
return PGRES_POLLING_READING ;
1518
1519
}
1520
+ else
1521
+ {
1522
+ /* otherwise set client encoding in pg_conn struct */
1523
+ int encoding = pg_char_to_encoding (env );
1524
+ if (encoding < 0 )
1525
+ {
1526
+ strcpy (conn -> errorMessage .data ,
1527
+ "PGCLIENTENCODING has no valid encoding name.\n" );
1528
+ goto error_return ;
1529
+ }
1530
+ conn -> client_encoding = encoding ;
1531
+ }
1532
+
1519
1533
}
1520
1534
1521
1535
case SETENV_STATE_ENCODINGS_WAIT :
You can’t perform that action at this time.
0 commit comments