Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit226211f

Browse files
committed
Optimization for bpcharlen, textlen, varcharlen in case of single byte
encodings.
1 parente254852 commit226211f

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

‎src/backend/utils/adt/varchar.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.86 2001/11/08 04:05:13 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.87 2001/11/18 12:07:07 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -598,6 +598,10 @@ bpcharlen(PG_FUNCTION_ARGS)
598598
BpChar*arg=PG_GETARG_BPCHAR_P(0);
599599

600600
#ifdefMULTIBYTE
601+
/* optimization for single byte encoding */
602+
if (pg_database_encoding_max_length() <=1)
603+
PG_RETURN_INT32(VARSIZE(arg)-VARHDRSZ);
604+
601605
PG_RETURN_INT32(
602606
pg_mbstrlen_with_len(VARDATA(arg),VARSIZE(arg)-VARHDRSZ)
603607
);
@@ -806,6 +810,10 @@ varcharlen(PG_FUNCTION_ARGS)
806810
VarChar*arg=PG_GETARG_VARCHAR_P(0);
807811

808812
#ifdefMULTIBYTE
813+
/* optimization for single byte encoding */
814+
if (pg_database_encoding_max_length() <=1)
815+
PG_RETURN_INT32(VARSIZE(arg)-VARHDRSZ);
816+
809817
PG_RETURN_INT32(
810818
pg_mbstrlen_with_len(VARDATA(arg),VARSIZE(arg)-VARHDRSZ)
811819
);

‎src/backend/utils/adt/varlena.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.74 2001/10/25 05:49:46 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.75 2001/11/18 12:07:07 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -240,22 +240,13 @@ textlen(PG_FUNCTION_ARGS)
240240
text*t=PG_GETARG_TEXT_P(0);
241241

242242
#ifdefMULTIBYTE
243-
unsignedchar*s;
244-
intlen,
245-
l,
246-
wl;
247-
248-
len=0;
249-
s=VARDATA(t);
250-
l=VARSIZE(t)-VARHDRSZ;
251-
while (l>0)
252-
{
253-
wl=pg_mblen(s);
254-
l-=wl;
255-
s+=wl;
256-
len++;
257-
}
258-
PG_RETURN_INT32(len);
243+
/* optimization for single byte encoding */
244+
if (pg_database_encoding_max_length() <=1)
245+
PG_RETURN_INT32(VARSIZE(t)-VARHDRSZ);
246+
247+
PG_RETURN_INT32(
248+
pg_mbstrlen_with_len(VARDATA(t),VARSIZE(t)-VARHDRSZ)
249+
);
259250
#else
260251
PG_RETURN_INT32(VARSIZE(t)-VARHDRSZ);
261252
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp