summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/bool.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/utils/adt/bool.c
parentf948197b4055bb0e22e508e9d6966217b7dbea3d (diff)
downloadpostgresql-220db7ccd8c88aafea4629f00e8be6f9f073ed00.tar.gz
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/utils/adt/bool.c')
-rw-r--r--src/backend/utils/adt/bool.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c
index 7261ab3e40..4ba234c62c 100644
--- a/src/backend/utils/adt/bool.c
+++ b/src/backend/utils/adt/bool.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.42 2008/01/01 19:45:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/bool.c,v 1.43 2008/03/25 22:42:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -152,14 +152,14 @@ Datum
booltext(PG_FUNCTION_ARGS)
{
bool arg1 = PG_GETARG_BOOL(0);
- char *str;
+ const char *str;
if (arg1)
str = "true";
else
str = "false";
- PG_RETURN_DATUM(DirectFunctionCall1(textin, CStringGetDatum(str)));
+ PG_RETURN_TEXT_P(cstring_to_text(str));
}