1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

- Fixed Informix compat math functions to cope with the situations

where one argument takes the result.
- Applied thread patches by Lee Kindness
This commit is contained in:
Michael Meskes
2004-03-14 12:16:30 +00:00
parent 80ac9b06ac
commit 757fb0e5a9
7 changed files with 181 additions and 102 deletions

View File

@ -60,8 +60,7 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
*nres;
int i;
/* set it to null in case it errors out later */
rsetnull(CDECIMALTYPE, (char *) result);
/* we must NOT set the result to NULL here because it may be the same variable as one of the arguments */
if (risnull(CDECIMALTYPE, (char *) arg1) || risnull(CDECIMALTYPE, (char *) arg2))
return 0;
@ -100,8 +99,13 @@ deccall3(decimal * arg1, decimal * arg2, decimal * result, int (*ptr) (numeric *
i = (*ptr) (a1, a2, nres);
if (i == 0) /* No error */
{
/* set the result to null in case it errors out later */
rsetnull(CDECIMALTYPE, (char *) result);
PGTYPESnumeric_to_decimal(nres, result);
}
PGTYPESnumeric_free(nres);
PGTYPESnumeric_free(a1);
PGTYPESnumeric_free(a2);
@ -268,7 +272,6 @@ decdiv(decimal * n1, decimal * n2, decimal * result)
int i;
rsetnull(CDECIMALTYPE, (char *) result);
i = deccall3(n1, n2, result, PGTYPESnumeric_div);
if (i != 0)
@ -293,7 +296,6 @@ decmul(decimal * n1, decimal * n2, decimal * result)
{
int i;
rsetnull(CDECIMALTYPE, (char *) result);
i = deccall3(n1, n2, result, PGTYPESnumeric_mul);
if (i != 0)
@ -315,7 +317,6 @@ decsub(decimal * n1, decimal * n2, decimal * result)
{
int i;
rsetnull(CDECIMALTYPE, (char *) result);
i = deccall3(n1, n2, result, PGTYPESnumeric_sub);
if (i != 0)