09.patch

text/x-patch

Filename: 09.patch
Type: text/x-patch
Part: 0
Message: Re: Review: ECPG infrastructure changes part 1, was: Re: ECPG fixes

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/interfaces/ecpg/ecpglib/execute.c 4 7
commit 05bcbb115157ce065276c5baf689ca5011311fc6
Author: Böszörményi Zoltán <zb@cybertec.at>
Date:   Fri Dec 6 12:20:16 2013 +0100

    ECPG: Move allocating struct statement earlier in ECPGdo()

diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index e5ee8a9..83acaf4 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1720,6 +1720,9 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
 		return (false);
 	}
 
+	if (!(stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno)))
+		return false;
+
 	/* Make sure we do NOT honor the locale for numeric input/output */
 	/* since the database wants the standard decimal point */
 	oldlocale = ecpg_strdup(setlocale(LC_NUMERIC, NULL), lineno);
@@ -1735,6 +1738,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
 	{
 		setlocale(LC_NUMERIC, oldlocale);
 		ecpg_free(oldlocale);
+		free_statement(stmt);
 		return (false);
 	}
 
@@ -1753,13 +1757,6 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
 	 * - pointer to indicator variable ind_varcharsize - empty ind_arraysize -
 	 * arraysize of indicator array ind_offset - indicator offset
 	 */
-	if (!(stmt = (struct statement *) ecpg_alloc(sizeof(struct statement), lineno)))
-	{
-		setlocale(LC_NUMERIC, oldlocale);
-		ecpg_free(oldlocale);
-		va_end(args);
-		return false;
-	}
 
 	/*
 	 * If statement type is ECPGst_prepnormal we are supposed to prepare the