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

Commit ffb90a0

Browse files
committed
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 t-ishii@sra.co.jp
1 parent 4140c2f commit ffb90a0

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/backend/utils/mb/conv.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* conversion between client encoding and server internal encoding
33
* (currently mule internal code (mic) is used)
44
* Tatsuo Ishii
5-
* $Id: conv.c,v 1.3 1998/09/01 04:33:21 momjian Exp $
5+
* $Id: conv.c,v 1.4 1998/12/14 04:59:58 momjian Exp $
66
*/
77
#include <stdio.h>
88
#include <string.h>
@@ -487,14 +487,15 @@ mic2ascii(unsigned char *mic, unsigned char *p, int len)
487487
{
488488
int c1;
489489

490-
while (len > 0 && (c1 = *mic))
490+
while (len-- > 0 && (c1 = *mic))
491491
{
492492
if (c1 > 0x7f)
493493
printBogusChar(&mic, &p);
494494
else
495495
{ /* should be ASCII */
496496
*p++ = c1;
497497
}
498+
mic++;
498499
}
499500
*p = '\0';
500501
}

src/bin/psql/psql.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* 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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -84,6 +84,11 @@ char *__progname = "psql";
8484

8585
#endif
8686

87+
#ifdef MULTIBYTE
88+
/* flag to indicate if PGCLIENTENCODING has been set by a user */
89+
static int has_client_encoding;
90+
#endif
91+
8792
/* This prompt string is assumed to have at least 3 characters by code in MainLoop().
8893
* A character two characters from the end is replaced each time by a mode character.
8994
*/
@@ -1485,6 +1490,18 @@ do_connect(const char *new_dbname,
14851490
/* FIXME: if changing user, ought to prompt for a new password? */
14861491
pwparam = PQpass(olddb);
14871492

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+
14881505
pset->db = PQsetdbLogin(PQhost(olddb), PQport(olddb),
14891506
NULL, NULL, dbparam, userparam, pwparam);
14901507

@@ -2754,6 +2771,10 @@ main(int argc, char **argv)
27542771
settings.getPassword = 0;
27552772
#endif
27562773

2774+
#ifdef MUTIBYTE
2775+
has_client_encoding = getenv("PGCLIENTENCODING");
2776+
#endif
2777+
27572778
while ((c = getopt(argc, argv, "Aa:c:d:ef:F:lh:Hnso:p:qStT:ux")) != EOF)
27582779
{
27592780
switch (c)

0 commit comments

Comments
 (0)