diff options
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 0fe08aa0d5e..36b5ce3479f 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.301.4.4 2005/07/13 15:26:06 tgl Exp $ + * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.301.4.5 2006/05/21 20:20:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1985,6 +1985,7 @@ makeEmptyPGconn(void) conn->xactStatus = PQTRANS_IDLE; conn->setenv_state = SETENV_STATE_IDLE; conn->client_encoding = PG_SQL_ASCII; + conn->std_strings = false; /* unless server says differently */ conn->verbosity = PQERRORS_DEFAULT; conn->sock = -1; #ifdef USE_SSL @@ -3077,8 +3078,14 @@ PQsetClientEncoding(PGconn *conn, const char *encoding) status = -1; else { - /* change libpq internal encoding */ - conn->client_encoding = pg_char_to_encoding(encoding); + /* + * In protocol 2 we have to assume the setting will stick, and + * adjust our state immediately. In protocol 3 and up we can + * rely on the backend to report the parameter value, and we'll + * change state at that time. + */ + if (PG_PROTOCOL_MAJOR(conn->pversion) < 3) + pqSaveParameterStatus(conn, "client_encoding", encoding); status = 0; /* everything is ok */ } PQclear(res); |