mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Remove #ifdef MULTIBYTE per hackers list discussion.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* ascii.c
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.12 2001/11/05 17:46:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.13 2002/08/29 07:22:26 ishii Exp $
|
||||
*
|
||||
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
|
||||
*
|
||||
@@ -18,46 +18,6 @@
|
||||
#include "mb/pg_wchar.h"
|
||||
#include "utils/ascii.h"
|
||||
|
||||
/* ----------
|
||||
* even if MULTIBYTE is not enabled, these functions must exist
|
||||
* since pg_proc.h has references to them.
|
||||
* ----------
|
||||
*/
|
||||
#ifndef MULTIBYTE
|
||||
|
||||
static void multibyte_error(void);
|
||||
|
||||
static void
|
||||
multibyte_error(void)
|
||||
{
|
||||
elog(ERROR, "Multi-byte support is not enabled");
|
||||
}
|
||||
|
||||
Datum
|
||||
to_ascii_encname(PG_FUNCTION_ARGS)
|
||||
{
|
||||
multibyte_error();
|
||||
return 0; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
Datum
|
||||
to_ascii_enc(PG_FUNCTION_ARGS)
|
||||
{
|
||||
multibyte_error();
|
||||
return 0; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
Datum
|
||||
to_ascii_default(PG_FUNCTION_ARGS)
|
||||
{
|
||||
multibyte_error();
|
||||
return 0; /* keep compiler quiet */
|
||||
}
|
||||
|
||||
|
||||
#else /* with MULTIBYTE */
|
||||
|
||||
|
||||
static text *encode_to_ascii(text *data, int enc);
|
||||
|
||||
/* ----------
|
||||
@@ -190,5 +150,3 @@ to_ascii_default(PG_FUNCTION_ARGS)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#endif /* MULTIBYTE */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.32 2002/08/24 15:00:46 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.33 2002/08/29 07:22:26 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -25,9 +25,7 @@
|
||||
#include "utils/numeric.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
|
||||
#define MAX_INT32_LEN 11
|
||||
#define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str))
|
||||
@@ -433,14 +431,11 @@ type_maximum_size(Oid type_oid, int32 typemod)
|
||||
case BPCHAROID:
|
||||
case VARCHAROID:
|
||||
/* typemod includes varlena header */
|
||||
#ifdef MULTIBYTE
|
||||
|
||||
/* typemod is in characters not bytes */
|
||||
return (typemod - VARHDRSZ) *
|
||||
pg_encoding_max_length(GetDatabaseEncoding())
|
||||
+ VARHDRSZ;
|
||||
#else
|
||||
return typemod;
|
||||
#endif
|
||||
|
||||
case NUMERICOID:
|
||||
/* precision (ie, max # of digits) is in upper bits of typmod */
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.50 2002/08/22 04:45:11 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/like.c,v 1.51 2002/08/29 07:22:26 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -19,9 +19,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
#include "utils/builtins.h"
|
||||
|
||||
|
||||
@@ -38,7 +36,6 @@ static int MatchBytea(unsigned char *t, int tlen,
|
||||
unsigned char *p, int plen);
|
||||
static text *do_like_escape(text *, text *);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
static int MBMatchText(unsigned char *t, int tlen,
|
||||
unsigned char *p, int plen);
|
||||
static int MBMatchTextIC(unsigned char *t, int tlen,
|
||||
@@ -107,9 +104,7 @@ iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
c2[0] = tolower(c2[0]);
|
||||
return (c1[0] == c2[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#define CHAREQ(p1, p2) wchareq(p1, p2)
|
||||
#define ICHAREQ(p1, p2) iwchareq(p1, p2)
|
||||
#define NextChar(p, plen) \
|
||||
@@ -132,7 +127,6 @@ iwchareq(unsigned char *p1, unsigned char *p2)
|
||||
#undef MatchText
|
||||
#undef MatchTextIC
|
||||
#undef do_like_escape
|
||||
#endif
|
||||
|
||||
#define CHAREQ(p1, p2) (*(p1) == *(p2))
|
||||
#define ICHAREQ(p1, p2) (tolower(*(p1)) == tolower(*(p2)))
|
||||
@@ -164,14 +158,10 @@ namelike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -192,14 +182,10 @@ namenlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -220,14 +206,10 @@ textlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchText(s, slen, p, plen) == LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -248,14 +230,10 @@ textnlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchText(s, slen, p, plen) != LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -322,14 +300,10 @@ nameiclike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -350,14 +324,10 @@ nameicnlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -378,14 +348,10 @@ texticlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchTextIC(s, slen, p, plen) == LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -406,14 +372,10 @@ texticnlike(PG_FUNCTION_ARGS)
|
||||
p = VARDATA(pat);
|
||||
plen = (VARSIZE(pat) - VARHDRSZ);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
else
|
||||
result = (MBMatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
#else
|
||||
result = (MatchTextIC(s, slen, p, plen) != LIKE_TRUE);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
@@ -429,14 +391,10 @@ like_escape(PG_FUNCTION_ARGS)
|
||||
text *esc = PG_GETARG_TEXT_P(1);
|
||||
text *result;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (pg_database_encoding_max_length() == 1)
|
||||
result = do_like_escape(pat, esc);
|
||||
else
|
||||
result = MB_do_like_escape(pat, esc);
|
||||
#else
|
||||
result = do_like_escape(pat, esc);
|
||||
#endif
|
||||
|
||||
PG_RETURN_TEXT_P(result);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.41 2002/08/22 05:05:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.42 2002/08/29 07:22:27 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,9 +20,7 @@
|
||||
|
||||
#include "utils/builtins.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
*
|
||||
@@ -172,9 +170,7 @@ lpad(PG_FUNCTION_ARGS)
|
||||
s1len,
|
||||
s2len;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
int bytelen;
|
||||
#endif
|
||||
|
||||
/* Negative len is silently taken as zero */
|
||||
if (len < 0)
|
||||
@@ -188,16 +184,14 @@ lpad(PG_FUNCTION_ARGS)
|
||||
if (s2len < 0)
|
||||
s2len = 0; /* shouldn't happen */
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
|
||||
#endif
|
||||
|
||||
if (s1len > len)
|
||||
s1len = len; /* truncate string1 to len chars */
|
||||
|
||||
if (s2len <= 0)
|
||||
len = s1len; /* nothing to pad with, so don't pad */
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
bytelen = pg_database_encoding_max_length() * len;
|
||||
|
||||
/* check for integer overflow */
|
||||
@@ -205,16 +199,13 @@ lpad(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "Requested length too large");
|
||||
|
||||
ret = (text *) palloc(VARHDRSZ + bytelen);
|
||||
#else
|
||||
ret = (text *) palloc(VARHDRSZ + len);
|
||||
#endif
|
||||
|
||||
m = len - s1len;
|
||||
|
||||
ptr2 = VARDATA(string2);
|
||||
ptr2end = ptr2 + s2len;
|
||||
ptr_ret = VARDATA(ret);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m--)
|
||||
{
|
||||
int mlen = pg_mblen(ptr2);
|
||||
@@ -225,18 +216,9 @@ lpad(PG_FUNCTION_ARGS)
|
||||
if (ptr2 == ptr2end) /* wrap around at end of s2 */
|
||||
ptr2 = VARDATA(string2);
|
||||
}
|
||||
#else
|
||||
while (m--)
|
||||
{
|
||||
*ptr_ret++ = *ptr2++;
|
||||
if (ptr2 == ptr2end) /* wrap around at end of s2 */
|
||||
ptr2 = VARDATA(string2);
|
||||
}
|
||||
#endif
|
||||
|
||||
ptr1 = VARDATA(string1);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (s1len--)
|
||||
{
|
||||
int mlen = pg_mblen(ptr1);
|
||||
@@ -245,10 +227,6 @@ lpad(PG_FUNCTION_ARGS)
|
||||
ptr_ret += mlen;
|
||||
ptr1 += mlen;
|
||||
}
|
||||
#else
|
||||
while (s1len--)
|
||||
*ptr_ret++ = *ptr1++;
|
||||
#endif
|
||||
|
||||
VARATT_SIZEP(ret) = ptr_ret - (char *) ret;
|
||||
|
||||
@@ -287,9 +265,7 @@ rpad(PG_FUNCTION_ARGS)
|
||||
s1len,
|
||||
s2len;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
int bytelen;
|
||||
#endif
|
||||
|
||||
/* Negative len is silently taken as zero */
|
||||
if (len < 0)
|
||||
@@ -303,9 +279,7 @@ rpad(PG_FUNCTION_ARGS)
|
||||
if (s2len < 0)
|
||||
s2len = 0; /* shouldn't happen */
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
s1len = pg_mbstrlen_with_len(VARDATA(string1), s1len);
|
||||
#endif
|
||||
|
||||
if (s1len > len)
|
||||
s1len = len; /* truncate string1 to len chars */
|
||||
@@ -313,7 +287,6 @@ rpad(PG_FUNCTION_ARGS)
|
||||
if (s2len <= 0)
|
||||
len = s1len; /* nothing to pad with, so don't pad */
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
bytelen = pg_database_encoding_max_length() * len;
|
||||
|
||||
/* Check for integer overflow */
|
||||
@@ -321,15 +294,11 @@ rpad(PG_FUNCTION_ARGS)
|
||||
elog(ERROR, "Requested length too large");
|
||||
|
||||
ret = (text *) palloc(VARHDRSZ + bytelen);
|
||||
#else
|
||||
ret = (text *) palloc(VARHDRSZ + len);
|
||||
#endif
|
||||
m = len - s1len;
|
||||
|
||||
ptr1 = VARDATA(string1);
|
||||
ptr_ret = VARDATA(ret);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (s1len--)
|
||||
{
|
||||
int mlen = pg_mblen(ptr1);
|
||||
@@ -338,15 +307,10 @@ rpad(PG_FUNCTION_ARGS)
|
||||
ptr_ret += mlen;
|
||||
ptr1 += mlen;
|
||||
}
|
||||
#else
|
||||
while (s1len--)
|
||||
*ptr_ret++ = *ptr1++;
|
||||
#endif
|
||||
|
||||
ptr2 = VARDATA(string2);
|
||||
ptr2end = ptr2 + s2len;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m--)
|
||||
{
|
||||
int mlen = pg_mblen(ptr2);
|
||||
@@ -357,14 +321,6 @@ rpad(PG_FUNCTION_ARGS)
|
||||
if (ptr2 == ptr2end) /* wrap around at end of s2 */
|
||||
ptr2 = VARDATA(string2);
|
||||
}
|
||||
#else
|
||||
while (m--)
|
||||
{
|
||||
*ptr_ret++ = *ptr2++;
|
||||
if (ptr2 == ptr2end) /* wrap around at end of s2 */
|
||||
ptr2 = VARDATA(string2);
|
||||
}
|
||||
#endif
|
||||
|
||||
VARATT_SIZEP(ret) = ptr_ret - (char *) ret;
|
||||
|
||||
@@ -399,13 +355,11 @@ btrim(PG_FUNCTION_ARGS)
|
||||
*end2;
|
||||
int m;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
char **mp;
|
||||
int mplen;
|
||||
char *p;
|
||||
int mblen;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
|
||||
(VARSIZE(set) - VARHDRSZ) <= 0)
|
||||
@@ -413,7 +367,6 @@ btrim(PG_FUNCTION_ARGS)
|
||||
|
||||
ptr = VARDATA(string);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
len = m;
|
||||
mp = (char **) palloc(len * sizeof(char *));
|
||||
p = ptr;
|
||||
@@ -428,12 +381,8 @@ btrim(PG_FUNCTION_ARGS)
|
||||
len -= mblen;
|
||||
}
|
||||
mplen--;
|
||||
#else
|
||||
end = VARDATA(string) + VARSIZE(string) - VARHDRSZ - 1;
|
||||
#endif
|
||||
end2 = VARDATA(set) + VARSIZE(set) - VARHDRSZ - 1;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m > 0)
|
||||
{
|
||||
int str_len = pg_mblen(ptr);
|
||||
@@ -475,37 +424,6 @@ btrim(PG_FUNCTION_ARGS)
|
||||
m -= str_len;
|
||||
}
|
||||
pfree(mp);
|
||||
#else
|
||||
while (m > 0)
|
||||
{
|
||||
ptr2 = VARDATA(set);
|
||||
while (ptr2 <= end2)
|
||||
{
|
||||
if (*ptr == *ptr2)
|
||||
break;
|
||||
++ptr2;
|
||||
}
|
||||
if (ptr2 > end2)
|
||||
break;
|
||||
ptr++;
|
||||
m--;
|
||||
}
|
||||
|
||||
while (m > 0)
|
||||
{
|
||||
ptr2 = VARDATA(set);
|
||||
while (ptr2 <= end2)
|
||||
{
|
||||
if (*end == *ptr2)
|
||||
break;
|
||||
++ptr2;
|
||||
}
|
||||
if (ptr2 > end2)
|
||||
break;
|
||||
end--;
|
||||
m--;
|
||||
}
|
||||
#endif
|
||||
ret = (text *) palloc(VARHDRSZ + m);
|
||||
VARATT_SIZEP(ret) = VARHDRSZ + m;
|
||||
memcpy(VARDATA(ret), ptr, m);
|
||||
@@ -619,7 +537,6 @@ ltrim(PG_FUNCTION_ARGS)
|
||||
ptr = VARDATA(string);
|
||||
end2 = VARDATA(set) + VARSIZE(set) - VARHDRSZ - 1;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m > 0)
|
||||
{
|
||||
int str_len = pg_mblen(ptr);
|
||||
@@ -639,22 +556,6 @@ ltrim(PG_FUNCTION_ARGS)
|
||||
ptr += str_len;
|
||||
m -= str_len;
|
||||
}
|
||||
#else
|
||||
while (m > 0)
|
||||
{
|
||||
ptr2 = VARDATA(set);
|
||||
while (ptr2 <= end2)
|
||||
{
|
||||
if (*ptr == *ptr2)
|
||||
break;
|
||||
++ptr2;
|
||||
}
|
||||
if (ptr2 > end2)
|
||||
break;
|
||||
ptr++;
|
||||
m--;
|
||||
}
|
||||
#endif
|
||||
ret = (text *) palloc(VARHDRSZ + m);
|
||||
VARATT_SIZEP(ret) = VARHDRSZ + m;
|
||||
memcpy(VARDATA(ret), ptr, m);
|
||||
@@ -691,13 +592,11 @@ rtrim(PG_FUNCTION_ARGS)
|
||||
*end2;
|
||||
int m;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
char **mp;
|
||||
int mplen;
|
||||
char *p;
|
||||
int mblen;
|
||||
int len;
|
||||
#endif
|
||||
|
||||
if ((m = VARSIZE(string) - VARHDRSZ) <= 0 ||
|
||||
(VARSIZE(set) - VARHDRSZ) <= 0)
|
||||
@@ -705,7 +604,6 @@ rtrim(PG_FUNCTION_ARGS)
|
||||
|
||||
ptr = VARDATA(string);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
len = m;
|
||||
mp = (char **) palloc(len * sizeof(char *));
|
||||
p = ptr;
|
||||
@@ -720,12 +618,8 @@ rtrim(PG_FUNCTION_ARGS)
|
||||
len -= mblen;
|
||||
}
|
||||
mplen--;
|
||||
#else
|
||||
end = VARDATA(string) + VARSIZE(string) - VARHDRSZ - 1;
|
||||
#endif
|
||||
end2 = VARDATA(set) + VARSIZE(set) - VARHDRSZ - 1;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m > 0)
|
||||
{
|
||||
int str_len;
|
||||
@@ -747,22 +641,6 @@ rtrim(PG_FUNCTION_ARGS)
|
||||
m -= str_len;
|
||||
}
|
||||
pfree(mp);
|
||||
#else
|
||||
while (m > 0)
|
||||
{
|
||||
ptr2 = VARDATA(set);
|
||||
while (ptr2 <= end2)
|
||||
{
|
||||
if (*end == *ptr2)
|
||||
break;
|
||||
++ptr2;
|
||||
}
|
||||
if (ptr2 > end2)
|
||||
break;
|
||||
end--;
|
||||
m--;
|
||||
}
|
||||
#endif
|
||||
ret = (text *) palloc(VARHDRSZ + m);
|
||||
VARATT_SIZEP(ret) = VARHDRSZ + m;
|
||||
memcpy(VARDATA(ret), ptr, m);
|
||||
@@ -805,13 +683,11 @@ translate(PG_FUNCTION_ARGS)
|
||||
retlen,
|
||||
i;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
int str_len;
|
||||
int estimate_len;
|
||||
int len;
|
||||
int source_len;
|
||||
int from_index;
|
||||
#endif
|
||||
|
||||
if ((m = VARSIZE(string) - VARHDRSZ) <= 0)
|
||||
PG_RETURN_TEXT_P(string);
|
||||
@@ -821,20 +697,15 @@ translate(PG_FUNCTION_ARGS)
|
||||
tolen = VARSIZE(to) - VARHDRSZ;
|
||||
to_ptr = VARDATA(to);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
str_len = VARSIZE(string);
|
||||
estimate_len = (tolen * 1.0 / fromlen + 0.5) * str_len;
|
||||
estimate_len = estimate_len > str_len ? estimate_len : str_len;
|
||||
result = (text *) palloc(estimate_len);
|
||||
#else
|
||||
result = (text *) palloc(VARSIZE(string));
|
||||
#endif
|
||||
|
||||
source = VARDATA(string);
|
||||
target = VARDATA(result);
|
||||
retlen = 0;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
while (m > 0)
|
||||
{
|
||||
source_len = pg_mblen(source);
|
||||
@@ -880,37 +751,6 @@ translate(PG_FUNCTION_ARGS)
|
||||
source += source_len;
|
||||
m -= source_len;
|
||||
}
|
||||
#else
|
||||
while (m-- > 0)
|
||||
{
|
||||
char rep = *source++;
|
||||
|
||||
for (i = 0; i < fromlen; i++)
|
||||
{
|
||||
if (from_ptr[i] == rep)
|
||||
break;
|
||||
}
|
||||
if (i < fromlen)
|
||||
{
|
||||
if (i < tolen)
|
||||
{
|
||||
/* substitute */
|
||||
*target++ = to_ptr[i];
|
||||
retlen++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* discard */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no match, so copy */
|
||||
*target++ = rep;
|
||||
retlen++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
VARATT_SIZEP(result) = retlen + VARHDRSZ;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.7 2002/04/04 04:25:49 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/quote.c,v 1.8 2002/08/29 07:22:27 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -70,102 +70,6 @@ quote_literal(PG_FUNCTION_ARGS)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MULTIBYTE
|
||||
|
||||
/* Check if a given identifier needs quoting */
|
||||
static bool
|
||||
quote_ident_required(text *iptr)
|
||||
{
|
||||
char *cp;
|
||||
char *ep;
|
||||
|
||||
cp = VARDATA(iptr);
|
||||
ep = VARDATA(iptr) + VARSIZE(iptr) - VARHDRSZ;
|
||||
|
||||
if (cp >= ep)
|
||||
return true;
|
||||
|
||||
if (!(*cp == '_' || (*cp >= 'a' && *cp <= 'z')))
|
||||
return true;
|
||||
|
||||
while ((++cp) < ep)
|
||||
{
|
||||
if (*cp >= 'a' && *cp <= 'z')
|
||||
continue;
|
||||
if (*cp >= '0' && *cp <= '9')
|
||||
continue;
|
||||
if (*cp == '_')
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Return a properly quoted identifier */
|
||||
static text *
|
||||
do_quote_ident(text *iptr)
|
||||
{
|
||||
text *result;
|
||||
char *cp1;
|
||||
char *cp2;
|
||||
int len;
|
||||
|
||||
len = VARSIZE(iptr) - VARHDRSZ;
|
||||
result = (text *) palloc(len * 2 + VARHDRSZ + 2);
|
||||
|
||||
cp1 = VARDATA(iptr);
|
||||
cp2 = VARDATA(result);
|
||||
|
||||
*cp2++ = '"';
|
||||
while (len-- > 0)
|
||||
{
|
||||
if (*cp1 == '"')
|
||||
*cp2++ = '"';
|
||||
*cp2++ = *cp1++;
|
||||
}
|
||||
*cp2++ = '"';
|
||||
|
||||
VARATT_SIZEP(result) = cp2 - ((char *) result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Return a properly quoted literal value */
|
||||
static text *
|
||||
do_quote_literal(text *lptr)
|
||||
{
|
||||
text *result;
|
||||
char *cp1;
|
||||
char *cp2;
|
||||
int len;
|
||||
|
||||
len = VARSIZE(lptr) - VARHDRSZ;
|
||||
result = (text *) palloc(len * 2 + VARHDRSZ + 2);
|
||||
|
||||
cp1 = VARDATA(lptr);
|
||||
cp2 = VARDATA(result);
|
||||
|
||||
*cp2++ = '\'';
|
||||
while (len-- > 0)
|
||||
{
|
||||
if (*cp1 == '\'')
|
||||
*cp2++ = '\'';
|
||||
if (*cp1 == '\\')
|
||||
*cp2++ = '\\';
|
||||
*cp2++ = *cp1++;
|
||||
}
|
||||
*cp2++ = '\'';
|
||||
|
||||
VARATT_SIZEP(result) = cp2 - ((char *) result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* Check if a given identifier needs quoting (MULTIBYTE version) */
|
||||
static bool
|
||||
quote_ident_required(text *iptr)
|
||||
@@ -285,5 +189,3 @@ do_quote_literal(text *lptr)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.113 2002/08/22 00:01:44 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.114 2002/08/29 07:22:27 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -3250,12 +3250,8 @@ make_greater_string(const char *str, Oid datatype)
|
||||
* Truncate off the last character, which might be more than 1
|
||||
* byte in MULTIBYTE case.
|
||||
*/
|
||||
#ifdef MULTIBYTE
|
||||
len = pg_mbcliplen((const unsigned char *) workstr, len, len - 1);
|
||||
workstr[len] = '\0';
|
||||
#else
|
||||
*lastchar = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Failed... */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.91 2002/08/26 17:53:59 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.92 2002/08/29 07:22:27 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -21,9 +21,7 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
@@ -76,37 +74,26 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
maxlen;
|
||||
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
|
||||
|
||||
|
||||
/* If typmod is -1 (or invalid), use the actual string length */
|
||||
if (atttypmod < (int32) VARHDRSZ)
|
||||
#ifdef MULTIBYTE
|
||||
maxlen = charlen;
|
||||
#else
|
||||
maxlen = len;
|
||||
#endif
|
||||
else
|
||||
maxlen = atttypmod - VARHDRSZ;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
if (charlen > maxlen)
|
||||
#else
|
||||
if (len > maxlen)
|
||||
#endif
|
||||
{
|
||||
/* Verify that extra characters are spaces, and clip them off */
|
||||
#ifdef MULTIBYTE
|
||||
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
|
||||
|
||||
/*
|
||||
@@ -125,15 +112,7 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
* the number of CHARACTERS!
|
||||
*/
|
||||
maxlen = len;
|
||||
#else
|
||||
if (strspn(s + maxlen, " ") == len - maxlen)
|
||||
len = maxlen;
|
||||
else
|
||||
elog(ERROR, "value too long for type character(%d)",
|
||||
(int) maxlen);
|
||||
#endif
|
||||
}
|
||||
#ifdef MULTIBYTE
|
||||
else
|
||||
{
|
||||
/*
|
||||
@@ -142,7 +121,6 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
maxlen = len + (maxlen - charlen);
|
||||
}
|
||||
#endif
|
||||
|
||||
result = palloc(maxlen + VARHDRSZ);
|
||||
VARATT_SIZEP(result) = maxlen + VARHDRSZ;
|
||||
@@ -202,26 +180,19 @@ bpchar(PG_FUNCTION_ARGS)
|
||||
char *s;
|
||||
int i;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
int charlen; /* number of charcters in the input string
|
||||
* + VARHDRSZ */
|
||||
#endif
|
||||
|
||||
len = VARSIZE(source);
|
||||
#ifdef MULTIBYTE
|
||||
|
||||
charlen = pg_mbstrlen_with_len(VARDATA(source), len - VARHDRSZ) + VARHDRSZ;
|
||||
#endif
|
||||
|
||||
/* No work if typmod is invalid or supplied data matches it already */
|
||||
if (maxlen < (int32) VARHDRSZ || len == maxlen)
|
||||
PG_RETURN_BPCHAR_P(source);
|
||||
#ifdef MULTIBYTE
|
||||
|
||||
if (charlen > maxlen)
|
||||
#else
|
||||
if (len > maxlen)
|
||||
#endif
|
||||
{
|
||||
/* Verify that extra characters are spaces, and clip them off */
|
||||
#ifdef MULTIBYTE
|
||||
size_t maxmblen;
|
||||
|
||||
maxmblen = pg_mbcharcliplen(VARDATA(source), len - VARHDRSZ,
|
||||
@@ -239,16 +210,7 @@ bpchar(PG_FUNCTION_ARGS)
|
||||
* length+VARHDRSZ, not the number of CHARACTERS!
|
||||
*/
|
||||
maxlen = len;
|
||||
#else
|
||||
for (i = maxlen - VARHDRSZ; i < len - VARHDRSZ; i++)
|
||||
if (*(VARDATA(source) + i) != ' ')
|
||||
elog(ERROR, "value too long for type character(%d)",
|
||||
maxlen - VARHDRSZ);
|
||||
|
||||
len = maxlen;
|
||||
#endif
|
||||
}
|
||||
#ifdef MULTIBYTE
|
||||
else
|
||||
{
|
||||
/*
|
||||
@@ -257,7 +219,6 @@ bpchar(PG_FUNCTION_ARGS)
|
||||
*/
|
||||
maxlen = len + (maxlen - charlen);
|
||||
}
|
||||
#endif
|
||||
|
||||
s = VARDATA(source);
|
||||
|
||||
@@ -408,29 +369,22 @@ varcharin(PG_FUNCTION_ARGS)
|
||||
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)
|
||||
{
|
||||
/* Verify that extra characters are spaces, and clip them off */
|
||||
#ifdef MULTIBYTE
|
||||
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
|
||||
|
||||
if (strspn(s + mbmaxlen, " ") == len - mbmaxlen)
|
||||
len = mbmaxlen;
|
||||
#else
|
||||
if (strspn(s + maxlen, " ") == len - maxlen)
|
||||
len = maxlen;
|
||||
#endif
|
||||
else
|
||||
elog(ERROR, "value too long for type character varying(%d)",
|
||||
(int) maxlen);
|
||||
@@ -493,7 +447,6 @@ varchar(PG_FUNCTION_ARGS)
|
||||
|
||||
/* only reach here if string is too long... */
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
{
|
||||
size_t maxmblen;
|
||||
|
||||
@@ -508,15 +461,6 @@ varchar(PG_FUNCTION_ARGS)
|
||||
|
||||
len = maxmblen;
|
||||
}
|
||||
#else
|
||||
for (i = maxlen - VARHDRSZ; i < len - VARHDRSZ; i++)
|
||||
if (*(VARDATA(source) + i) != ' ')
|
||||
elog(ERROR, "value too long for type character varying(%d)",
|
||||
maxlen - VARHDRSZ);
|
||||
|
||||
/* clip extra spaces */
|
||||
len = maxlen;
|
||||
#endif
|
||||
|
||||
result = palloc(len);
|
||||
VARATT_SIZEP(result) = len;
|
||||
@@ -584,7 +528,6 @@ bpcharlen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
BpChar *arg = PG_GETARG_BPCHAR_P(0);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
/* optimization for single byte encoding */
|
||||
if (pg_database_encoding_max_length() <= 1)
|
||||
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
|
||||
@@ -592,9 +535,6 @@ bpcharlen(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(
|
||||
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
|
||||
);
|
||||
#else
|
||||
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
Datum
|
||||
@@ -796,7 +736,6 @@ varcharlen(PG_FUNCTION_ARGS)
|
||||
{
|
||||
VarChar *arg = PG_GETARG_VARCHAR_P(0);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
/* optimization for single byte encoding */
|
||||
if (pg_database_encoding_max_length() <= 1)
|
||||
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
|
||||
@@ -804,9 +743,6 @@ varcharlen(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_INT32(
|
||||
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
|
||||
);
|
||||
#else
|
||||
PG_RETURN_INT32(VARSIZE(arg) - VARHDRSZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
Datum
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.89 2002/08/28 20:46:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.90 2002/08/29 07:22:27 ishii Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -217,16 +217,12 @@ textin(PG_FUNCTION_ARGS)
|
||||
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;
|
||||
@@ -1476,12 +1472,8 @@ SplitIdentifierString(char *rawstring, char separator,
|
||||
curlen = strlen(curname);
|
||||
if (curlen >= NAMEDATALEN)
|
||||
{
|
||||
#ifdef MULTIBYTE
|
||||
curlen = pg_mbcliplen(curname, curlen, NAMEDATALEN - 1);
|
||||
curname[curlen] = '\0';
|
||||
#else
|
||||
curname[NAMEDATALEN - 1] = '\0';
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user