BUG #1292: ecpg precompile bug (valiable typedef & define )

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1292: ecpg precompile bug (valiable typedef & define )
Date: 2004-10-25 01:22:37
Message-ID: 20041025012237.47DDC5A100B@www.postgresql.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1292
Logged by: shigeto aya

Email address: shigeto_aya_za(at)mail(dot)toyota(dot)co(dot)jp

PostgreSQL version: 7.4.2

Operating system: Red Hat Linux Advanced Server release 2.1AS/i686
(Pensacola)

Description: ecpg precompile bug (valiable typedef & define )

Details:

The result to demand cannot be found although the following programs were
performed.

Demand :
data insert ------
100
200
300
400
500
600
700
800
select ------
100
200
300
400
500
600
700
800

Execution result
data insert ------
100
200
300
400
500
600
700
800
select ------
1
200
300
400
5
600
700
800

sample program -------------------------

#include <stdio.h>
/* */
/* create table test_table ( retu text ); */
/* */
int main() {

#define LEN 3
exec sql begin declare section;
typedef char TYPE1[LEN+1];
typedef char TYPE2[3+1];

struct {
TYPE1 val1; /* NG */
TYPE2 val2; /* OK */
char val3[LEN+1]; /* OK */
char val4[3+1]; /* OK */
} k ;

TYPE1 val5; /* NG */
TYPE2 val6; /* OK */
char val7[3+1]; /* OK */
char val8[LEN+1]; /* OK */

char fetch_val[4];
exec sql end declare section;

exec sql connect to aya;
exec sql begin work;

printf("data insert ------ \n");
strcpy ( k.val1, "100"); printf("%s\n", k.val1);
strcpy ( k.val2, "200"); printf("%s\n", k.val2);
strcpy ( k.val3, "300"); printf("%s\n", k.val3);
strcpy ( k.val4, "400"); printf("%s\n", k.val4);
strcpy ( val5, "500"); printf("%s\n", val5);
strcpy ( val6, "600"); printf("%s\n", val6);
strcpy ( val7, "700"); printf("%s\n", val7);
strcpy ( val8, "800"); printf("%s\n", val8);

exec sql delete from test_table;
exec sql insert into test_table values ( :k.val1 ) ; /* bug ? */
exec sql insert into test_table values ( :k.val2 ) ; /* ok */
exec sql insert into test_table values ( :k.val3 ) ; /* ok */
exec sql insert into test_table values ( :k.val4 ) ; /* ok */
exec sql insert into test_table values ( :val5 ) ; /* bug ? */
exec sql insert into test_table values ( :val6 ) ; /* ok */
exec sql insert into test_table values ( :val7 ) ; /* ok */
exec sql insert into test_table values ( :val8 ) ; /* ok */

exec sql declare acur cursor for select retu1 from test_table ;
exec sql open acur;

printf("select ------ \n");
while(1) {
memset ( fetch_val, '\0', sizeof ( fetch_val ) );
exec sql fetch acur into :fetch_val ;
if (sqlca.sqlcode != 0 ){
break;
}
printf ("%s\n",fetch_val);
}

exec sql commit work;
exec sql disconnect;

exit( 0 );

}

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PostgreSQL Bugs List 2004-10-25 02:25:22 BUG #1293: INSERT INTO test (f1.f2) VALUES (1,2) - wrong diagnostic
Previous Message Tom Lane 2004-10-24 23:50:41 Re: [HACKERS] BUG #1290: Default value and ALTER...TYPE