diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-25 22:42:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-03-25 22:42:46 +0000 |
commit | 220db7ccd8c88aafea4629f00e8be6f9f073ed00 (patch) | |
tree | 772c9dca19736eb9d417cb665a281686c3570b4c /src/pl/plperl/plperl.c | |
parent | f948197b4055bb0e22e508e9d6966217b7dbea3d (diff) |
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/pl/plperl/plperl.c')
-rw-r--r-- | src/pl/plperl/plperl.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c index 3ce8f60c262..9922a4a0edb 100644 --- a/src/pl/plperl/plperl.c +++ b/src/pl/plperl/plperl.c @@ -1,7 +1,7 @@ /********************************************************************** * plperl.c - perl as a procedural language for PostgreSQL * - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.137 2008/03/25 19:26:53 neilc Exp $ + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.138 2008/03/25 22:42:45 tgl Exp $ * **********************************************************************/ @@ -542,7 +542,7 @@ plperl_safe_init(void) desc.arg_is_rowtype[0] = false; fmgr_info(F_TEXTOUT, &(desc.arg_out_func[0])); - fcinfo.arg[0] = DirectFunctionCall1(textin, CStringGetDatum("a")); + fcinfo.arg[0] = CStringGetTextDatum("a"); fcinfo.argnull[0] = false; /* and make the call */ @@ -1668,8 +1668,7 @@ compile_plperl_function(Oid fn_oid, bool is_trigger) Anum_pg_proc_prosrc, &isnull); if (isnull) elog(ERROR, "null prosrc"); - proc_source = DatumGetCString(DirectFunctionCall1(textout, - prosrcdatum)); + proc_source = TextDatumGetCString(prosrcdatum); /************************************************************ * Create the procedure in the interpreter |