diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-07-10 21:14:00 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-07-10 21:14:00 +0000 |
commit | d78397d301172cccce14d5d789f296c47dd47c5e (patch) | |
tree | 4104dc887976aee14286c0c0a7be03f84af43b7d /src/backend/utils/mb/mbutils.c | |
parent | 2e330699fae72c40f5237ce0f4fc210c483d2816 (diff) |
Change typreceive function API so that receive functions get the same
optional arguments as text input functions, ie, typioparam OID and
atttypmod. Make all the datatypes that use typmod enforce it the same
way in typreceive as they do in typinput. This fixes a problem with
failure to enforce length restrictions during COPY FROM BINARY.
Diffstat (limited to 'src/backend/utils/mb/mbutils.c')
-rw-r--r-- | src/backend/utils/mb/mbutils.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 541f9c2a5d3..a670bcce624 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -4,7 +4,7 @@ * (currently mule internal code (mic) is used) * Tatsuo Ishii * - * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.49 2005/03/07 04:30:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/mb/mbutils.c,v 1.50 2005/07/10 21:13:59 tgl Exp $ */ #include "postgres.h" @@ -489,16 +489,21 @@ pg_mbstrlen(const unsigned char *mbstr) } /* returns the length (counted as a wchar) of a multibyte string - (not necessarily NULL terminated) */ + * (not necessarily NULL terminated) + */ int pg_mbstrlen_with_len(const unsigned char *mbstr, int limit) { int len = 0; - int l; + + /* optimization for single byte encoding */ + if (pg_database_encoding_max_length() == 1) + return limit; while (limit > 0 && *mbstr) { - l = pg_mblen(mbstr); + int l = pg_mblen(mbstr); + limit -= l; mbstr += l; len++; |