diff options
author | Neil Conway <neilc@samurai.com> | 2005-02-27 08:31:30 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2005-02-27 08:31:30 +0000 |
commit | 5285b3576316b6ff6cd02834b63f0a1f3f5b3e08 (patch) | |
tree | e54973c318676863b5b7c29a6e8ef006a2f3c102 /src/backend/utils/adt/int.c | |
parent | 2d22f16132991db1f779fae90e7f9f4df52d044c (diff) | |
download | postgresql-5285b3576316b6ff6cd02834b63f0a1f3f5b3e08.tar.gz postgresql-5285b3576316b6ff6cd02834b63f0a1f3f5b3e08.zip |
Add explicit casts between int4 and boolean. Patch from Sean Chittenden,
editorializing by Neil Conway. Catalog version bumped.
Diffstat (limited to 'src/backend/utils/adt/int.c')
-rw-r--r-- | src/backend/utils/adt/int.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 7525b50bfec..db36ac963e1 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -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); +} /* * ============================ |