1 /*-------------------------------------------------------------------------
4 * Functions for the built-in type "bool".
6 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.21 2000/01/26 05:57:13 momjian Exp $
13 *-------------------------------------------------------------------------
18 #include "utils/builtins.h"
20 /*****************************************************************************
22 *****************************************************************************/
25 * boolin - converts "t" or "f" to 1 or 0
27 * Check explicitly for "true/false" and TRUE/FALSE, 1/0, YES/NO.
28 * Reject other values. - thomas 1997-10-05
30 * In the switch statement, check the most-used possibilities first.
39 if (strncasecmp(b, "true", strlen(b)) == 0)
45 if (strncasecmp(b, "false", strlen(b)) == 0)
51 if (strncasecmp(b, "yes", strlen(b)) == 0)
56 if (strncasecmp(b, "1", strlen(b)) == 0)
62 if (strncasecmp(b, "no", strlen(b)) == 0)
67 if (strncasecmp(b, "0", strlen(b)) == 0)
75 elog(ERROR, "Bad boolean external representation '%s'", b);
81 * boolout - converts 1 or 0 to "t" or "f"
86 char *result = (char *) palloc(2);
88 *result = (b) ? 't' : 'f';
94 /*****************************************************************************
96 *****************************************************************************/
99 booleq(bool arg1, bool arg2)
105 boolne(bool arg1, bool arg2)
111 boollt(bool arg1, bool arg2)
117 boolgt(bool arg1, bool arg2)