commit 58144950a0dbca652aa50d3363962e9dafd3182b
Author: Böszörményi Zoltán <zboszor@pr.hu>
Date:   Wed Apr 16 10:01:36 2014 +0200

    ECPG: Decouple the tuple index from the array index in
    ecpg_get_data(). Document the function arguments.

diff --git a/src/interfaces/ecpg/ecpglib/data.c b/src/interfaces/ecpg/ecpglib/data.c
index 5f9a3d4..7f3c7cb 100644
--- a/src/interfaces/ecpg/ecpglib/data.c
+++ b/src/interfaces/ecpg/ecpglib/data.c
@@ -112,22 +112,49 @@ check_special_value(char *ptr, double *retval, char **endptr)
 	else if (pg_strncasecmp(ptr, "-Infinity", 9) == 0)
 	{
 		*retval = -get_float8_infinity();
 		*endptr = ptr + 9;
 		return true;
 	}
 
 	return false;
 }
 
+/*
+ * ecpg_get_data
+ *   Store one field data from PQgetvalue(results, act_tuple, act_field)
+ *   into a target variable. If the field is NULL, store the indication or
+ *   emit an error about the fact that there is no NULL indicator given.
+ * Parameters:
+ *   results:     result set
+ *   act_tuple:   row index in the result set
+ *   act_field:   column index in the result set
+ *   var_index:   array index in the target variable
+ *   lineno:      line number in the ECPG source file for debugging
+ *   type:        type of target variable
+ *   ind_type:    type of NULL indicator variable
+ *   var:         target variable
+ *   ind:         NULL indicator variable
+ *   varcharsize: size of the variable if it's varchar
+ *   offset:      size of the target variable
+ *                (used for indexing in an array)
+ *   ind_offset:  size of the NULL indicator variable
+ *                (used for indexing in an array)
+ *   isarray:     array type
+ *   compat:      native PostgreSQL or Informix compatibility mode
+ *   force_indicator:
+ *                if Informix compatibility mode is set and no NULL indicator
+ *                is given, provide a way to indicate NULL value in the
+ *                target variable itself
+ */
 bool
-ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
+ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int var_index, int lineno,
 			  enum ECPGttype type, enum ECPGttype ind_type,
 			  char *var, char *ind, long varcharsize, long offset,
 			  long ind_offset, enum ARRAY_TYPE isarray, enum COMPAT_MODE compat, bool force_indicator)
 {
 	struct sqlca_t *sqlca = ECPGget_sqlca();
 	char	   *pval = (char *) PQgetvalue(results, act_tuple, act_field);
 	int			binary = PQfformat(results, act_field);
 	int			size = PQgetlength(results, act_tuple, act_field);
 	int			value_for_indicator = 0;
 	long		log_offset;
@@ -160,46 +187,46 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 	 * check for null value and set indicator accordingly, i.e. -1 if NULL and
 	 * 0 if not
 	 */
 	if (PQgetisnull(results, act_tuple, act_field))
 		value_for_indicator = -1;
 
 	switch (ind_type)
 	{
 		case ECPGt_short:
 		case ECPGt_unsigned_short:
-			*((short *) (ind + ind_offset * act_tuple)) = value_for_indicator;
+			*((short *) (ind + ind_offset * var_index)) = value_for_indicator;
 			break;
 		case ECPGt_int:
 		case ECPGt_unsigned_int:
-			*((int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
+			*((int *) (ind + ind_offset * var_index)) = value_for_indicator;
 			break;
 		case ECPGt_long:
 		case ECPGt_unsigned_long:
-			*((long *) (ind + ind_offset * act_tuple)) = value_for_indicator;
+			*((long *) (ind + ind_offset * var_index)) = value_for_indicator;
 			break;
 #ifdef HAVE_LONG_LONG_INT
 		case ECPGt_long_long:
 		case ECPGt_unsigned_long_long:
-			*((long long int *) (ind + ind_offset * act_tuple)) = value_for_indicator;
+			*((long long int *) (ind + ind_offset * var_index)) = value_for_indicator;
 			break;
 #endif   /* HAVE_LONG_LONG_INT */
 		case ECPGt_NO_INDICATOR:
 			if (value_for_indicator == -1)
 			{
 				if (force_indicator == false)
 				{
 					/*
 					 * Informix has an additional way to specify NULLs note
 					 * that this uses special values to denote NULL
 					 */
-					ECPGset_noind_null(type, var + offset * act_tuple);
+					ECPGset_noind_null(type, var + offset * var_index);
 				}
 				else
 				{
 					ecpg_raise(lineno, ECPG_MISSING_INDICATOR,
 							 ECPG_SQLSTATE_NULL_VALUE_NO_INDICATOR_PARAMETER,
 							   NULL);
 					return (false);
 				}
 			}
 			break;
@@ -236,46 +263,46 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 				pval++;
 				break;
 		}
 	}
 
 	do
 	{
 		if (binary)
 		{
 			if (varcharsize == 0 || varcharsize * offset >= size)
-				memcpy(var + offset * act_tuple, pval, size);
+				memcpy(var + offset * var_index, pval, size);
 			else
 			{
-				memcpy(var + offset * act_tuple, pval, varcharsize * offset);
+				memcpy(var + offset * var_index, pval, varcharsize * offset);
 
 				if (varcharsize * offset < size)
 				{
 					/* truncation */
 					switch (ind_type)
 					{
 						case ECPGt_short:
 						case ECPGt_unsigned_short:
-							*((short *) (ind + ind_offset * act_tuple)) = size;
+							*((short *) (ind + ind_offset * var_index)) = size;
 							break;
 						case ECPGt_int:
 						case ECPGt_unsigned_int:
-							*((int *) (ind + ind_offset * act_tuple)) = size;
+							*((int *) (ind + ind_offset * var_index)) = size;
 							break;
 						case ECPGt_long:
 						case ECPGt_unsigned_long:
-							*((long *) (ind + ind_offset * act_tuple)) = size;
+							*((long *) (ind + ind_offset * var_index)) = size;
 							break;
 #ifdef HAVE_LONG_LONG_INT
 						case ECPGt_long_long:
 						case ECPGt_unsigned_long_long:
-							*((long long int *) (ind + ind_offset * act_tuple)) = size;
+							*((long long int *) (ind + ind_offset * var_index)) = size;
 							break;
 #endif   /* HAVE_LONG_LONG_INT */
 						default:
 							break;
 					}
 					sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
 				}
 			}
 			pval += size;
 		}
@@ -300,27 +327,27 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 					{
 						ecpg_raise(lineno, ECPG_INT_FORMAT,
 								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 						return (false);
 					}
 					pval = scan_length;
 
 					switch (type)
 					{
 						case ECPGt_short:
-							*((short *) (var + offset * act_tuple)) = (short) res;
+							*((short *) (var + offset * var_index)) = (short) res;
 							break;
 						case ECPGt_int:
-							*((int *) (var + offset * act_tuple)) = (int) res;
+							*((int *) (var + offset * var_index)) = (int) res;
 							break;
 						case ECPGt_long:
-							*((long *) (var + offset * act_tuple)) = (long) res;
+							*((long *) (var + offset * var_index)) = (long) res;
 							break;
 						default:
 							/* Cannot happen */
 							break;
 					}
 					break;
 
 				case ECPGt_unsigned_short:
 				case ECPGt_unsigned_int:
 				case ECPGt_unsigned_long:
@@ -329,50 +356,50 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 					{
 						ecpg_raise(lineno, ECPG_UINT_FORMAT,
 								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 						return (false);
 					}
 					pval = scan_length;
 
 					switch (type)
 					{
 						case ECPGt_unsigned_short:
-							*((unsigned short *) (var + offset * act_tuple)) = (unsigned short) ures;
+							*((unsigned short *) (var + offset * var_index)) = (unsigned short) ures;
 							break;
 						case ECPGt_unsigned_int:
-							*((unsigned int *) (var + offset * act_tuple)) = (unsigned int) ures;
+							*((unsigned int *) (var + offset * var_index)) = (unsigned int) ures;
 							break;
 						case ECPGt_unsigned_long:
-							*((unsigned long *) (var + offset * act_tuple)) = (unsigned long) ures;
+							*((unsigned long *) (var + offset * var_index)) = (unsigned long) ures;
 							break;
 						default:
 							/* Cannot happen */
 							break;
 					}
 					break;
 
 #ifdef HAVE_LONG_LONG_INT
 #ifdef HAVE_STRTOLL
 				case ECPGt_long_long:
-					*((long long int *) (var + offset * act_tuple)) = strtoll(pval, &scan_length, 10);
+					*((long long int *) (var + offset * var_index)) = strtoll(pval, &scan_length, 10);
 					if (garbage_left(isarray, scan_length, compat))
 					{
 						ecpg_raise(lineno, ECPG_INT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 						return (false);
 					}
 					pval = scan_length;
 
 					break;
 #endif   /* HAVE_STRTOLL */
 #ifdef HAVE_STRTOULL
 				case ECPGt_unsigned_long_long:
-					*((unsigned long long int *) (var + offset * act_tuple)) = strtoull(pval, &scan_length, 10);
+					*((unsigned long long int *) (var + offset * var_index)) = strtoull(pval, &scan_length, 10);
 					if ((isarray && *scan_length != ',' && *scan_length != '}')
 						|| (!isarray && !(INFORMIX_MODE(compat) && *scan_length == '.') && *scan_length != '\0' && *scan_length != ' '))		/* Garbage left */
 					{
 						ecpg_raise(lineno, ECPG_UINT_FORMAT, ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 						return (false);
 					}
 					pval = scan_length;
 
 					break;
 #endif   /* HAVE_STRTOULL */
@@ -393,51 +420,51 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 					{
 						ecpg_raise(lineno, ECPG_FLOAT_FORMAT,
 								   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 						return (false);
 					}
 					pval = scan_length;
 
 					switch (type)
 					{
 						case ECPGt_float:
-							*((float *) (var + offset * act_tuple)) = dres;
+							*((float *) (var + offset * var_index)) = dres;
 							break;
 						case ECPGt_double:
-							*((double *) (var + offset * act_tuple)) = dres;
+							*((double *) (var + offset * var_index)) = dres;
 							break;
 						default:
 							/* Cannot happen */
 							break;
 					}
 					break;
 
 				case ECPGt_bool:
 					if (pval[0] == 'f' && pval[1] == '\0')
 					{
 						if (offset == sizeof(char))
-							*((char *) (var + offset * act_tuple)) = false;
+							*((char *) (var + offset * var_index)) = false;
 						else if (offset == sizeof(int))
-							*((int *) (var + offset * act_tuple)) = false;
+							*((int *) (var + offset * var_index)) = false;
 						else
 							ecpg_raise(lineno, ECPG_CONVERT_BOOL,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH,
 									   NULL);
 						pval++;
 						break;
 					}
 					else if (pval[0] == 't' && pval[1] == '\0')
 					{
 						if (offset == sizeof(char))
-							*((char *) (var + offset * act_tuple)) = true;
+							*((char *) (var + offset * var_index)) = true;
 						else if (offset == sizeof(int))
-							*((int *) (var + offset * act_tuple)) = true;
+							*((int *) (var + offset * var_index)) = true;
 						else
 							ecpg_raise(lineno, ECPG_CONVERT_BOOL,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH,
 									   NULL);
 						pval++;
 						break;
 					}
 					else if (pval[0] == '\0' && PQgetisnull(results, act_tuple, act_field))
 					{
 						/* NULL is valid */
@@ -446,21 +473,21 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 
 					ecpg_raise(lineno, ECPG_CONVERT_BOOL,
 							   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 					return (false);
 					break;
 
 				case ECPGt_char:
 				case ECPGt_unsigned_char:
 				case ECPGt_string:
 					{
-						char	   *str = (char *) (var + offset * act_tuple);
+						char	   *str = (char *) (var + offset * var_index);
 
 						if (varcharsize == 0 || varcharsize > size)
 						{
 							strncpy(str, pval, size + 1);
 							/* do the rtrim() */
 							if (type == ECPGt_string)
 							{
 								char	   *last = str + size;
 
 								while (last > str && (*last == ' ' || *last == '\0'))
@@ -474,79 +501,79 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 						{
 							strncpy(str, pval, varcharsize);
 
 							if (varcharsize < size)
 							{
 								/* truncation */
 								switch (ind_type)
 								{
 									case ECPGt_short:
 									case ECPGt_unsigned_short:
-										*((short *) (ind + ind_offset * act_tuple)) = size;
+										*((short *) (ind + ind_offset * var_index)) = size;
 										break;
 									case ECPGt_int:
 									case ECPGt_unsigned_int:
-										*((int *) (ind + ind_offset * act_tuple)) = size;
+										*((int *) (ind + ind_offset * var_index)) = size;
 										break;
 									case ECPGt_long:
 									case ECPGt_unsigned_long:
-										*((long *) (ind + ind_offset * act_tuple)) = size;
+										*((long *) (ind + ind_offset * var_index)) = size;
 										break;
 #ifdef HAVE_LONG_LONG_INT
 									case ECPGt_long_long:
 									case ECPGt_unsigned_long_long:
-										*((long long int *) (ind + ind_offset * act_tuple)) = size;
+										*((long long int *) (ind + ind_offset * var_index)) = size;
 										break;
 #endif   /* HAVE_LONG_LONG_INT */
 									default:
 										break;
 								}
 								sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
 							}
 						}
 						pval += size;
 					}
 					break;
 
 				case ECPGt_varchar:
 					{
 						struct ECPGgeneric_varchar *variable =
-						(struct ECPGgeneric_varchar *) (var + offset * act_tuple);
+						(struct ECPGgeneric_varchar *) (var + offset * var_index);
 
 						variable->len = size;
 						if (varcharsize == 0)
 							strncpy(variable->arr, pval, variable->len);
 						else
 						{
 							strncpy(variable->arr, pval, varcharsize);
 
 							if (variable->len > varcharsize)
 							{
 								/* truncation */
 								switch (ind_type)
 								{
 									case ECPGt_short:
 									case ECPGt_unsigned_short:
-										*((short *) (ind + ind_offset * act_tuple)) = variable->len;
+										*((short *) (ind + ind_offset * var_index)) = variable->len;
 										break;
 									case ECPGt_int:
 									case ECPGt_unsigned_int:
-										*((int *) (ind + ind_offset * act_tuple)) = variable->len;
+										*((int *) (ind + ind_offset * var_index)) = variable->len;
 										break;
 									case ECPGt_long:
 									case ECPGt_unsigned_long:
-										*((long *) (ind + ind_offset * act_tuple)) = variable->len;
+										*((long *) (ind + ind_offset * var_index)) = variable->len;
 										break;
 #ifdef HAVE_LONG_LONG_INT
 									case ECPGt_long_long:
 									case ECPGt_unsigned_long_long:
-										*((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
+										*((long long int *) (ind + ind_offset * var_index)) = variable->len;
 										break;
 #endif   /* HAVE_LONG_LONG_INT */
 									default:
 										break;
 								}
 								sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
 
 								variable->len = varcharsize;
 							}
 						}
@@ -599,23 +626,23 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 						{
 							free(nres);
 							ecpg_raise(lineno, ECPG_NUMERIC_FORMAT,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 							return (false);
 						}
 					}
 					pval = scan_length;
 
 					if (type == ECPGt_numeric)
-						PGTYPESnumeric_copy(nres, (numeric *) (var + offset * act_tuple));
+						PGTYPESnumeric_copy(nres, (numeric *) (var + offset * var_index));
 					else
-						PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
+						PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * var_index));
 
 					PGTYPESnumeric_free(nres);
 					break;
 
 				case ECPGt_interval:
 					if (isarray && *pval == '"')
 						ires = PGTYPESinterval_from_asc(pval + 1, &scan_length);
 					else
 						ires = PGTYPESinterval_from_asc(pval, &scan_length);
 
@@ -652,21 +679,21 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 						if (garbage_left(isarray, scan_length, compat))
 						{
 							free(ires);
 							ecpg_raise(lineno, ECPG_INTERVAL_FORMAT,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 							return (false);
 						}
 					}
 					pval = scan_length;
 
-					PGTYPESinterval_copy(ires, (interval *) (var + offset * act_tuple));
+					PGTYPESinterval_copy(ires, (interval *) (var + offset * var_index));
 					free(ires);
 					break;
 
 				case ECPGt_date:
 					if (isarray && *pval == '"')
 						ddres = PGTYPESdate_from_asc(pval + 1, &scan_length);
 					else
 						ddres = PGTYPESdate_from_asc(pval, &scan_length);
 
 					/* did we get an error? */
@@ -696,21 +723,21 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 							scan_length++;
 
 						if (garbage_left(isarray, scan_length, compat))
 						{
 							ecpg_raise(lineno, ECPG_DATE_FORMAT,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 							return (false);
 						}
 					}
 
-					*((date *) (var + offset * act_tuple)) = ddres;
+					*((date *) (var + offset * var_index)) = ddres;
 					pval = scan_length;
 					break;
 
 				case ECPGt_timestamp:
 					if (isarray && *pval == '"')
 						tres = PGTYPEStimestamp_from_asc(pval + 1, &scan_length);
 					else
 						tres = PGTYPEStimestamp_from_asc(pval, &scan_length);
 
 					/* did we get an error? */
@@ -740,37 +767,38 @@ ecpg_get_data(const PGresult *results, int act_tuple, int act_field, int lineno,
 							scan_length++;
 
 						if (garbage_left(isarray, scan_length, compat))
 						{
 							ecpg_raise(lineno, ECPG_TIMESTAMP_FORMAT,
 									   ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
 							return (false);
 						}
 					}
 
-					*((timestamp *) (var + offset * act_tuple)) = tres;
+					*((timestamp *) (var + offset * var_index)) = tres;
 					pval = scan_length;
 					break;
 
 				default:
 					ecpg_raise(lineno, ECPG_UNSUPPORTED,
 							   ECPG_SQLSTATE_ECPG_INTERNAL_ERROR,
 							   ecpg_type_name(type));
 					return (false);
 					break;
 			}
 			if (ECPG_IS_ARRAY(isarray))
 			{
 				bool		string = false;
 
 				/* set array to next entry */
 				++act_tuple;
+				++var_index;
 
 				/* set pval to the next entry */
 
 				/*
 				 * *pval != '\0' should not be needed, but is used as a safety
 				 * guard
 				 */
 				for (; *pval != '\0' && (string || (!array_delimiter(isarray, *pval) && !array_boundary(isarray, *pval))); ++pval)
 					if (*pval == '"')
 						string = string ? false : true;
diff --git a/src/interfaces/ecpg/ecpglib/execute.c b/src/interfaces/ecpg/ecpglib/execute.c
index a90fb41..af57521 100644
--- a/src/interfaces/ecpg/ecpglib/execute.c
+++ b/src/interfaces/ecpg/ecpglib/execute.c
@@ -426,40 +426,40 @@ ecpg_store_result(const PGresult *results, int act_field,
 		/* filling the array of (char*)s */
 		char	  **current_string = (char **) var->value;
 
 		/* storing the data (after the last array element) */
 		char	   *current_data_location = (char *) &current_string[ntuples + 1];
 
 		for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
 		{
 			int			len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
 
-			if (!ecpg_get_data(results, act_tuple, act_field, stmt->lineno,
+			if (!ecpg_get_data(results, act_tuple, act_field, act_tuple, stmt->lineno,
 							 var->type, var->ind_type, current_data_location,
 							   var->ind_value, len, 0, var->ind_offset, isarray, stmt->compat, stmt->force_indicator))
 				status = false;
 			else
 			{
 				*current_string = current_data_location;
 				current_data_location += len;
 				current_string++;
 			}
 		}
 
 		/* terminate the list */
 		*current_string = NULL;
 	}
 	else
 	{
 		for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
 		{
-			if (!ecpg_get_data(results, act_tuple, act_field, stmt->lineno,
+			if (!ecpg_get_data(results, act_tuple, act_field, act_tuple, stmt->lineno,
 							   var->type, var->ind_type, var->value,
 							   var->ind_value, var->varcharsize, var->offset, var->ind_offset, isarray, stmt->compat, stmt->force_indicator))
 				status = false;
 		}
 	}
 	return status;
 }
 
 static void
 sprintf_double_value(char *ptr, double value, const char *delim)
diff --git a/src/interfaces/ecpg/ecpglib/extern.h b/src/interfaces/ecpg/ecpglib/extern.h
index 1f96869..f91867c 100644
--- a/src/interfaces/ecpg/ecpglib/extern.h
+++ b/src/interfaces/ecpg/ecpglib/extern.h
@@ -132,21 +132,21 @@ struct var_list
 	struct var_list *next;
 };
 
 extern struct var_list *ivlist;
 
 /* Here are some methods used by the lib. */
 
 /* Returns a pointer to a string containing a simple type name. */
 void		ecpg_add_mem(void *ptr, int lineno);
 
-bool ecpg_get_data(const PGresult *, int, int, int, enum ECPGttype type,
+bool ecpg_get_data(const PGresult *, int, int, int, int, enum ECPGttype type,
 			  enum ECPGttype, char *, char *, long, long, long,
 			  enum ARRAY_TYPE, enum COMPAT_MODE, bool);
 
 #ifdef ENABLE_THREAD_SAFETY
 void		ecpg_pthreads_init(void);
 #endif
 struct connection *ecpg_get_connection(const char *);
 char	   *ecpg_alloc(long, int);
 char	   *ecpg_realloc(void *, long, int);
 void		ecpg_free(void *);
diff --git a/src/interfaces/ecpg/ecpglib/sqlda.c b/src/interfaces/ecpg/ecpglib/sqlda.c
index bc94f2f..9985a6c 100644
--- a/src/interfaces/ecpg/ecpglib/sqlda.c
+++ b/src/interfaces/ecpg/ecpglib/sqlda.c
@@ -386,21 +386,21 @@ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat ** _sqlda, const PGresult
 		}
 
 		isnull = PQgetisnull(res, row, i);
 		ecpg_log("ecpg_set_compat_sqlda on line %d row %d col %d %s\n", lineno, row, i, isnull ? "IS NULL" : "IS NOT NULL");
 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
 		sqlda->sqlvar[i].sqlilen = sizeof(short);
 		if (!isnull)
 		{
 			if (set_data)
-				ecpg_get_data(res, row, i, lineno,
+				ecpg_get_data(res, row, i, 0, lineno,
 							  sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
 							  sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
 							  ECPG_ARRAY_NONE, compat, false);
 		}
 		else
 			ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
 
 		offset = next_offset;
 	}
 }
@@ -571,19 +571,19 @@ ecpg_set_native_sqlda(int lineno, struct sqlda_struct ** _sqlda, const PGresult
 				sqlda->sqlvar[i].sqllen = datalen;
 				break;
 		}
 
 		isnull = PQgetisnull(res, row, i);
 		ecpg_log("ecpg_set_native_sqlda on line %d row %d col %d %s\n", lineno, row, i, isnull ? "IS NULL" : "IS NOT NULL");
 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
 		if (!isnull)
 		{
 			if (set_data)
-				ecpg_get_data(res, row, i, lineno,
+				ecpg_get_data(res, row, i, 0, lineno,
 							  sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
 							  sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
 							  ECPG_ARRAY_NONE, compat, false);
 		}
 
 		offset = next_offset;
 	}
 }
