summaryrefslogtreecommitdiff
path: root/src/bin/psql/psql.c
diff options
context:
space:
mode:
authorBruce Momjian1998-12-14 04:59:58 +0000
committerBruce Momjian1998-12-14 04:59:58 +0000
commitffb90a01fdd97bebb1a70d7899f55765f0acfe00 (patch)
tree33134e20d6dd1cbe87ad4674eb36bc2d120a1ebb /src/bin/psql/psql.c
parent4140c2f30e2814527f0975876956f446e326ae70 (diff)
Current multi-byte related codes have a bug with SQL_ASCII
support. Included patches will solve it and should be applied to both trees. Also, it fix the problem with \c command of psql when switching different encoding databases. Regression tests passed. -- Tatsuo Ishii [email protected]
Diffstat (limited to 'src/bin/psql/psql.c')
-rw-r--r--src/bin/psql/psql.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index a340c0a2589..ace31f577c3 100644
--- a/src/bin/psql/psql.c
+++ b/src/bin/psql/psql.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.164 1998/11/17 14:26:31 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.165 1998/12/14 04:59:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -84,6 +84,11 @@ char *__progname = "psql";
#endif
+#ifdef MULTIBYTE
+/* flag to indicate if PGCLIENTENCODING has been set by a user */
+static int has_client_encoding;
+#endif
+
/* This prompt string is assumed to have at least 3 characters by code in MainLoop().
* A character two characters from the end is replaced each time by a mode character.
*/
@@ -1485,6 +1490,18 @@ do_connect(const char *new_dbname,
/* FIXME: if changing user, ought to prompt for a new password? */
pwparam = PQpass(olddb);
+#ifdef MULTIBYTE
+ /* PGCLIENTENCODING may be set by the previous connection.
+ if a user does not explicitly set PGCLIENTENCODING,
+ we should discard PGCLIENTENCODING so that
+ libpq could get the backend encoding as the default
+ PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */
+
+ if (!has_client_encoding) {
+ unsetenv("PGCLIENTENCODING");
+ }
+#endif
+
pset->db = PQsetdbLogin(PQhost(olddb), PQport(olddb),
NULL, NULL, dbparam, userparam, pwparam);
@@ -2754,6 +2771,10 @@ main(int argc, char **argv)
settings.getPassword = 0;
#endif
+#ifdef MUTIBYTE
+ has_client_encoding = getenv("PGCLIENTENCODING");
+#endif
+
while ((c = getopt(argc, argv, "Aa:c:d:ef:F:lh:Hnso:p:qStT:ux")) != EOF)
{
switch (c)