Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION
От | Boszormenyi Zoltan |
---|---|
Тема | Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION |
Дата | |
Msg-id | 52934E51.8030000@cybertec.at обсуждение исходный текст |
Ответ на | Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION (Michael Meskes <meskes@postgresql.org>) |
Ответы |
Re: BUG #8608: ECPG: sizeof() in EXEC SQL DECLARE SECTION
|
Список | 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@postgresql.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/
Вложения
В списке pgsql-bugs по дате отправления: