diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-25 14:10:07 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-10-25 14:10:07 +0000 |
commit | a0cd991987bd23d79d5d273e7712afe40dba554b (patch) | |
tree | 94f0068451398a1cce08a424ac5f7bb36e4c1701 /src/backend/utils | |
parent | 92e8282229d0be6c8cbfed12d311a0a39f409885 (diff) | |
download | postgresql-a0cd991987bd23d79d5d273e7712afe40dba554b.tar.gz postgresql-a0cd991987bd23d79d5d273e7712afe40dba554b.zip |
Add int2-to-int8 and int8-to-int2 conversion routines. Needed to avoid
breaking existing pg_dump scripts, which try to assign the result of
count(*) to an int2 variable. catversion bumped.
Diffstat (limited to 'src/backend/utils')
-rw-r--r-- | src/backend/utils/adt/int8.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 41a60615884..b689cb764a4 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.34 2001/10/25 05:49:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.35 2001/10/25 14:10:06 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -698,6 +698,29 @@ int84(PG_FUNCTION_ARGS) } Datum +int28(PG_FUNCTION_ARGS) +{ + int16 val = PG_GETARG_INT16(0); + + PG_RETURN_INT64((int64) val); +} + +Datum +int82(PG_FUNCTION_ARGS) +{ + int64 val = PG_GETARG_INT64(0); + int16 result; + + result = (int16) val; + + /* Test for overflow by reverse-conversion. */ + if ((int64) result != val) + elog(ERROR, "int8 conversion to int2 is out of range"); + + PG_RETURN_INT16(result); +} + +Datum i8tod(PG_FUNCTION_ARGS) { int64 val = PG_GETARG_INT64(0); |