diff options
author | Marc G. Fournier <scrappy@hub.org> | 1998-04-27 17:10:50 +0000 |
---|---|---|
committer | Marc G. Fournier <scrappy@hub.org> | 1998-04-27 17:10:50 +0000 |
commit | f554af0a9fdbe0e9636fce36d6c809e81ce1539c (patch) | |
tree | 3cd60fe19a94c78e774ac3b70ef3d729f7896f20 /src/backend/utils/adt/varchar.c | |
parent | 2cbcf461028dee105f69328e4589f08a4f59db91 (diff) | |
download | postgresql-f554af0a9fdbe0e9636fce36d6c809e81ce1539c.tar.gz postgresql-f554af0a9fdbe0e9636fce36d6c809e81ce1539c.zip |
From: t-ishii@sra.co.jp
Hi, here are patches I promised (against 6.3.2):
* character_length(), position(), substring() are now aware of
multi-byte characters
* add octet_length()
* add --with-mb option to configure
* new regression tests for EUC_KR
(contributed by "Soonmyung. Hong" <hong@lunaris.hanmesoft.co.kr>)
* add some test cases to the EUC_JP regression test
* fix problem in regress/regress.sh in case of System V
* fix toupper(), tolower() to handle 8bit chars
note that:
o patches for both configure.in and configure are
included. maybe the one for configure is not necessary.
o pg_proc.h was modified to add octet_length(). I used OIDs
(1374-1379) for that. Please let me know if these numbers are not
appropriate.
Diffstat (limited to 'src/backend/utils/adt/varchar.c')
-rw-r--r-- | src/backend/utils/adt/varchar.c | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 796cc3099ac..cbd113bba85 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.29 1998/02/26 04:37:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.30 1998/04/27 17:08:26 scrappy Exp $ * *------------------------------------------------------------------------- */ @@ -21,6 +21,8 @@ char *convertstr(char *, int, int); #endif +#include "regex/pg_wchar.h" + /* * CHAR() and VARCHAR() types are part of the ANSI SQL standard. CHAR() * is for blank-padded string whose length is specified in CREATE TABLE. @@ -214,6 +216,31 @@ bcTruelen(char *arg) int32 bpcharlen(char *arg) { +#ifdef MB + unsigned char *s; + int len, l, wl; +#endif + if (!PointerIsValid(arg)) + elog(ERROR, "Bad (null) char() external representation", NULL); +#ifdef MB + l = bcTruelen(arg); + len = 0; + s = VARDATA(arg); + while (l > 0) { + wl = pg_mblen(s); + l -= wl; + s += wl; + len++; + } + return(len); +#else + return (bcTruelen(arg)); +#endif +} + +int32 +bpcharoctetlen(char *arg) +{ if (!PointerIsValid(arg)) elog(ERROR, "Bad (null) char() external representation", NULL); @@ -354,9 +381,34 @@ bpcharcmp(char *arg1, char *arg2) int32 varcharlen(char *arg) { +#ifdef MB + unsigned char *s; + int len, l, wl; +#endif if (!PointerIsValid(arg)) elog(ERROR, "Bad (null) varchar() external representation", NULL); +#ifdef MB + len = 0; + s = VARDATA(arg); + l = VARSIZE(arg) - VARHDRSZ; + while (l > 0) { + wl = pg_mblen(s); + l -= wl; + s += wl; + len++; + } + return(len); +#else + return (VARSIZE(arg) - VARHDRSZ); +#endif +} + +int32 +varcharoctetlen(char *arg) +{ + if (!PointerIsValid(arg)) + elog(ERROR, "Bad (null) varchar() external representation", NULL); return (VARSIZE(arg) - VARHDRSZ); } |