- Replaced double-quote-fix with a hopefully better version.
- Use initializer string length as size for character strings.
- Added ecpg_config.h file that is created via configure.
+
+Th 24. Aug 11:53:29 CEST 2006
+
+ - Fixed of by one variable size.
- Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1.
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.33 2006/08/08 11:51:24 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.34 2006/08/24 10:35:58 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
case ECPGt_unsigned_char:
if (pval)
{
- if (varcharsize == 0 || varcharsize > strlen(pval))
- strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval) + 1);
+ if (varcharsize == 0 || varcharsize > size)
+ strncpy((char *) ((long) var + offset * act_tuple), pval, size + 1);
else
{
strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
- if (varcharsize < strlen(pval))
+ if (varcharsize < size)
{
/* truncation */
switch (ind_type)
{
case ECPGt_short:
case ECPGt_unsigned_short:
- *((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ *((short *) (ind + ind_offset * act_tuple)) = size;
break;
case ECPGt_int:
case ECPGt_unsigned_int:
- *((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ *((int *) (ind + ind_offset * act_tuple)) = size;
break;
case ECPGt_long:
case ECPGt_unsigned_long:
- *((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ *((long *) (ind + ind_offset * act_tuple)) = size;
break;
#ifdef HAVE_LONG_LONG_INT_64
case ECPGt_long_long:
case ECPGt_unsigned_long_long:
- *((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ *((long long int *) (ind + ind_offset * act_tuple)) = size;
break;
#endif /* HAVE_LONG_LONG_INT_64 */
default:
sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
}
}
- pval += strlen(pval);
+ pval += size;
}
break;
struct ECPGgeneric_varchar *variable =
(struct ECPGgeneric_varchar *) ((long) var + offset * act_tuple);
- variable->len = strlen(pval);
+ variable->len = size;
if (varcharsize == 0)
strncpy(variable->arr, pval, variable->len);
else
variable->len = varcharsize;
}
}
- pval += strlen(pval);
+ pval += size;
}
break;
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.330 2006/08/23 12:01:52 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/preproc.y,v 1.331 2006/08/24 10:35:58 meskes Exp $ */
/* Copyright comment */
%{
/* if we have an initializer but no string size set, let's use the initializer's length */
free(length);
length = mm_alloc(i+sizeof("sizeof()"));
- sprintf(length, "sizeof(%s)+1", $5+2);
+ sprintf(length, "sizeof(%s)", $5+2);
}
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
}
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl ) values( 1 , ? , ? , ? , ? , ? , ? , ? ) ",
- ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
+ ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
rsetnull(CDTIMETYPE, (char *) &tmp);
{ ECPGdo(__LINE__, 1, 0, NULL, "insert into test ( id , c , s , i , b , f , l , dbl , dec , dat , tmp ) values( 2 , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ",
- ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
+ ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
printf("first select\n");
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 1 ", ECPGt_EOIT,
- ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
+ ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
printf("second select\n");
{ ECPGdo(__LINE__, 1, 0, NULL, "select c , s , i , b , f , l , dbl , dec , dat , tmp from test where id = 2 ", ECPGt_EOIT,
- ECPGt_char,(c),(long)sizeof("abc ")+1,(long)1,(sizeof("abc ")+1)*sizeof(char),
+ ECPGt_char,(c),(long)sizeof("abc "),(long)1,(sizeof("abc "))*sizeof(char),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_short,&(s),(long)1,(long)1,sizeof(short),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
{ ECPGget_desc(__LINE__, "outdesc", 1,ECPGd_data,
- ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char), ECPGd_EODT);
+ ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char), ECPGd_EODT);
#line 51 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c1", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int),
- ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
+ ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
ECPGt_int,&(ind2),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 57 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "fetch next from c2", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
+ ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 69 "desc.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, "select * from test1 where a = 3 ", ECPGt_EOIT,
ECPGt_int,&(val1output),(long)1,(long)1,sizeof(int),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
- ECPGt_char,(val2output),(long)sizeof("AAA")+1,(long)1,(sizeof("AAA")+1)*sizeof(char),
+ ECPGt_char,(val2output),(long)sizeof("AAA"),(long)1,(sizeof("AAA"))*sizeof(char),
ECPGt_int,&(val2i),(long)1,(long)1,sizeof(int), ECPGt_EORT);
#line 74 "desc.pgc"