mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
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.
This commit is contained in:
@ -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.
|
||||
@ -213,6 +215,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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user