|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.164 1998/11/17 14:26:31 thomas Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.165 1998/12/14 04:59:58 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -84,6 +84,11 @@ char *__progname = "psql";
|
84 | 84 |
|
85 | 85 | #endif
|
86 | 86 |
|
| 87 | +#ifdef MULTIBYTE |
| 88 | +/* flag to indicate if PGCLIENTENCODING has been set by a user */ |
| 89 | +static int has_client_encoding; |
| 90 | +#endif |
| 91 | + |
87 | 92 | /* This prompt string is assumed to have at least 3 characters by code in MainLoop().
|
88 | 93 | * A character two characters from the end is replaced each time by a mode character.
|
89 | 94 | */
|
@@ -1485,6 +1490,18 @@ do_connect(const char *new_dbname,
|
1485 | 1490 | /* FIXME: if changing user, ought to prompt for a new password? */
|
1486 | 1491 | pwparam = PQpass(olddb);
|
1487 | 1492 |
|
| 1493 | +#ifdef MULTIBYTE |
| 1494 | + /* PGCLIENTENCODING may be set by the previous connection. |
| 1495 | + if a user does not explicitly set PGCLIENTENCODING, |
| 1496 | + we should discard PGCLIENTENCODING so that |
| 1497 | + libpq could get the backend encoding as the default |
| 1498 | + PGCLIENTENCODING value. -- 1998/12/12 Tatsuo Ishii */ |
| 1499 | + |
| 1500 | + if (!has_client_encoding) { |
| 1501 | + unsetenv("PGCLIENTENCODING"); |
| 1502 | + } |
| 1503 | +#endif |
| 1504 | + |
1488 | 1505 | pset->db = PQsetdbLogin(PQhost(olddb), PQport(olddb),
|
1489 | 1506 | NULL, NULL, dbparam, userparam, pwparam);
|
1490 | 1507 |
|
@@ -2754,6 +2771,10 @@ main(int argc, char **argv)
|
2754 | 2771 | settings.getPassword = 0;
|
2755 | 2772 | #endif
|
2756 | 2773 |
|
| 2774 | +#ifdef MUTIBYTE |
| 2775 | + has_client_encoding = getenv("PGCLIENTENCODING"); |
| 2776 | +#endif |
| 2777 | + |
2757 | 2778 | while ((c = getopt(argc, argv, "Aa:c:d:ef:F:lh:Hnso:p:qStT:ux")) != EOF)
|
2758 | 2779 | {
|
2759 | 2780 | switch (c)
|
|
0 commit comments