*** empty log message ***
This commit is contained in:
parent
9db6b7f3f7
commit
03842eb03b
@ -113,7 +113,7 @@ register_error(long code, char *fmt,...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
|
sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
|
||||||
|
|
||||||
/* free all memory we allocate for the user */
|
/* free all memory we have allocated for the user */
|
||||||
for (am = auto_allocs; am;)
|
for (am = auto_allocs; am;)
|
||||||
{
|
{
|
||||||
struct auto_mem *act = am;
|
struct auto_mem *act = am;
|
||||||
@ -178,7 +178,7 @@ ECPGfinish(struct connection * act)
|
|||||||
static char *
|
static char *
|
||||||
ecpg_alloc(long size, int lineno)
|
ecpg_alloc(long size, int lineno)
|
||||||
{
|
{
|
||||||
char *new = (char *) malloc(size);
|
char *new = (char *) calloc(1L, size);
|
||||||
|
|
||||||
if (!new)
|
if (!new)
|
||||||
{
|
{
|
||||||
@ -710,6 +710,8 @@ ECPGexecute(struct statement * stmt)
|
|||||||
*/
|
*/
|
||||||
if (var->arrsize == 0 || var->varcharsize == 0)
|
if (var->arrsize == 0 || var->varcharsize == 0)
|
||||||
{
|
{
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
switch(var->type)
|
switch(var->type)
|
||||||
{
|
{
|
||||||
case ECPGt_char:
|
case ECPGt_char:
|
||||||
@ -720,38 +722,26 @@ ECPGexecute(struct statement * stmt)
|
|||||||
/* check strlen for each tuple */
|
/* check strlen for each tuple */
|
||||||
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
|
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
|
||||||
{
|
{
|
||||||
int len = strlen(PQgetvalue(results, act_tuple, act_field));
|
int len = strlen(PQgetvalue(results, act_tuple, act_field)) + 1;
|
||||||
|
|
||||||
if (len > var->varcharsize)
|
if (len > var->varcharsize)
|
||||||
var->varcharsize = len;
|
var->varcharsize = len;
|
||||||
}
|
}
|
||||||
var->offset *= var->varcharsize;
|
var->offset *= var->varcharsize;
|
||||||
add_mem((void *)(var->value) = *((void **)(var->pointer)) = (void *) ecpg_alloc(var->offset * ntuples, stmt->lineno), stmt->lineno);
|
len = var->offset * ntuples;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#if 0
|
|
||||||
case ECPGt_varchar:
|
case ECPGt_varchar:
|
||||||
if (((struct ECPGgeneric_varchar *)var->value)->arr == NULL)
|
if (var->value == NULL)
|
||||||
{
|
len = ntuples * (var->varcharsize + sizeof (int));
|
||||||
var->varcharsize = 0;
|
|
||||||
/* check strlen for each tuple */
|
|
||||||
for (act_tuple = 0; act_tuple < ntuples; act_tuple++)
|
|
||||||
{
|
|
||||||
int len = strlen(PQgetvalue(results, act_tuple, act_field));
|
|
||||||
|
|
||||||
if (len > var->varcharsize)
|
|
||||||
var->varcharsize = len;
|
|
||||||
|
|
||||||
((struct ECPGgeneric_varchar *) ((long) var->value + var->offset * act_tuple))->arr = (char *) ecpg_alloc(len, stmt->lineno);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
if (var->value == NULL)
|
if (var->value == NULL)
|
||||||
add_mem((void *)(var->value) = *((void **)(var->pointer)) = (void *) ecpg_alloc(var->offset * ntuples, stmt->lineno), stmt->lineno);
|
len = var->offset * ntuples;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_mem((void *)(var->value) = *((void **)(var->pointer)) = (void *) ecpg_alloc(len, stmt->lineno), stmt->lineno);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
|
for (act_tuple = 0; act_tuple < ntuples && status; act_tuple++)
|
||||||
|
@ -573,6 +573,9 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
|
|||||||
*dimension = type_dimension;
|
*dimension = type_dimension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*length >= 0 && *dimension >= 0 && pointer)
|
||||||
|
yyerror("No multi-dimensional array support");
|
||||||
|
|
||||||
switch (type_enum)
|
switch (type_enum)
|
||||||
{
|
{
|
||||||
case ECPGt_struct:
|
case ECPGt_struct:
|
||||||
@ -589,9 +592,9 @@ adjust_array(enum ECPGttype type_enum, int *dimension, int *length, int type_dim
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case ECPGt_varchar:
|
case ECPGt_varchar:
|
||||||
/* pointer has to get length 0 */
|
/* pointer has to get dimension 0 */
|
||||||
if (pointer)
|
if (pointer)
|
||||||
*length=0;
|
*dimension = 0;
|
||||||
|
|
||||||
/* one index is the string length */
|
/* one index is the string length */
|
||||||
if (*length < 0)
|
if (*length < 0)
|
||||||
@ -4838,6 +4841,7 @@ type: simple_type
|
|||||||
{
|
{
|
||||||
$$.type_str = $1;
|
$$.type_str = $1;
|
||||||
$$.type_enum = ECPGt_int;
|
$$.type_enum = ECPGt_int;
|
||||||
|
|
||||||
$$.type_dimension = -1;
|
$$.type_dimension = -1;
|
||||||
$$.type_index = -1;
|
$$.type_index = -1;
|
||||||
}
|
}
|
||||||
@ -4846,7 +4850,7 @@ type: simple_type
|
|||||||
/* this is for typedef'ed types */
|
/* this is for typedef'ed types */
|
||||||
struct typedefs *this = get_typedef($1);
|
struct typedefs *this = get_typedef($1);
|
||||||
|
|
||||||
$$.type_str = mm_strdup(this->name);
|
$$.type_str = (this->type->type_enum == ECPGt_varchar) ? make1_str("") : mm_strdup(this->name);
|
||||||
$$.type_enum = this->type->type_enum;
|
$$.type_enum = this->type->type_enum;
|
||||||
$$.type_dimension = this->type->type_dimension;
|
$$.type_dimension = this->type->type_dimension;
|
||||||
$$.type_index = this->type->type_index;
|
$$.type_index = this->type->type_index;
|
||||||
@ -4945,8 +4949,6 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
|
|||||||
switch(dimension)
|
switch(dimension)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
strcpy(dim, "[]");
|
|
||||||
break;
|
|
||||||
case -1:
|
case -1:
|
||||||
case 1:
|
case 1:
|
||||||
*dim = '\0';
|
*dim = '\0';
|
||||||
@ -4957,11 +4959,14 @@ variable: opt_pointer symbol opt_array_bounds opt_initializer
|
|||||||
}
|
}
|
||||||
sprintf(ascii_len, "%d", length);
|
sprintf(ascii_len, "%d", length);
|
||||||
|
|
||||||
if (length > 0)
|
if (length == 0)
|
||||||
$$ = make4_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } "), mm_strdup($2), mm_strdup(dim));
|
yyerror ("pointer to varchar are not implemented");
|
||||||
|
|
||||||
|
if (dimension == 0)
|
||||||
|
$$ = make4_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } *"), mm_strdup($2), $4);
|
||||||
else
|
else
|
||||||
yyerror ("pointer to varchar are not implemented yet");
|
$$ = make5_str(make5_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2), make1_str(" { int len; char arr["), mm_strdup(ascii_len)), make1_str("]; } "), mm_strdup($2), mm_strdup(dim), $4);
|
||||||
/* $$ = make4_str(make3_str(mm_strdup(actual_storage[struct_level]), make1_str(" struct varchar_"), mm_strdup($2)), make1_str(" { int len; char *arr; }"), mm_strdup($2), mm_strdup(dim));*/
|
|
||||||
break;
|
break;
|
||||||
case ECPGt_char:
|
case ECPGt_char:
|
||||||
case ECPGt_unsigned_char:
|
case ECPGt_unsigned_char:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
all: test1 test2 perftest
|
all: test1 test2 test3 perftest
|
||||||
|
|
||||||
LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
|
LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
|
||||||
|
|
||||||
@ -10,9 +10,13 @@ test2: test2.c
|
|||||||
test2.c: test2.pgc
|
test2.c: test2.pgc
|
||||||
/usr/local/pgsql/bin/ecpg $?
|
/usr/local/pgsql/bin/ecpg $?
|
||||||
|
|
||||||
|
test3: test3.c
|
||||||
|
test3.c: test3.pgc
|
||||||
|
/usr/local/pgsql/bin/ecpg $?
|
||||||
|
|
||||||
perftest: perftest.c
|
perftest: perftest.c
|
||||||
perftest.c:perftest.pgc
|
perftest.c:perftest.pgc
|
||||||
/usr/local/pgsql/bin/ecpg $?
|
/usr/local/pgsql/bin/ecpg $?
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-/bin/rm test1 test2 perftest *.c log
|
-/bin/rm test1 test2 test3 perftest *.c log
|
||||||
|
@ -8,19 +8,21 @@ typedef char* c;
|
|||||||
exec sql type ind is union { int integer; short smallint; };
|
exec sql type ind is union { int integer; short smallint; };
|
||||||
typedef union { int integer; short smallint; } ind;
|
typedef union { int integer; short smallint; } ind;
|
||||||
|
|
||||||
|
exec sql type str is varchar[8];
|
||||||
|
|
||||||
int
|
int
|
||||||
main ()
|
main ()
|
||||||
{
|
{
|
||||||
typedef struct { long born; short age; } birthinfo;
|
typedef struct { long born; short age; } birthinfo;
|
||||||
exec sql type birthinfo is struct { long born; short age; };
|
exec sql type birthinfo is struct { long born; short age; };
|
||||||
exec sql begin declare section;
|
exec sql begin declare section;
|
||||||
struct personal_struct { varchar name[8];
|
struct personal_struct { str name;
|
||||||
birthinfo birth;
|
birthinfo birth;
|
||||||
} personal;
|
} personal;
|
||||||
struct personal_indicator { int ind_name;
|
struct personal_indicator { int ind_name;
|
||||||
birthinfo ind_birth;
|
birthinfo ind_birth;
|
||||||
} ind_personal;
|
} ind_personal;
|
||||||
int ind_married;
|
float ind_married;
|
||||||
ind children;
|
ind children;
|
||||||
ind ind_children;
|
ind ind_children;
|
||||||
char *married = NULL;
|
char *married = NULL;
|
||||||
@ -68,8 +70,8 @@ exec sql end declare section;
|
|||||||
printf(", born %d", personal.birth.born);
|
printf(", born %d", personal.birth.born);
|
||||||
if (ind_personal.ind_birth.age >= 0)
|
if (ind_personal.ind_birth.age >= 0)
|
||||||
printf(", age = %d", personal.birth.age);
|
printf(", age = %d", personal.birth.age);
|
||||||
if (ind_married >= 0)
|
if ((long)ind_married >= 0)
|
||||||
printf(", married %10.10s", married);
|
printf(", married %s", married);
|
||||||
if (ind_children.smallint >= 0)
|
if (ind_children.smallint >= 0)
|
||||||
printf(", children = %d", children.integer);
|
printf(", children = %d", children.integer);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
@ -98,8 +100,8 @@ exec sql end declare section;
|
|||||||
printf(", born %d", personal.birth.born);
|
printf(", born %d", personal.birth.born);
|
||||||
if (ind_personal.ind_birth.age >= 0)
|
if (ind_personal.ind_birth.age >= 0)
|
||||||
printf(", age = %d", personal.birth.age);
|
printf(", age = %d", personal.birth.age);
|
||||||
if (ind_married >= 0)
|
if ((long)ind_married >= 0)
|
||||||
printf(", married %10.10s", married);
|
printf(", married %s", married);
|
||||||
if (ind_children.smallint >= 0)
|
if (ind_children.smallint >= 0)
|
||||||
printf(", children = %d", children.integer);
|
printf(", children = %d", children.integer);
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user