Commit fb7b1df0 authored by Michael Meskes's avatar Michael Meskes

Fixed bug that caused arrays of varchar to be output with incomplete name.

In the process expanded one test case,
parent 0f855d62
......@@ -2322,3 +2322,8 @@ Sun, 17 Feb 2008 18:45:39 +0100
- Removed duplicate include of ecpgtype.h.
- Changed INFORMIX mode symbol definition yet again because the old
way didn't work on NetBSD.
Sun, 02 Mar 2008 11:50:48 +0100
- Fixed bug that caused arrays of varchar to be output with incomplete
name.
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.77 2007/12/21 14:33:20 meskes Exp $ */
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/type.c,v 1.78 2008/03/02 10:54:11 meskes Exp $ */
#include "postgres_fe.h"
......@@ -259,7 +259,7 @@ ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * type,
ECPGdump_a_simple(o, name,
type->u.element->type,
type->u.element->size, type->size, NULL, prefix, type->lineno);
type->u.element->size, type->size, NULL, prefix, type->u.element->lineno);
if (ind_type != NULL)
{
......
......@@ -81,6 +81,7 @@ int main( int argc, char * argv[] )
#line 26 "array_of_struct.pgc"
customer custs1 [ 10 ] ;
......@@ -111,54 +112,57 @@ int main( int argc, char * argv[] )
#line 44 "array_of_struct.pgc"
int r ;
/* exec sql end declare section */
#line 45 "array_of_struct.pgc"
struct varchar_onlyname_45 { int len; char arr[ 50 ]; } onlyname [2] ;
/* exec sql end declare section */
#line 46 "array_of_struct.pgc"
ECPGdebug(1, stderr);
{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0);
#line 49 "array_of_struct.pgc"
#line 50 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 49 "array_of_struct.pgc"
#line 50 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 49 "array_of_struct.pgc"
#line 50 "array_of_struct.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table customers ( c varchar ( 50 ) , p int ) ", ECPGt_EOIT, ECPGt_EORT);
#line 51 "array_of_struct.pgc"
#line 52 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 51 "array_of_struct.pgc"
#line 52 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 51 "array_of_struct.pgc"
#line 52 "array_of_struct.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'John Doe' , '12345' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 52 "array_of_struct.pgc"
#line 53 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 52 "array_of_struct.pgc"
#line 53 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 52 "array_of_struct.pgc"
#line 53 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 52 "array_of_struct.pgc"
#line 53 "array_of_struct.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into customers values ( 'Jane Doe' , '67890' ) ", ECPGt_EOIT, ECPGt_EORT);
#line 53 "array_of_struct.pgc"
#line 54 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 53 "array_of_struct.pgc"
#line 54 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 53 "array_of_struct.pgc"
#line 54 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 53 "array_of_struct.pgc"
#line 54 "array_of_struct.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select * from customers limit 2 ", ECPGt_EOIT,
......@@ -166,16 +170,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ),
ECPGt_int,&(custs1->phone),(long)1,(long)10,sizeof( customer ),
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 55 "array_of_struct.pgc"
#line 56 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 55 "array_of_struct.pgc"
#line 56 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 55 "array_of_struct.pgc"
#line 56 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 55 "array_of_struct.pgc"
#line 56 "array_of_struct.pgc"
printf("custs1:\n");
for (r = 0; r < 2; r++)
......@@ -189,16 +193,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ),
ECPGt_int,&(custs2->phone),(long)1,(long)10,sizeof( customer2 ),
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 63 "array_of_struct.pgc"
#line 64 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 63 "array_of_struct.pgc"
#line 64 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 63 "array_of_struct.pgc"
#line 64 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 63 "array_of_struct.pgc"
#line 64 "array_of_struct.pgc"
printf("\ncusts2:\n");
for (r = 0; r < 2; r++)
......@@ -212,16 +216,16 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short,&(inds->name_ind),(long)1,(long)10,sizeof( struct ind ),
ECPGt_int,&(custs3->phone),(long)1,(long)10,sizeof( struct customer3 ),
ECPGt_short,&(inds->phone_ind),(long)1,(long)10,sizeof( struct ind ), ECPGt_EORT);
#line 71 "array_of_struct.pgc"
#line 72 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 71 "array_of_struct.pgc"
#line 72 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 71 "array_of_struct.pgc"
#line 72 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 71 "array_of_struct.pgc"
#line 72 "array_of_struct.pgc"
printf("\ncusts3:\n");
for (r = 0; r < 2; r++)
......@@ -235,29 +239,49 @@ if (sqlca.sqlcode < 0) sqlprint();}
ECPGt_short,&(inds[0].name_ind),(long)1,(long)1,sizeof(short),
ECPGt_int,&(custs4.phone),(long)1,(long)1,sizeof(int),
ECPGt_short,&(inds[0].phone_ind),(long)1,(long)1,sizeof(short), ECPGt_EORT);
#line 79 "array_of_struct.pgc"
#line 80 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 79 "array_of_struct.pgc"
#line 80 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 79 "array_of_struct.pgc"
#line 80 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 79 "array_of_struct.pgc"
#line 80 "array_of_struct.pgc"
printf("\ncusts4:\n");
printf( "name - %s\n", custs4.name.arr );
printf( "phone - %d\n", custs4.phone );
{ 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_onlyname_45),
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
#line 85 "array_of_struct.pgc"
if (sqlca.sqlcode == ECPG_NOT_FOUND) sqlprint();
#line 85 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 85 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 85 "array_of_struct.pgc"
printf("\nname:\n");
for (r = 0; r < 2; r++)
{
printf( "name - %s\n", onlyname[r].arr );
}
{ ECPGdisconnect(__LINE__, "ALL");
#line 84 "array_of_struct.pgc"
#line 92 "array_of_struct.pgc"
if (sqlca.sqlwarn[0] == 'W') sqlprint();
#line 84 "array_of_struct.pgc"
#line 92 "array_of_struct.pgc"
if (sqlca.sqlcode < 0) sqlprint();}
#line 84 "array_of_struct.pgc"
#line 92 "array_of_struct.pgc"
return( 0 );
......
......@@ -2,75 +2,85 @@
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 51: QUERY: create table customers ( c varchar ( 50 ) , p int ) with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 51: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 51 Ok: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 52: QUERY: insert into customers values ( 'John Doe' , '12345' ) with 0 parameter on connection regress1
[NO_PID]: ecpg_execute line 52: QUERY: create table customers ( c varchar ( 50 ) , p int ) with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 52: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 52 Ok: INSERT 0 1
[NO_PID]: ecpg_execute line 52 Ok: CREATE TABLE
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 53: QUERY: insert into customers values ( 'Jane Doe' , '67890' ) with 0 parameter on connection regress1
[NO_PID]: ecpg_execute line 53: QUERY: insert into customers values ( 'John Doe' , '12345' ) with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 53: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 53 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 55: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: ecpg_execute line 54: QUERY: insert into customers values ( 'Jane Doe' , '67890' ) with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 54: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 54 Ok: INSERT 0 1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 56: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 56: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 56: Correctly got 2 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 56: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 56: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 56: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 55: using PQexec
[NO_PID]: ecpg_get_data line 56: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 55: Correctly got 2 tuples with 2 fields
[NO_PID]: ecpg_execute line 64: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 55: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 64: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 55: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 64: Correctly got 2 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 55: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 64: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 55: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 64: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 63: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: ecpg_get_data line 64: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 63: using PQexec
[NO_PID]: ecpg_get_data line 64: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 63: Correctly got 2 tuples with 2 fields
[NO_PID]: ecpg_execute line 72: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 63: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 72: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 63: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 72: Correctly got 2 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 63: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 72: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 63: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 72: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 71: QUERY: select * from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: ecpg_get_data line 72: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 71: using PQexec
[NO_PID]: ecpg_get_data line 72: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 71: Correctly got 2 tuples with 2 fields
[NO_PID]: ecpg_execute line 80: QUERY: select * from customers limit 1 with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 71: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 80: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 71: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: ecpg_execute line 80: Correctly got 1 tuples with 2 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 71: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 80: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 71: RESULT: 67890 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 80: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 79: QUERY: select * from customers limit 1 with 0 parameter on connection regress1
[NO_PID]: ecpg_execute line 85: QUERY: select c from customers limit 2 with 0 parameter on connection regress1
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 79: using PQexec
[NO_PID]: ecpg_execute line 85: using PQexec
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_execute line 79: Correctly got 1 tuples with 2 fields
[NO_PID]: ecpg_execute line 85: Correctly got 2 tuples with 1 fields
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 79: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 85: RESULT: John Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data line 79: RESULT: 12345 offset: -1 array: Yes
[NO_PID]: ecpg_get_data line 85: RESULT: Jane Doe offset: -1 array: Yes
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_finish: Connection regress1 closed.
[NO_PID]: sqlca: code: 0, state: 00000
......@@ -19,3 +19,7 @@ phone - 67890
custs4:
name - John Doe
phone - 12345
name:
name - John Doe
name - Jane Doe
......@@ -42,6 +42,7 @@ int main( int argc, char * argv[] )
int phone;
} custs4;
int r;
varchar onlyname[2][50];
EXEC SQL end declare section;
ECPGdebug(1, stderr);
......@@ -81,6 +82,13 @@ int main( int argc, char * argv[] )
printf( "name - %s\n", custs4.name.arr );
printf( "phone - %d\n", custs4.phone );
EXEC SQL select c INTO :onlyname from customers limit 2;
printf("\nname:\n");
for (r = 0; r < 2; r++)
{
printf( "name - %s\n", onlyname[r].arr );
}
EXEC SQL disconnect all;
return( 0 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment