BUG #1774: ecpg preprocessor produces a wrong varchar struct

From: "Dirk Jagdmann" <doj(at)cubic(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1774: ecpg preprocessor produces a wrong varchar struct
Date: 2005-07-18 16:40:17
Message-ID: 20050718164017.2F523F0AC6@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1774
Logged by: Dirk Jagdmann
Email address: doj(at)cubic(dot)org
PostgreSQL version: 8.0.3
Operating system: i686 Linux 2.6
Description: ecpg preprocessor produces a wrong varchar struct
Details:

The ecpg preprocessor produces wrong code which does not compile.

--- input.pgc ---
int main()
{
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR v;
EXEC SQL END DECLARE SECTION;
return 0;
}
-------------------

Now process it with "ecpg input.pgc" which results in:
--- input.c ---
/* Processed by ecpg (4.0.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "input.pgc"
int main()
{
/* exec sql begin declare section */
#line 4 "input.pgc"
struct varchar_v { int len; char arr[ -1 ]; } v ;
/* exec sql end declare section */
#line 5 "input.pgc"
return 0;
}
---------------

The array size of the struct is -1 and this does not compile:
input.pgc: In function `main':
input.pgc:4: error: size of array `arr' is negative

I suppose the size should have been 0 so it can be malloced by the backend.

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2005-07-18 20:18:04 Re: BUG #1756: PQexec eats huge amounts of memory
Previous Message sivagopal 2005-07-16 12:00:24 BUG #1772: java.sql.SQLException