diff options
| author | Bruce Momjian <bruce@momjian.us> | 2003-12-01 21:52:38 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2003-12-01 21:52:38 +0000 |
| commit | 04a4821adef38155b7920ba9eb83c4c3c29156f8 (patch) | |
| tree | c778c2d286441d98a2453f06f5af9c2b214ffc3e /src/include/catalog/pg_proc.h | |
| parent | af03663878b257f7fb93a80eec03a8dd070b22b7 (diff) | |
| download | postgresql-04a4821adef38155b7920ba9eb83c4c3c29156f8.tar.gz | |
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/include/catalog/pg_proc.h')
| -rw-r--r-- | src/include/catalog/pg_proc.h | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 5515a48d31..1ed5359ffb 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.316 2003/11/29 22:40:58 pgsql Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.317 2003/12/01 21:52:37 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -208,8 +208,6 @@ DESCR("PostgreSQL version string"); /* OIDS 100 - 199 */ -DATA(insert OID = 100 ( int8fac PGNSP PGUID 12 f f t f i 1 20 "20" int8fac - _null_ )); -DESCR("factorial"); DATA(insert OID = 101 ( eqsel PGNSP PGUID 12 f f t f s 4 701 "2281 26 2281 23" eqsel - _null_ )); DESCR("restriction selectivity of = and related operators"); DATA(insert OID = 102 ( neqsel PGNSP PGUID 12 f f t f s 4 701 "2281 26 2281 23" neqsel - _null_ )); @@ -231,7 +229,7 @@ DATA(insert OID = 109 ( unknownin PGNSP PGUID 12 f f t f i 1 705 "2275" un DESCR("I/O"); DATA(insert OID = 110 ( unknownout PGNSP PGUID 12 f f t f i 1 2275 "705" unknownout - _null_ )); DESCR("I/O"); - +DATA(insert OID = 111 ( numeric_fac PGNSP PGUID 12 f f t f i 1 1700 "20" numeric_fac - _null_ )); DATA(insert OID = 112 ( text PGNSP PGUID 12 f f t f i 1 25 "23" int4_text - _null_ )); DESCR("convert int4 to text"); DATA(insert OID = 113 ( text PGNSP PGUID 12 f f t f i 1 25 "21" int2_text - _null_ )); @@ -294,8 +292,6 @@ DATA(insert OID = 140 ( areajoinsel PGNSP PGUID 12 f f t f s 4 701 "2281 26 DESCR("join selectivity for area-comparison operators"); DATA(insert OID = 141 ( int4mul PGNSP PGUID 12 f f t f i 2 23 "23 23" int4mul - _null_ )); DESCR("multiply"); -DATA(insert OID = 142 ( int4fac PGNSP PGUID 12 f f t f i 1 23 "23" int4fac - _null_ )); -DESCR("factorial"); DATA(insert OID = 144 ( int4ne PGNSP PGUID 12 f f t f i 2 16 "23 23" int4ne - _null_ )); DESCR("not equal"); DATA(insert OID = 145 ( int2ne PGNSP PGUID 12 f f t f i 2 16 "21 21" int2ne - _null_ )); @@ -571,9 +567,6 @@ DESCR("Current date and time - increments during transactions"); DATA(insert OID = 275 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "702" abstime_finite - _null_ )); DESCR("finite abstime?"); -DATA(insert OID = 276 ( int2fac PGNSP PGUID 12 f f t f i 1 23 "21" int2fac - _null_ )); -DESCR("factorial"); - DATA(insert OID = 277 ( inter_sl PGNSP PGUID 12 f f t f i 2 16 "601 628" inter_sl - _null_ )); DESCR("intersect?"); DATA(insert OID = 278 ( inter_lb PGNSP PGUID 12 f f t f i 2 16 "628 603" inter_lb - _null_ )); @@ -1758,11 +1751,7 @@ DATA(insert OID = 1390 ( isfinite PGNSP PGUID 12 f f t f i 1 16 "1186" inte DESCR("finite interval?"); -DATA(insert OID = 1391 ( factorial PGNSP PGUID 12 f f t f i 1 23 "21" int2fac - _null_ )); -DESCR("factorial"); -DATA(insert OID = 1392 ( factorial PGNSP PGUID 12 f f t f i 1 23 "23" int4fac - _null_ )); -DESCR("factorial"); -DATA(insert OID = 1393 ( factorial PGNSP PGUID 12 f f t f i 1 20 "20" int8fac - _null_ )); +DATA(insert OID = 1376 ( factorial PGNSP PGUID 12 f f t f i 1 1700 "20" numeric_fac - _null_ )); DESCR("factorial"); DATA(insert OID = 1394 ( abs PGNSP PGUID 12 f f t f i 1 700 "700" float4abs - _null_ )); DESCR("absolute value"); |
