1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* bool.c--
|
1997-09-07 07:04:48 +02:00
|
|
|
* Functions for the built-in type "bool".
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
1997-09-07 07:04:48 +02:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.5 1997/09/07 04:49:58 momjian Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-11-03 07:54:38 +01:00
|
|
|
|
|
|
|
#include "postgres.h"
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
#include "utils/builtins.h" /* where the declarations go */
|
1996-07-09 08:22:35 +02:00
|
|
|
#include "utils/palloc.h"
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* USER I/O ROUTINES *
|
1996-07-09 08:22:35 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* boolin - converts "t" or "f" to 1 or 0
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1996-07-09 08:22:35 +02:00
|
|
|
boolin(char *b)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
if (b == NULL)
|
|
|
|
elog(WARN, "Bad input string for type bool");
|
|
|
|
return ((bool) (*b == 't') || (*b == 'T'));
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1997-09-07 07:04:48 +02:00
|
|
|
* boolout - converts 1 or 0 to "t" or "f"
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
char *
|
1996-07-09 08:22:35 +02:00
|
|
|
boolout(long b)
|
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
char *result = (char *) palloc(2);
|
|
|
|
|
|
|
|
*result = (b) ? 't' : 'f';
|
|
|
|
result[1] = '\0';
|
|
|
|
return (result);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* PUBLIC ROUTINES *
|
1996-07-09 08:22:35 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1997-09-07 07:04:48 +02:00
|
|
|
booleq(int8 arg1, int8 arg2)
|
|
|
|
{
|
|
|
|
return (arg1 == arg2);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-03-15 00:21:12 +01:00
|
|
|
bool
|
1997-09-07 07:04:48 +02:00
|
|
|
boolne(int8 arg1, int8 arg2)
|
1996-07-09 08:22:35 +02:00
|
|
|
{
|
1997-09-07 07:04:48 +02:00
|
|
|
return (arg1 != arg2);
|
1996-07-09 08:22:35 +02:00
|
|
|
}
|
|
|
|
|
1997-04-27 21:20:16 +02:00
|
|
|
bool
|
1997-09-07 07:04:48 +02:00
|
|
|
boollt(int8 arg1, int8 arg2)
|
|
|
|
{
|
|
|
|
return (arg1 < arg2);
|
1997-04-27 21:20:16 +02:00
|
|
|
}
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1997-04-27 21:20:16 +02:00
|
|
|
bool
|
1997-09-07 07:04:48 +02:00
|
|
|
boolgt(int8 arg1, int8 arg2)
|
|
|
|
{
|
|
|
|
return (arg1 > arg2);
|
1997-04-27 21:20:16 +02:00
|
|
|
}
|