1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-10 14:22:35 +03:00

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
This commit is contained in:
Bruce Momjian
2003-12-01 21:52:38 +00:00
parent af03663878
commit 04a4821ade
9 changed files with 74 additions and 100 deletions

View File

@@ -15,19 +15,17 @@ CREATE OPERATOR <% (
negator = >=%
);
CREATE OPERATOR @#@ (
rightarg = int4, -- left unary
procedure = int4fac
rightarg = int8, -- left unary
procedure = numeric_fac
);
CREATE OPERATOR #@# (
leftarg = int4, -- right unary
procedure = int4fac
leftarg = int8, -- right unary
procedure = numeric_fac
);
CREATE OPERATOR #%# (
leftarg = int4, -- right unary
procedure = int4fac
leftarg = int8, -- right unary
procedure = numeric_fac
);
-- Test comments
COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary';
ERROR: operator does not exist: integer ######
COMMENT ON OPERATOR #%# (int4, NONE) IS 'right unary';
COMMENT ON OPERATOR #%# (int4, NONE) IS NULL;

View File

@@ -18,23 +18,21 @@ CREATE OPERATOR <% (
);
CREATE OPERATOR @#@ (
rightarg = int4, -- left unary
procedure = int4fac
rightarg = int8, -- left unary
procedure = numeric_fac
);
CREATE OPERATOR #@# (
leftarg = int4, -- right unary
procedure = int4fac
leftarg = int8, -- right unary
procedure = numeric_fac
);
CREATE OPERATOR #%# (
leftarg = int4, -- right unary
procedure = int4fac
leftarg = int8, -- right unary
procedure = numeric_fac
);
-- Test comments
COMMENT ON OPERATOR ###### (int4, NONE) IS 'bad right unary';
COMMENT ON OPERATOR #%# (int4, NONE) IS 'right unary';
COMMENT ON OPERATOR #%# (int4, NONE) IS NULL;