]> granicus.if.org Git - postgresql/commitdiff
Make makeObjectName multibyte aware. Currently, it may produce
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 22 Aug 2000 12:59:04 +0000 (12:59 +0000)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 22 Aug 2000 12:59:04 +0000 (12:59 +0000)
incorrect multibyte sequence while truncating too long names.

src/backend/parser/analyze.c

index be6009f70002b8599998c4ccaa27e3eaeb9f8713..f3cad18de86362e5647b4ac62f27bf210ccd048a 100644 (file)
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- *     $Id: analyze.c,v 1.154 2000/08/11 23:45:27 tgl Exp $
+ *     $Id: analyze.c,v 1.155 2000/08/22 12:59:04 ishii Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "utils/relcache.h"
 #include "utils/syscache.h"
 
+#ifdef MULTIBYTE
+#include "mb/pg_wchar.h"
+#endif
+
 void           CheckSelectForUpdate(Query *qry);       /* no points for style... */
 
 static Query *transformStmt(ParseState *pstate, Node *stmt);
@@ -550,6 +554,13 @@ makeObjectName(char *name1, char *name2, char *typename)
                        name2chars--;
        }
 
+#ifdef MULTIBYTE
+       if (name1)
+               name1chars = pg_mbcliplen(name1, name1chars, name1chars);
+       if (name2)
+               name2chars = pg_mbcliplen(name2, name2chars, name2chars);
+#endif
+
        /* Now construct the string using the chosen lengths */
        name = palloc(name1chars + name2chars + overhead + 1);
        strncpy(name, name1, name1chars);