summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/bool.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-05-12 23:08:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-05-12 23:08:52 +0000
commit30f609484d025bfb7c69f8f6b9610dc981cb5fb8 (patch)
tree479152f5d7605284dfecb779eadaf0e254723815 /src/backend/utils/adt/bool.c
parentb02832719ce9926fe5a1c9b7e03cebf3dbf6a653 (diff)
downloadpostgresql-30f609484d025bfb7c69f8f6b9610dc981cb5fb8.tar.gz
Add binary I/O routines for a bunch more datatypes. Still a few to go,
but that was enough tedium for one day. Along the way, move the few support routines for types xid and cid into a more logical place.
Diffstat (limited to 'src/backend/utils/adt/bool.c')
-rw-r--r--src/backend/utils/adt/bool.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c
index a2fb5b4fa2..ccc9768303 100644
--- a/src/backend/utils/adt/bool.c
+++ b/src/backend/utils/adt/bool.c
@@ -8,13 +8,14 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.26 2002/06/20 20:29:36 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.27 2003/05/12 23:08:50 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
+#include "libpq/pqformat.h"
#include "utils/builtins.h"
/*****************************************************************************
@@ -94,6 +95,36 @@ boolout(PG_FUNCTION_ARGS)
PG_RETURN_CSTRING(result);
}
+/*
+ * boolrecv - converts external binary format to bool
+ *
+ * The external representation is one byte. Any nonzero value is taken
+ * as "true".
+ */
+Datum
+boolrecv(PG_FUNCTION_ARGS)
+{
+ StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
+ int ext;
+
+ ext = pq_getmsgbyte(buf);
+ PG_RETURN_BOOL((ext != 0) ? true : false);
+}
+
+/*
+ * boolsend - converts bool to binary format
+ */
+Datum
+boolsend(PG_FUNCTION_ARGS)
+{
+ bool arg1 = PG_GETARG_BOOL(0);
+ StringInfoData buf;
+
+ pq_begintypsend(&buf);
+ pq_sendbyte(&buf, arg1 ? 1 : 0);
+ PG_RETURN_BYTEA_P(pq_endtypsend(&buf));
+}
+
/*****************************************************************************
* PUBLIC ROUTINES *