aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-06-17 19:10:56 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-06-17 19:10:56 +0000
commitb163baa89ce0e4385497bc0f38deaf0078074d76 (patch)
tree247ea4721f276d9c9cb608b1e3fd586aa861269c /src/backend/utils/adt/int.c
parent4274726d4225158c69fef04aadc10e7e26f41971 (diff)
downloadpostgresql-b163baa89ce0e4385497bc0f38deaf0078074d76.tar.gz
postgresql-b163baa89ce0e4385497bc0f38deaf0078074d76.zip
Clean up some problems with redundant cross-type arithmetic operators. Add
int2-and-int8 implementations of the basic arithmetic operators +, -, *, /. This doesn't really add any new functionality, but it avoids "operator is not unique" failures that formerly occurred in these cases because the parser couldn't decide whether to promote the int2 to int4 or int8. We could alternatively have removed the existing cross-type operators, but experimentation shows that the cost of an additional type coercion expression node is noticeable compared to such cheap operators; so let's not give up any performance here. On the other hand, I removed the int2-and-int4 modulo (%) operators since they didn't seem as important from a performance standpoint. Per a complaint last January from ykhuang.
Diffstat (limited to 'src/backend/utils/adt/int.c')
-rw-r--r--src/backend/utils/adt/int.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c
index 64ba146d713..c8dfe1cfeb7 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.81 2008/01/01 19:45:52 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int.c,v 1.82 2008/06/17 19:10:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1085,36 +1085,6 @@ int2mod(PG_FUNCTION_ARGS)
PG_RETURN_INT16(arg1 % arg2);
}
-Datum
-int24mod(PG_FUNCTION_ARGS)
-{
- int16 arg1 = PG_GETARG_INT16(0);
- int32 arg2 = PG_GETARG_INT32(1);
-
- if (arg2 == 0)
- ereport(ERROR,
- (errcode(ERRCODE_DIVISION_BY_ZERO),
- errmsg("division by zero")));
- /* No overflow is possible */
-
- PG_RETURN_INT32(arg1 % arg2);
-}
-
-Datum
-int42mod(PG_FUNCTION_ARGS)
-{
- int32 arg1 = PG_GETARG_INT32(0);
- int16 arg2 = PG_GETARG_INT16(1);
-
- if (arg2 == 0)
- ereport(ERROR,
- (errcode(ERRCODE_DIVISION_BY_ZERO),
- errmsg("division by zero")));
- /* No overflow is possible */
-
- PG_RETURN_INT32(arg1 % arg2);
-}
-
/* int[24]abs()
* Absolute value