@ -51,6 +51,13 @@ typedef struct ind {
# line 22 "pointer_to_struct.pgc"
# line 22 "pointer_to_struct.pgc"
typedef struct {
# line 27 "pointer_to_struct.pgc"
customer * customers ;
} company ;
# line 28 "pointer_to_struct.pgc"
int main ( )
int main ( )
{
{
/* exec sql begin declare section */
/* exec sql begin declare section */
@ -61,14 +68,14 @@ int main()
typedef struct {
typedef struct {
# line 31 "pointer_to_struct.pgc"
# line 37 "pointer_to_struct.pgc"
struct varchar_2 { int len ; char arr [ 50 ] ; } name ;
struct varchar_2 { int len ; char arr [ 50 ] ; } name ;
# line 32 "pointer_to_struct.pgc"
# line 38 "pointer_to_struct.pgc"
int phone ;
int phone ;
} customer2 ;
} customer2 ;
# line 33 "pointer_to_struct.pgc"
# line 39 "pointer_to_struct.pgc"
@ -87,103 +94,132 @@ int main()
# line 27 "pointer_to_struct.pgc"
# line 33 "pointer_to_struct.pgc"
customer * custs1 = ( customer * ) malloc ( sizeof ( customer ) * 10 ) ;
customer * custs1 = ( customer * ) malloc ( sizeof ( customer ) * 10 ) ;
# line 28 "pointer_to_struct.pgc"
# line 34 "pointer_to_struct.pgc"
cust_ind * inds = ( cust_ind * ) malloc ( sizeof ( cust_ind ) * 10 ) ;
cust_ind * inds = ( cust_ind * ) malloc ( sizeof ( cust_ind ) * 10 ) ;
# line 3 4 "pointer_to_struct.pgc"
# line 40 "pointer_to_struct.pgc"
customer2 * custs2 = ( customer2 * ) malloc ( sizeof ( customer2 ) * 10 ) ;
customer2 * custs2 = ( customer2 * ) malloc ( sizeof ( customer2 ) * 10 ) ;
# line 40 "pointer_to_struct.pgc"
# line 46 "pointer_to_struct.pgc"
struct customer3 {
struct customer3 {
# line 38 "pointer_to_struct.pgc"
# line 44 "pointer_to_struct.pgc"
char name [ 50 ] ;
char name [ 50 ] ;
# line 39 "pointer_to_struct.pgc"
# line 45 "pointer_to_struct.pgc"
int phone ;
int phone ;
} * custs3 = ( struct customer3 * ) malloc ( sizeof ( struct customer3 ) * 10 ) ;
} * custs3 = ( struct customer3 * ) malloc ( sizeof ( struct customer3 ) * 10 ) ;
# line 46 "pointer_to_struct.pgc"
# line 52 "pointer_to_struct.pgc"
struct customer4 {
struct customer4 {
# line 44 "pointer_to_struct.pgc"
# line 50 "pointer_to_struct.pgc"
struct varchar_3 { int len ; char arr [ 50 ] ; } name ;
struct varchar_3 { int len ; char arr [ 50 ] ; } name ;
# line 4 5 "pointer_to_struct.pgc"
# line 51 "pointer_to_struct.pgc"
int phone ;
int phone ;
} * custs4 = ( struct customer4 * ) malloc ( sizeof ( struct customer4 ) ) ;
} * custs4 = ( struct customer4 * ) malloc ( sizeof ( struct customer4 ) ) ;
# line 48 "pointer_to_struct.pgc"
# line 54 "pointer_to_struct.pgc"
company acme ;
# line 56 "pointer_to_struct.pgc"
int r ;
int r ;
# line 49 "pointer_to_struct.pgc"
# line 57 "pointer_to_struct.pgc"
struct varchar_4 { int len ; char arr [ 50 ] ; } onlyname [ 2 ] ;
struct varchar_4 { int len ; char arr [ 50 ] ; } onlyname [ 2 ] ;
/* exec sql end declare section */
/* exec sql end declare section */
# line 50 "pointer_to_struct.pgc"
# line 58 "pointer_to_struct.pgc"
ECPGdebug ( 1 , stderr ) ;
ECPGdebug ( 1 , stderr ) ;
acme . customers = ( customer * ) malloc ( sizeof ( customer ) * 10 ) ;
{ ECPGconnect ( __LINE__ , 0 , " ecpg1_regression " , NULL , NULL , NULL , 0 ) ;
{ ECPGconnect ( __LINE__ , 0 , " ecpg1_regression " , NULL , NULL , NULL , 0 ) ;
# line 54 "pointer_to_struct.pgc"
# line 6 4 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 5 4 "pointer_to_struct.pgc"
# line 6 4 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 5 4 "pointer_to_struct.pgc"
# line 6 4 "pointer_to_struct.pgc"
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " create table customers ( c varchar ( 50 ) , p int ) " , ECPGt_EOIT , ECPGt_EORT ) ;
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " create table customers ( c varchar ( 50 ) , p int ) " , ECPGt_EOIT , ECPGt_EORT ) ;
# line 5 6 "pointer_to_struct.pgc"
# line 6 6 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 5 6 "pointer_to_struct.pgc"
# line 6 6 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 5 6 "pointer_to_struct.pgc"
# line 6 6 "pointer_to_struct.pgc"
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " insert into customers values ( 'John Doe' , '12345' ) " , ECPGt_EOIT , ECPGt_EORT ) ;
# line 57 "pointer_to_struct.pgc"
/* First we'll insert some data using C variable references */
strcpy ( custs1 [ 0 ] . name . arr , " John Doe " ) ;
custs1 [ 0 ] . name . len = strlen ( custs1 [ 0 ] . name . arr ) ;
custs1 [ 0 ] . phone = 12345 ;
strcpy ( acme . customers [ 1 ] . name . arr , " Jane Doe " ) ;
acme . customers [ 1 ] . name . len = strlen ( acme . customers [ 1 ] . name . arr ) ;
acme . customers [ 1 ] . phone = 67890 ;
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " insert into customers values ( $1 , $2 ) " ,
ECPGt_varchar , & ( custs1 - > name ) , ( long ) 50 , ( long ) 1 , sizeof ( struct varchar_1 ) ,
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L ,
ECPGt_int , & ( custs1 [ 0 ] . phone ) , ( long ) 1 , ( long ) 1 , sizeof ( int ) ,
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L , ECPGt_EOIT , ECPGt_EORT ) ;
# line 78 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 57 "pointer_to_struct.pgc"
# line 78 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 57 "pointer_to_struct.pgc"
# line 78 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 57 "pointer_to_struct.pgc"
# line 78 "pointer_to_struct.pgc"
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " insert into customers values ( 'Jane Doe' , '67890' ) " , ECPGt_EOIT , ECPGt_EORT ) ;
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " insert into customers values ( $1 , $2 ) " ,
# line 58 "pointer_to_struct.pgc"
ECPGt_varchar , & ( acme . customers [ 1 ] . name ) , ( long ) 50 , ( long ) 1 , sizeof ( struct varchar_1 ) ,
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L ,
ECPGt_int , & ( acme . customers [ 1 ] . phone ) , ( long ) 1 , ( long ) 1 , sizeof ( int ) ,
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L , ECPGt_EOIT , ECPGt_EORT ) ;
# line 80 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 58 "pointer_to_struct.pgc"
# line 80 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 5 8 "pointer_to_struct.pgc"
# line 80 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 58 "pointer_to_struct.pgc"
# line 80 "pointer_to_struct.pgc"
/* Clear the array, to be sure reading back into it actually gets data */
memset ( custs1 , 0 , sizeof ( customer ) * 10 ) ;
/* Now read back the data */
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " select * from customers limit 2 " , ECPGt_EOIT ,
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " select * from customers limit 2 " , ECPGt_EOIT ,
ECPGt_varchar , & ( custs1 - > name ) , ( long ) 50 , ( long ) - 1 , sizeof ( customer ) ,
ECPGt_varchar , & ( custs1 - > name ) , ( long ) 50 , ( long ) - 1 , sizeof ( customer ) ,
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_int , & ( custs1 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( customer ) ,
ECPGt_int , & ( custs1 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( customer ) ,
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
# line 60 "pointer_to_struct.pgc"
# line 8 6 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 60 "pointer_to_struct.pgc"
# line 8 6 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 60 "pointer_to_struct.pgc"
# line 8 6 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 60 "pointer_to_struct.pgc"
# line 8 6 "pointer_to_struct.pgc"
printf ( " custs1: \n " ) ;
printf ( " custs1: \n " ) ;
for ( r = 0 ; r < 2 ; r + + )
for ( r = 0 ; r < 2 ; r + + )
@ -197,16 +233,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_int , & ( custs2 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( customer2 ) ,
ECPGt_int , & ( custs2 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( customer2 ) ,
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
# line 68 "pointer_to_struct.pgc"
# line 94 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 68 "pointer_to_struct.pgc"
# line 94 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 68 "pointer_to_struct.pgc"
# line 94 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 68 "pointer_to_struct.pgc"
# line 94 "pointer_to_struct.pgc"
printf ( " \n custs2: \n " ) ;
printf ( " \n custs2: \n " ) ;
for ( r = 0 ; r < 2 ; r + + )
for ( r = 0 ; r < 2 ; r + + )
@ -220,16 +256,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_int , & ( custs3 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct customer3 ) ,
ECPGt_int , & ( custs3 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct customer3 ) ,
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
# line 76 "pointer_to_struct.pgc"
# line 102 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 76 "pointer_to_struct.pgc"
# line 102 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 76 "pointer_to_struct.pgc"
# line 102 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 76 "pointer_to_struct.pgc"
# line 102 "pointer_to_struct.pgc"
printf ( " \n custs3: \n " ) ;
printf ( " \n custs3: \n " ) ;
for ( r = 0 ; r < 2 ; r + + )
for ( r = 0 ; r < 2 ; r + + )
@ -243,16 +279,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_short , & ( inds - > name_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) ,
ECPGt_int , & ( custs4 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct customer4 ) ,
ECPGt_int , & ( custs4 - > phone ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct customer4 ) ,
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
ECPGt_short , & ( inds - > phone_ind ) , ( long ) 1 , ( long ) - 1 , sizeof ( struct ind ) , ECPGt_EORT ) ;
# line 84 "pointer_to_struct.pgc"
# line 110 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 84 "pointer_to_struct.pgc"
# line 110 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 84 "pointer_to_struct.pgc"
# line 110 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 84 "pointer_to_struct.pgc"
# line 110 "pointer_to_struct.pgc"
printf ( " \n custs4: \n " ) ;
printf ( " \n custs4: \n " ) ;
printf ( " name - %s \n " , custs4 - > name . arr ) ;
printf ( " name - %s \n " , custs4 - > name . arr ) ;
@ -261,16 +297,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " select c from customers limit 2 " , ECPGt_EOIT ,
{ ECPGdo ( __LINE__ , 0 , 1 , NULL , 0 , ECPGst_normal , " select c from customers limit 2 " , ECPGt_EOIT ,
ECPGt_varchar , ( onlyname ) , ( long ) 50 , ( long ) 2 , sizeof ( struct varchar_4 ) ,
ECPGt_varchar , ( onlyname ) , ( long ) 50 , ( long ) 2 , sizeof ( struct varchar_4 ) ,
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L , ECPGt_EORT ) ;
ECPGt_NO_INDICATOR , NULL , 0L , 0L , 0L , ECPGt_EORT ) ;
# line 89 "pointer_to_struct.pgc"
# line 115 "pointer_to_struct.pgc"
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
if ( sqlca . sqlcode = = ECPG_NOT_FOUND ) sqlprint ( ) ;
# line 89 "pointer_to_struct.pgc"
# line 115 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 89 "pointer_to_struct.pgc"
# line 115 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 89 "pointer_to_struct.pgc"
# line 115 "pointer_to_struct.pgc"
printf ( " \n name: \n " ) ;
printf ( " \n name: \n " ) ;
for ( r = 0 ; r < 2 ; r + + )
for ( r = 0 ; r < 2 ; r + + )
@ -279,13 +315,13 @@ if (sqlca.sqlcode < 0) sqlprint();}
}
}
{ ECPGdisconnect ( __LINE__ , " ALL " ) ;
{ ECPGdisconnect ( __LINE__ , " ALL " ) ;
# line 96 "pointer_to_struct.pgc"
# line 122 "pointer_to_struct.pgc"
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
if ( sqlca . sqlwarn [ 0 ] = = ' W ' ) sqlprint ( ) ;
# line 96 "pointer_to_struct.pgc"
# line 122 "pointer_to_struct.pgc"
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
if ( sqlca . sqlcode < 0 ) sqlprint ( ) ; }
# line 96 "pointer_to_struct.pgc"
# line 122 "pointer_to_struct.pgc"
/* All the memory will anyway be freed at the end */
/* All the memory will anyway be freed at the end */