aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/functions.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-25 22:42:46 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-25 22:42:46 +0000
commit220db7ccd8c88aafea4629f00e8be6f9f073ed00 (patch)
tree772c9dca19736eb9d417cb665a281686c3570b4c /src/backend/executor/functions.c
parentf948197b4055bb0e22e508e9d6966217b7dbea3d (diff)
downloadpostgresql-220db7ccd8c88aafea4629f00e8be6f9f073ed00.tar.gz
postgresql-220db7ccd8c88aafea4629f00e8be6f9f073ed00.zip
Simplify and standardize conversions between TEXT datums and ordinary C
strings. This patch introduces four support functions cstring_to_text, cstring_to_text_with_len, text_to_cstring, and text_to_cstring_buffer, and two macros CStringGetTextDatum and TextDatumGetCString. A number of existing macros that provided variants on these themes were removed. Most of the places that need to make such conversions now require just one function or macro call, in place of the multiple notational layers that used to be needed. There are no longer any direct calls of textout or textin, and we got most of the places that were using handmade conversions via memcpy (there may be a few still lurking, though). This commit doesn't make any serious effort to eliminate transient memory leaks caused by detoasting toasted text objects before they reach text_to_cstring. We changed PG_GETARG_TEXT_P to PG_GETARG_TEXT_PP in a few places where it was easy, but much more could be done. Brendan Jurd and Tom Lane
Diffstat (limited to 'src/backend/executor/functions.c')
-rw-r--r--src/backend/executor/functions.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index da6976b62f7..678b43927d7 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.121 2008/03/18 22:04:14 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/functions.c,v 1.122 2008/03/25 22:42:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -244,7 +244,7 @@ init_sql_fcache(FmgrInfo *finfo)
&isNull);
if (isNull)
elog(ERROR, "null prosrc for function %u", foid);
- fcache->src = DatumGetCString(DirectFunctionCall1(textout, tmp));
+ fcache->src = TextDatumGetCString(tmp);
/*
* Parse and rewrite the queries in the function text.
@@ -777,7 +777,7 @@ sql_exec_error_callback(void *arg)
&isnull);
if (isnull)
elog(ERROR, "null prosrc");
- prosrc = DatumGetCString(DirectFunctionCall1(textout, tmp));
+ prosrc = TextDatumGetCString(tmp);
errposition(0);
internalerrposition(syntaxerrposition);
internalerrquery(prosrc);