From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | alexsav23(at)gmail(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION |
Date: | 2013-11-25 13:19:13 |
Message-ID: | 52934E51.8030000@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
2013-11-25 09:18 keltezéssel, Michael Meskes írta:
> On Sun, Nov 24, 2013 at 03:59:40PM +0100, Boszormenyi Zoltan wrote:
>> I think it's needlessly narrows the scope of the problem.
>> Consider this code:
>>
>> #include <stdio.h>
>>
>> #define hide_size_of_var sizeof
>> ...
> I assume you'd want to put this defined name into a declare section, right?
> Well, that's what EXEC SQL DECLARE is for, isn't it?
Of course. And of course you meant EXEC SQL DEFINE.
The attached code throws syntax errors over sizeof(int) and
sizeof(struct somestruct). I compiled GIT HEAD which contains your fix:
commit 08d1b22b3be2305ad6b83ca275829ff26305f5d7
Author: Michael Meskes <meskes(at)postgresql(dot)org>
Date: Sun Nov 24 12:51:21 2013 +0100
Allow C array definitions to use sizeof().
When parsing C variable definitions ecpg should allow sizeof() operators as array
dimensions.
So it seems it's not enough, try these with the attached code:
Succeeds:
$ ecpg array-sizeof.pgc
These fail:
$ ecpg -D TRY_INT array-sizeof.pgc
array-sizeof.pgc:24: ERROR: syntax error at or near "int"
$ ecpg -D TRY_STRUCT array-sizeof.pgc
array-sizeof.pgc:30: ERROR: syntax error at or near "struct"
The attached patch fixes "sizeof(struct something)" but the
"simple_type" variant that should also accept
[signed|unsigned]{char|short|int|long|long long}
causes 2 shift/reduce problems when processing preproc.y.
Best regards,
Zoltán Böszörményi
>
>> I think you should pass everything through as is inside the '[' and ']' and
>> let the C compiler fail if the code is not valid.
> I prefer catching as much as possible without re-implementing a C-compiler of course.
>
> Michael
--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/
Attachment | Content-Type | Size |
---|---|---|
array-sizeof.pgc | text/plain | 975 bytes |
array-sizeof-struct-fix.patch | text/x-patch | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Meskes | 2013-11-25 14:14:46 | Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION |
Previous Message | Oliver Munyao | 2013-11-25 10:54:37 | Re: pgdump not dumping my database |