mirror of
https://github.com/postgres/postgres.git
synced 2025-06-29 10:41:53 +03:00
Add explicit casts between int4 and boolean. Patch from Sean Chittenden,
editorializing by Neil Conway. Catalog version bumped.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.64 2004/12/31 22:01:22 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.65 2005/02/27 08:31:30 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -361,6 +361,25 @@ text_int4(PG_FUNCTION_ARGS)
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Cast int4 -> bool */
|
||||
Datum
|
||||
int4_bool(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_GETARG_INT32(0) == 0)
|
||||
PG_RETURN_BOOL(false);
|
||||
else
|
||||
PG_RETURN_BOOL(true);
|
||||
}
|
||||
|
||||
/* Cast bool -> int4 */
|
||||
Datum
|
||||
bool_int4(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (PG_GETARG_BOOL(0) == false)
|
||||
PG_RETURN_INT32(0);
|
||||
else
|
||||
PG_RETURN_INT32(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* ============================
|
||||
|
Reference in New Issue
Block a user