Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit afde2ac

Browse files
committed
Recongizing PGCLIENTENCODING has been broken since 7.0.
1 parent 2912c28 commit afde2ac

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/interfaces/libpq/fe-connect.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* 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 $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1608,17 +1608,31 @@ PQsetenvPoll(PGconn *conn)
16081608
{
16091609
const char *env;
16101610

1611-
/* query server encoding */
16121611
env = getenv(envname);
16131612
if (!env || *env == '\0')
16141613
{
1614+
/* query server encoding if PGCLIENTENCODING
1615+
is not specified */
16151616
if (!PQsendQuery(conn,
16161617
"select getdatabaseencoding()"))
16171618
goto error_return;
16181619

16191620
conn->setenv_state = SETENV_STATE_ENCODINGS_WAIT;
16201621
return PGRES_POLLING_READING;
16211622
}
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+
16221636
}
16231637

16241638
case SETENV_STATE_ENCODINGS_WAIT:

0 commit comments

Comments
 (0)