Attached is a patch implementing factorial(), returning numeric. Points
Bruce Momjian <bruce@momjian.us>
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
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/int8.c | modified | +1 −21 |
| src/backend/utils/adt/int.c | modified | +2 −36 |
| src/backend/utils/adt/numeric.c | modified | +50 −1 |
| src/include/catalog/pg_operator.h | modified | +3 −7 |
| src/include/catalog/pg_proc.h | modified | +3 −14 |
| src/include/utils/builtins.h | modified | +2 −3 |
| src/include/utils/int8.h | modified | +1 −2 |
| src/test/regress/expected/create_operator.out | modified | +6 −8 |
| src/test/regress/sql/create_operator.sql | modified | +6 −8 |