commit b49862a400e0573294a72409abf88d177e1e10d8
Author: Böszörményi Zoltán <zboszor@pr.hu>
Date:   Wed Apr 16 10:07:28 2014 +0200

    ECPG: Use the more descriptive "act_tuple" variable name instead of "i".
    Use the variables declared for the function scope, don't alias them.

diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index 85ef44f..ef5824a 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -1535,20 +1535,21 @@ ecpg_execute(struct statement * stmt)
 bool
 ecpg_process_output(struct statement * stmt, int start, int ntuples, int direction, int var_index, bool clear_result, bool append_result)
 {
 	struct variable *var;
 	bool		status = false;
 	char	   *cmdstat;
 	PGnotify   *notify;
 	struct sqlca_t *sqlca = ECPGget_sqlca();
 	int			nfields,
 				tuples_left,
+				act_tuple,
 				act_field;
 
 	var = stmt->outlist;
 	switch (PQresultStatus(stmt->results))
 	{
 		case PGRES_TUPLES_OK:
 			nfields = PQnfields(stmt->results);
 			sqlca->sqlerrd[2] = ntuples;
 
 			ecpg_log("ecpg_process_output on line %d: correctly got %d tuples with %d fields\n", stmt->lineno, ntuples, nfields);
@@ -1567,31 +1568,30 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 			if (var != NULL && var->type == ECPGt_descriptor)
 			{
 				struct descriptor *desc = ecpg_find_desc(stmt->lineno, var->pointer);
 
 				if (desc == NULL)
 					status = false;
 				else
 				{
 					if (append_result && desc->result)
 					{
-						int		act_tuple, col,
-								row = PQntuples(desc->result);
+						int		row = PQntuples(desc->result);
 
 						for (tuples_left = ntuples, act_tuple = start; tuples_left; tuples_left--, act_tuple += direction, row++)
-							for (col = 0; col < nfields; col++)
+							for (act_field = 0; act_field < nfields; act_field++)
 							{
-								bool	isnull = PQgetisnull(stmt->results, act_tuple, col);
+								bool	isnull = PQgetisnull(stmt->results, act_tuple, act_field);
 
-								if (!PQsetvalue(desc->result, row, col,
-										isnull ? NULL : PQgetvalue(stmt->results, act_tuple, col),
-										isnull ? -1 : PQgetlength(stmt->results, act_tuple, col)))
+								if (!PQsetvalue(desc->result, row, act_field,
+										isnull ? NULL : PQgetvalue(stmt->results, act_tuple, act_field),
+										isnull ? -1 : PQgetlength(stmt->results, act_tuple, act_field)))
 								{
 									ecpg_raise(stmt->lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL);
 									status = false;
 									break;
 								}
 							}
 					}
 					else
 					{
 						if (desc->result)
@@ -1605,21 +1605,20 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 				var = var->next;
 			}
 			else if (var != NULL && var->type == ECPGt_sqlda)
 			{
 				if (INFORMIX_MODE(stmt->compat))
 				{
 					struct sqlda_compat **_sqlda = (struct sqlda_compat **) var->pointer;
 					struct sqlda_compat *sqlda = *_sqlda;
 					struct sqlda_compat *sqlda_last;
 					struct sqlda_compat *sqlda_new;
-					int			i;
 
 					if (append_result)
 					{
 						sqlda_last = sqlda;
 						while (sqlda_last && sqlda_last->desc_next)
 							sqlda_last = sqlda_last->desc_next;
 					}
 					else
 					{
 						/*
@@ -1627,27 +1626,27 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 						 * then free it.
 						 */
 						while (sqlda)
 						{
 							sqlda_new = sqlda->desc_next;
 							free(sqlda);
 							sqlda = sqlda_new;
 						}
 						*_sqlda = sqlda = sqlda_last = NULL;
 					}
-					for (i = start; ntuples; ntuples--, i += direction)
+					for (tuples_left = ntuples, act_tuple = start; tuples_left; tuples_left--, act_tuple += direction)
 					{
 						/*
 						 * Build a new sqlda structure. Note that only
 						 * fetching 1 record is supported
 						 */
-						sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, stmt->results, i, stmt->compat);
+						sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, stmt->results, act_tuple, stmt->compat);
 
 						if (!sqlda_new)
 						{
 							/* cleanup all SQLDAs we created up */
 							while (sqlda)
 							{
 								sqlda_new = sqlda->desc_next;
 								free(sqlda);
 								sqlda = sqlda_new;
 							}
@@ -1664,33 +1663,32 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 							if (sqlda_last)
 							{
 								sqlda_last->desc_next = sqlda_new;
 								sqlda_last = sqlda_new;
 							}
 							else
 							{
 								*_sqlda = sqlda = sqlda_last = sqlda_new;
 							}
 
-							ecpg_set_compat_sqlda(stmt->lineno, &sqlda_new, stmt->results, i, stmt->compat);
+							ecpg_set_compat_sqlda(stmt->lineno, &sqlda_new, stmt->results, act_tuple, stmt->compat);
 							ecpg_log("ecpg_process_output on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
 									 stmt->lineno, PQnfields(stmt->results));
 						}
 					}
 				}
 				else
 				{
 					struct sqlda_struct **_sqlda = (struct sqlda_struct **) var->pointer;
 					struct sqlda_struct *sqlda = *_sqlda;
 					struct sqlda_struct *sqlda_last;
 					struct sqlda_struct *sqlda_new;
-					int			i;
 
 					if (append_result)
 					{
 						sqlda_last = sqlda;
 						while (sqlda_last && sqlda_last->desc_next)
 							sqlda_last = sqlda_last->desc_next;
 					}
 					else
 					{
 						/*
@@ -1698,27 +1696,27 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 						 * then free it.
 						 */
 						while (sqlda)
 						{
 							sqlda_new = sqlda->desc_next;
 							free(sqlda);
 							sqlda = sqlda_new;
 						}
 						*_sqlda = sqlda = sqlda_last = NULL;
 					}
-					for (i = start; ntuples; ntuples--, i += direction)
+					for (tuples_left = ntuples, act_tuple = start; tuples_left; tuples_left--, act_tuple += direction)
 					{
 						/*
 						 * Build a new sqlda structure. Note that only
 						 * fetching 1 record is supported
 						 */
-						sqlda_new = ecpg_build_native_sqlda(stmt->lineno, stmt->results, i, stmt->compat);
+						sqlda_new = ecpg_build_native_sqlda(stmt->lineno, stmt->results, act_tuple, stmt->compat);
 
 						if (!sqlda_new)
 						{
 							/* cleanup all SQLDAs we created up */
 							while (sqlda)
 							{
 								sqlda_new = sqlda->desc_next;
 								free(sqlda);
 								sqlda = sqlda_new;
 							}
@@ -1735,21 +1733,21 @@ ecpg_process_output(struct statement * stmt, int start, int ntuples, int directi
 							if (sqlda_last)
 							{
 								sqlda_last->desc_next = sqlda_new;
 								sqlda_last = sqlda_new;
 							}
 							else
 							{
 								*_sqlda = sqlda = sqlda_last = sqlda_new;
 							}
 
-							ecpg_set_native_sqlda(stmt->lineno, &sqlda_new, stmt->results, i, stmt->compat);
+							ecpg_set_native_sqlda(stmt->lineno, &sqlda_new, stmt->results, act_tuple, stmt->compat);
 							ecpg_log("ecpg_process_output on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
 									 stmt->lineno, PQnfields(stmt->results));
 						}
 					}
 				}
 
 				var = var->next;
 			}
 			else
 				for (act_field = 0; act_field < nfields && status; act_field++)
