Skip to content

Commit 5f65345

Browse files
committed
Do not pass server_encoding to the client.
libpq, talking to an old server, should assume SQL_ASCII as the default client encoding, because that is what the server will actually use (not the server encoding).
1 parent f10a903 commit 5f65345

File tree

4 files changed

+22
-34
lines changed

4 files changed

+22
-34
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.133 2003/08/31 17:32:19 petere Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.134 2003/09/01 23:04:49 petere Exp $
33
-->
44

55
<chapter id="libpq">
@@ -856,21 +856,20 @@ is not known.
856856
<para>
857857
Parameters reported as of the current release include
858858
<literal>server_version</> (cannot change after startup);
859-
<literal>server_encoding</> (also not presently changeable after start);
860859
<literal>client_encoding</>,
861860
<literal>is_superuser</>, and
862861
<literal>DateStyle</>.
863862
</para>
864863

865864
<para>
866-
Pre-3.0-protocol servers do not report parameter settings,
867-
but <application>libpq</> includes logic to obtain values for
868-
<literal>server_version</>, <literal>server_encoding</>, and
869-
<literal>client_encoding</>. Applications are encouraged to use
870-
<function>PQparameterStatus</> rather than ad-hoc code to determine these
871-
values. (Beware however that on a pre-3.0 connection, changing
872-
<literal>client_encoding</> via <command>SET</> after connection startup
873-
will not be reflected by <function>PQparameterStatus</>.)
865+
Pre-3.0-protocol servers do not report parameter settings, but
866+
<application>libpq</> includes logic to obtain values for
867+
<literal>server_version</>, and <literal>client_encoding</>.
868+
Applications are encouraged to use <function>PQparameterStatus</>
869+
rather than ad-hoc code to determine these values. (Beware however
870+
that on a pre-3.0 connection, changing <literal>client_encoding</> via
871+
<command>SET</> after connection startup will not be reflected by
872+
<function>PQparameterStatus</>.)
874873
</para>
875874
</listitem>
876875
</varlistentry>

doc/src/sgml/protocol.sgml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.41 2003/08/14 20:09:31 tgl Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/protocol.sgml,v 1.42 2003/09/01 23:04:49 petere Exp $ -->
22

33
<chapter id="protocol">
44
<title>Frontend/Backend Protocol</title>
@@ -1005,7 +1005,6 @@
10051005
ParameterStatus will be generated: they are
10061006
<literal>server_version</> (a pseudo-parameter that cannot change after
10071007
startup);
1008-
<literal>server_encoding</> (also not presently changeable after start);
10091008
<literal>client_encoding</>,
10101009
<literal>is_superuser</>, and
10111010
<literal>DateStyle</>.

src/backend/utils/misc/guc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.152 2003/09/01 04:15:50 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.153 2003/09/01 23:04:49 petere Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -1479,7 +1479,7 @@ static struct config_string ConfigureNamesString[] =
14791479
{"server_encoding", PGC_INTERNAL, CLIENT_CONN_LOCALE,
14801480
gettext_noop("Server (database) character set encoding"),
14811481
NULL,
1482-
GUC_REPORT | GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
1482+
GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE
14831483
},
14841484
&server_encoding_string,
14851485
"SQL_ASCII", NULL, NULL

src/interfaces/libpq/fe-protocol2.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.7 2003/08/27 00:33:34 petere Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.8 2003/09/01 23:04:49 petere Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -177,10 +177,10 @@ pqSetenvPoll(PGconn *conn)
177177
* must use begin/commit in case autocommit is off by
178178
* default in a 7.3 server.
179179
*
180-
* Note: version() and getdatabaseencoding() exist in all
180+
* Note: version() exists in all
181181
* protocol-2.0-supporting backends.
182182
*/
183-
if (!PQsendQuery(conn, "begin; select version(), getdatabaseencoding(); end"))
183+
if (!PQsendQuery(conn, "begin; select version(); end"))
184184
goto error_return;
185185

186186
conn->setenv_state = SETENV_STATE_QUERY1_WAIT;
@@ -213,8 +213,8 @@ pqSetenvPoll(PGconn *conn)
213213
}
214214

215215
/*
216-
* Extract server version and database encoding,
217-
* and save as if ParameterStatus
216+
* Extract server version and save as if
217+
* ParameterStatus
218218
*/
219219
val = PQgetvalue(res, 0, 0);
220220
if (val && strncmp(val, "PostgreSQL ", 11) == 0)
@@ -236,12 +236,6 @@ pqSetenvPoll(PGconn *conn)
236236
val);
237237
}
238238

239-
val = PQgetvalue(res, 0, 1);
240-
if (val && *val) /* null should not happen,
241-
* but */
242-
pqSaveParameterStatus(conn, "server_encoding",
243-
val);
244-
245239
PQclear(res);
246240
/* Keep reading until PQgetResult returns NULL */
247241
}
@@ -306,21 +300,17 @@ pqSetenvPoll(PGconn *conn)
306300
else
307301
{
308302
/*
309-
* Error: presumably function not available,
310-
* so use PGCLIENTENCODING or database
311-
* encoding as the fallback.
303+
* Error: presumably function not
304+
* available, so use PGCLIENTENCODING or
305+
* SQL_ASCII as the fallback.
312306
*/
313307
val = getenv("PGCLIENTENCODING");
314308
if (val && *val)
315309
pqSaveParameterStatus(conn, "client_encoding",
316310
val);
317311
else
318-
{
319-
val = PQparameterStatus(conn, "server_encoding");
320-
if (val && *val)
321-
pqSaveParameterStatus(conn, "client_encoding",
322-
val);
323-
}
312+
pqSaveParameterStatus(conn, "client_encoding",
313+
"SQL_ASCII");
324314
}
325315

326316
PQclear(res);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy