summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varchar.c
diff options
context:
space:
mode:
authorTatsuo Ishii <ishii@postgresql.org>2001-11-18 12:07:07 +0000
committerTatsuo Ishii <ishii@postgresql.org>2001-11-18 12:07:07 +0000
commit226211f0af3b9deee6733a5393f32cb34c59bc53 (patch)
tree200d90ea15b5a7c1de85f1cea774ca0e58d6f3ae /src/backend/utils/adt/varchar.c
parente2548526cf21896c775aa35da8cc2ef24acda597 (diff)
Optimization for bpcharlen, textlen, varcharlen in case of single byte
encodings.
Diffstat (limited to 'src/backend/utils/adt/varchar.c')
-rw-r--r--src/backend/utils/adt/varchar.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index b7230b5bbd9..f25a06e1449 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.86 2001/11/08 04:05:13 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.87 2001/11/18 12:07:07 ishii Exp $
*
*-------------------------------------------------------------------------
*/
@@ -598,6 +598,10 @@ 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);
+
PG_RETURN_INT32(
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);
@@ -806,6 +810,10 @@ 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);
+
PG_RETURN_INT32(
pg_mbstrlen_with_len(VARDATA(arg), VARSIZE(arg) - VARHDRSZ)
);