Skip to content

Commit 722f31f

Browse files
committed
Thank you for applying patch --- regexp_replace.
An attached patch is a small additional improvement. This patch use appendStringInfoText instead of appendStringInfoString. There is an overhead of PG_TEXT_GET_STR when appendStringInfoString is executed by text type. This can be reduced by appendStringInfoText. Atsushi Ogawa
1 parent 5d27bf2 commit 722f31f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/backend/utils/adt/varlena.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.129 2005/07/21 04:41:43 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.130 2005/07/29 03:17:55 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2064,7 +2064,7 @@ appendStringInfoRegexpSubstr(StringInfo str, text *replace_text,
20642064
{
20652065
text *append_text = text_substring(PointerGetDatum(replace_text),
20662066
substr_start, ch_cnt, false);
2067-
appendStringInfoString(str, PG_TEXT_GET_STR(append_text));
2067+
appendStringInfoText(str, append_text);
20682068
pfree(append_text);
20692069
}
20702070
substr_start += ch_cnt + 1;
@@ -2099,7 +2099,7 @@ appendStringInfoRegexpSubstr(StringInfo str, text *replace_text,
20992099
/* Copy the text that is back reference of regexp. */
21002100
text *append_text = text_substring(PointerGetDatum(src_text),
21012101
so + 1, (eo - so), false);
2102-
appendStringInfoString(str, PG_TEXT_GET_STR(append_text));
2102+
appendStringInfoText(str, append_text);
21032103
pfree(append_text);
21042104
}
21052105
}
@@ -2169,7 +2169,7 @@ replace_text_regexp(PG_FUNCTION_ARGS)
21692169
text *left_text = text_substring(PointerGetDatum(src_text),
21702170
data_pos + 1,
21712171
pmatch[0].rm_so - data_pos, false);
2172-
appendStringInfoString(str, PG_TEXT_GET_STR(left_text));
2172+
appendStringInfoText(str, left_text);
21732173
pfree(left_text);
21742174
}
21752175

@@ -2180,7 +2180,7 @@ replace_text_regexp(PG_FUNCTION_ARGS)
21802180
if (have_escape)
21812181
appendStringInfoRegexpSubstr(str, replace_text, pmatch, src_text);
21822182
else
2183-
appendStringInfoString(str, PG_TEXT_GET_STR(replace_text));
2183+
appendStringInfoText(str, replace_text);
21842184

21852185
search_start = data_pos = pmatch[0].rm_eo;
21862186

@@ -2205,7 +2205,7 @@ replace_text_regexp(PG_FUNCTION_ARGS)
22052205
{
22062206
text *right_text = text_substring(PointerGetDatum(src_text),
22072207
data_pos + 1, -1, true);
2208-
appendStringInfoString(str, PG_TEXT_GET_STR(right_text));
2208+
appendStringInfoText(str, right_text);
22092209
pfree(right_text);
22102210
}
22112211

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy