-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.5 2003/06/15 04:07:58 momjian Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/data.c,v 1.6 2003/06/19 09:52:11 meskes Exp $ */
#define POSTGRES_ECPG_INTERNAL
#include "postgres_fe.h"
switch (type)
{
long res;
- unsigned long ures;
+ unsigned long ures;
double dres;
- char *scan_length;
- Numeric *nres;
- Date ddres;
+ char *scan_length;
+ Numeric *nres;
+ Date ddres;
Timestamp tres;
Interval *ires;
case ECPGt_char:
case ECPGt_unsigned_char:
{
- strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
- if (varcharsize && varcharsize < strlen(pval))
+ if (varcharsize == 0)
+ {
+ strncpy((char *) ((long) var + offset * act_tuple), pval, strlen(pval));
+ }
+ else
{
- /* truncation */
- switch (ind_type)
+ strncpy((char *) ((long) var + offset * act_tuple), pval, varcharsize);
+
+ if (varcharsize < strlen(pval))
{
- case ECPGt_short:
- case ECPGt_unsigned_short:
-/* ((short *) ind)[act_tuple] = strlen(pval);*/
- *((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
- break;
- case ECPGt_int:
- case ECPGt_unsigned_int:
-/* ((int *) ind)[act_tuple] = strlen(pval);*/
- *((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
- break;
- case ECPGt_long:
- case ECPGt_unsigned_long:
-/* ((long *) ind)[act_tuple] = strlen(pval);*/
- *((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
- break;
+ /* truncation */
+ switch (ind_type)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ /* ((short *) ind)[act_tuple] = strlen(pval);*/
+ *((short *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ /* ((int *) ind)[act_tuple] = strlen(pval);*/
+ *((int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ /* ((long *) ind)[act_tuple] = strlen(pval);*/
+ *((long *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ 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);
- break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ *((long long int *) (ind + ind_offset * act_tuple)) = strlen(pval);
+ break;
#endif /* HAVE_LONG_LONG_INT_64 */
- default:
- break;
+ default:
+ break;
+ }
+ sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
}
- sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
}
}
break;
variable->len = strlen(pval);
if (varcharsize == 0)
+ {
strncpy(variable->arr, pval, variable->len);
+ }
else
+ {
strncpy(variable->arr, pval, varcharsize);
- if (varcharsize > 0 && variable->len > varcharsize)
- {
- /* truncation */
- switch (ind_type)
+ if (variable->len > varcharsize)
{
- case ECPGt_short:
- case ECPGt_unsigned_short:
-/* ((short *) ind)[act_tuple] = variable->len;*/
- *((short *) (ind + offset * act_tuple)) = variable->len;
- break;
- case ECPGt_int:
- case ECPGt_unsigned_int:
-/* ((int *) ind)[act_tuple] = variable->len;*/
- *((int *) (ind + offset * act_tuple)) = variable->len;
- break;
- case ECPGt_long:
- case ECPGt_unsigned_long:
-/* ((long *) ind)[act_tuple] = variable->len;*/
- *((long *) (ind + offset * act_tuple)) = variable->len;
- break;
+ /* truncation */
+ switch (ind_type)
+ {
+ case ECPGt_short:
+ case ECPGt_unsigned_short:
+ /* ((short *) ind)[act_tuple] = variable->len;*/
+ *((short *) (ind + offset * act_tuple)) = variable->len;
+ break;
+ case ECPGt_int:
+ case ECPGt_unsigned_int:
+ /* ((int *) ind)[act_tuple] = variable->len;*/
+ *((int *) (ind + offset * act_tuple)) = variable->len;
+ break;
+ case ECPGt_long:
+ case ECPGt_unsigned_long:
+ /* ((long *) ind)[act_tuple] = variable->len;*/
+ *((long *) (ind + offset * act_tuple)) = variable->len;
+ break;
#ifdef HAVE_LONG_LONG_INT_64
- case ECPGt_long_long:
- case ECPGt_unsigned_long_long:
- *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
- break;
+ case ECPGt_long_long:
+ case ECPGt_unsigned_long_long:
+ *((long long int *) (ind + ind_offset * act_tuple)) = variable->len;
+ break;
#endif /* HAVE_LONG_LONG_INT_64 */
- default:
- break;
- }
- sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
+ default:
+ break;
+ }
+ sqlca->sqlwarn[0] = sqlca->sqlwarn[1] = 'W';
- variable->len = varcharsize;
+ variable->len = varcharsize;
+ }
}
}
break;
-/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.233 2003/06/17 07:28:22 meskes Exp $ */
+/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.234 2003/06/19 09:52:11 meskes Exp $ */
/* Copyright comment */
%{
$$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
break;
- /*case ECPGt_numeric:
- if (atoi(dimension) < 0)
- type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
- else
- type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
-
- if (atoi(dimension) < 0)
- $$ = cat_str(4, mm_strdup(actual_storage[struct_level]), make_str("Numeric"), mm_strdup($2), $4);
- else
- $$ = cat_str(5, mm_strdup(actual_storage[struct_level]), make_str("Numeric"), mm_strdup($2), mm_strdup(dim), $4);
- break;
-
- case ECPGt_interval:
- if (atoi(dimension) < 0)
- type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
- else
- type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
-
- if (atoi(dimension) < 0)
- $$ = cat_str(4, mm_strdup(actual_storage[struct_level]), make_str("Interval"), mm_strdup($2), $4);
- else
- $$ = cat_str(5, mm_strdup(actual_storage[struct_level]), make_str("Interval"), mm_strdup($2), mm_strdup(dim), $4);
- break;*/
-
default:
if (atoi(dimension) < 0)
type = ECPGmake_simple_type(actual_type[struct_level].type_enum, make_str("1"));