aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/int8.c
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2003-12-01 21:52:38 +0000
committerBruce Momjian <bruce@momjian.us>2003-12-01 21:52:38 +0000
commit04a4821adef38155b7920ba9eb83c4c3c29156f8 (patch)
treec778c2d286441d98a2453f06f5af9c2b214ffc3e /src/backend/utils/adt/int8.c
parentaf03663878b257f7fb93a80eec03a8dd070b22b7 (diff)
downloadpostgresql-04a4821adef38155b7920ba9eb83c4c3c29156f8.tar.gz
postgresql-04a4821adef38155b7920ba9eb83c4c3c29156f8.zip
Attached is a patch implementing factorial(), returning numeric. Points
to note: 1) arttype is numeric. I thought this was the best way of allowing arbitarily large factorials, even though factorial(2^63) is a large number. Happy to change to integers if this is overkill. 2) since we're accepting numeric arguments, the patch tests for floats. If a numeric is passed with non-zero decimal portion, an error is raised since (from memory) they are undefined. Gavin Sherry
Diffstat (limited to 'src/backend/utils/adt/int8.c')
-rw-r--r--src/backend/utils/adt/int8.c22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 616ceaaf9db..016330a0533 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
- * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.49 2003/11/29 19:51:58 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/int8.c,v 1.50 2003/12/01 21:52:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -561,26 +561,6 @@ int8mod(PG_FUNCTION_ARGS)
PG_RETURN_INT64(result);
}
-/* int8fac()
- * Factorial
- */
-Datum
-int8fac(PG_FUNCTION_ARGS)
-{
- int64 arg1 = PG_GETARG_INT64(0);
- int64 result;
- int64 i;
-
- if (arg1 == 0)
- result = 1;
- else if (arg1 < 1)
- result = 0;
- else
- for (i = arg1, result = 1; i > 0; --i)
- result *= i;
-
- PG_RETURN_INT64(result);
-}
Datum
int8inc(PG_FUNCTION_ARGS)