From: Michael Meskes Date: Sun, 14 Mar 2004 12:18:35 +0000 (+0000) Subject: Committed Informix compat bug fix to 7.4 as well. X-Git-Tag: REL7_4_3~66 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e6bc372174dff40993978f0388d5c9b5b9f96a66;p=postgresql Committed Informix compat bug fix to 7.4 as well. --- diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile index 2150c829d0..d1cd03a7b0 100644 --- a/src/interfaces/ecpg/compatlib/Makefile +++ b/src/interfaces/ecpg/compatlib/Makefile @@ -4,7 +4,7 @@ # # Copyright (c) 1994, Regents of the University of California # -# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.11.2.2 2004/02/10 07:26:48 tgl Exp $ +# $PostgreSQL: pgsql/src/interfaces/ecpg/compatlib/Makefile,v 1.11.2.3 2004/03/14 12:18:35 meskes Exp $ # #------------------------------------------------------------------------- @@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global NAME= ecpg_compat SO_MAJOR_VERSION= 1 -SO_MINOR_VERSION= 1 +SO_MINOR_VERSION= 2 override CPPFLAGS := -I$(top_srcdir)/src/interfaces/ecpg/include -I$(libpq_srcdir) -I$(top_srcdir)/src/include/utils $(CPPFLAGS) $(THREAD_CPPFLAGS) SHLIB_LINK = -L../ecpglib -lecpg -L../pgtypeslib -lpgtypes $(libpq) \ diff --git a/src/interfaces/ecpg/compatlib/informix.c b/src/interfaces/ecpg/compatlib/informix.c index 5773c45abe..973d7a8547 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)