]> granicus.if.org Git - postgresql/commitdiff
Implement following item in TODO:
authorTatsuo Ishii <ishii@postgresql.org>
Tue, 11 Sep 2001 05:18:59 +0000 (05:18 +0000)
committerTatsuo Ishii <ishii@postgresql.org>
Tue, 11 Sep 2001 05:18:59 +0000 (05:18 +0000)
* Reject character sequences those are not valid in their charset

src/backend/utils/adt/varchar.c
src/backend/utils/adt/varlena.c

index 38b26173ad23d5230cfb8e081bc6ea764a0822e2..b142d126c1c1babcc30d2242f8e7a534558b47ce 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.81 2001/07/15 11:07:37 ishii Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.82 2001/09/11 05:18:59 ishii Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,10 +75,14 @@ bpcharin(PG_FUNCTION_ARGS)
        int                     i;
 #ifdef MULTIBYTE
        int     charlen;        /* number of charcters in the input string */
+       char    *ermsg;
 #endif
 
        len = strlen(s);
 #ifdef MULTIBYTE
+       if ((ermsg = pg_verifymbstr(s, len)))
+           elog(ERROR,"%s",ermsg);
+
        charlen = pg_mbstrlen(s);
 #endif
 
@@ -405,8 +409,15 @@ varcharin(PG_FUNCTION_ARGS)
        int32           atttypmod = PG_GETARG_INT32(2);
        VarChar    *result;
        size_t          len, maxlen;
+#ifdef MULTIBYTE
+       char    *ermsg;
+#endif
 
        len = strlen(s);
+#ifdef MULTIBYTE
+       if ((ermsg = pg_verifymbstr(s, len)))
+           elog(ERROR,"%s",ermsg);
+#endif
        maxlen = atttypmod - VARHDRSZ;
 
        if (atttypmod >= (int32) VARHDRSZ && len > maxlen)
index 9bc42cf05e702639afcb26b0cd3f0ad354ed7f45..75eee05eeae22ff228e9b2839f58dcd4d78ad1c3 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.71 2001/08/13 18:45:35 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.72 2001/09/11 05:18:59 ishii Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -154,8 +154,17 @@ textin(PG_FUNCTION_ARGS)
        char       *inputText = PG_GETARG_CSTRING(0);
        text       *result;
        int                     len;
+#ifdef MULTIBYTE
+       char    *ermsg;
+#endif
 
        len = strlen(inputText) + VARHDRSZ;
+
+#ifdef MULTIBYTE
+       if ((ermsg = pg_verifymbstr(inputText, len - VARHDRSZ)))
+           elog(ERROR,"%s",ermsg);
+#endif
+
        result = (text *) palloc(len);
        VARATT_SIZEP(result) = len;