git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d7ffd4)
Current multi-byte related codes have a bug with SQL_ASCII
1998年12月14日 04:51:34 +0000 (04:51 +0000)
1998年12月14日 04:51:34 +0000 (04:51 +0000)
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


diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c
index ee9649f32d9fbec5caf9c31424821d4cc27261e0..97ba1caafa1881e2ad471766967d1cbf7c50988c 100644 (file)
--- a/src/backend/utils/mb/conv.c
+++ b/src/backend/utils/mb/conv.c
@@ -2,7 +2,7 @@
* conversion between client encoding and server internal encoding
* (currently mule internal code (mic) is used)
* Tatsuo Ishii
- * $Id: conv.c,v 1.3 1998年09月01日 04:33:21 momjian Exp $
+ * $Id: conv.c,v 1.3.2.1 1998年12月14日 04:51:33 momjian Exp $
*/
#include <stdio.h>
#include <string.h>
@@ -487,7 +487,7 @@ mic2ascii(unsigned char *mic, unsigned char *p, int len)
{
int c1;
- while (len > 0 && (c1 = *mic))
+ while (len-- > 0 && (c1 = *mic))
{
if (c1 > 0x7f)
printBogusChar(&mic, &p);
@@ -495,6 +495,7 @@ mic2ascii(unsigned char *mic, unsigned char *p, int len)
{ /* should be ASCII */
*p++ = c1;
}
+ mic++;
}
*p = '0円';
}
diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c
index de9339d8eef750a8ef6d275520edd48087593a61..eea1c928827ccb734c06eb7a8d0ecf099cc55b1b 100644 (file)
--- 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.163.2.1 1998年11月24日 05:50:42 thomas Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.163.2.2 1998年12月14日 04:51:34 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)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /