diff options
author | Michael Meskes <meskes@postgresql.org> | 2004-03-14 12:16:30 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2004-03-14 12:16:30 +0000 |
commit | 757fb0e5a9a61ac8d3a67e334faeea6dc0084b3f (patch) | |
tree | 36660558226b311fd6fabc7a11f700f3dc177775 /src/interfaces/ecpg/compatlib/informix.c | |
parent | 80ac9b06acb20da700a86251d58b2eae1506b727 (diff) | |
download | postgresql-757fb0e5a9a61ac8d3a67e334faeea6dc0084b3f.tar.gz postgresql-757fb0e5a9a61ac8d3a67e334faeea6dc0084b3f.zip |
- Fixed Informix compat math functions to cope with the situations
where one argument takes the result.
- Applied thread patches by Lee Kindness
Diffstat (limited to 'src/interfaces/ecpg/compatlib/informix.c')
-rw-r--r-- | src/interfaces/ecpg/compatlib/informix.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index 5773c45abee..973d7a8547d 100644 --- a/src/interfaces/ecpg/compatlib/informix.c +++ b/src/interfaces/ecpg/compatlib/informix.c @@ -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) |