BUG #14167: ecpg parser cann't ignore code in #ifdef ?
The following bug has been logged on the website:
Bug reference: 14167
Logged by: Zhou Digoal
Email address: digoal@126.com
PostgreSQL version: 9.6beta1
Operating system: CentOS 6.x x64
Description:
HI,
this is my pgc code.
#include <stdio.h>
#include <stdlib.h>
#include <pgtypes_numeric.h>;
EXEC SQL WHENEVER SQLERROR STOP;
int
main(void)
{
EXEC SQL BEGIN DECLARE SECTION;
numeric *num;
#ifdef ABC
err *abc;
#endif
numeric *num2;
decimal *dec;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONNECT TO tcp:postgresql://127.0.0.1:5432/postgres AS test
USER test USING test;
num = PGTYPESnumeric_new();
dec = PGTYPESdecimal_new();
EXEC SQL SELECT 12.345::numeric(4,2), 23.456::decimal(4,2) INTO :num,
:dec;
printf("numeric = %s\n", PGTYPESnumeric_to_asc(num, 0));
printf("numeric = %s\n", PGTYPESnumeric_to_asc(num, 1));
printf("numeric = %s\n", PGTYPESnumeric_to_asc(num, 2));
/* Convert decimal to numeric to show a decimal value. */
num2 = PGTYPESnumeric_new();
PGTYPESnumeric_from_decimal(dec, num2);
printf("decimal = %s\n", PGTYPESnumeric_to_asc(num2, 0));
printf("decimal = %s\n", PGTYPESnumeric_to_asc(num2, 1));
printf("decimal = %s\n", PGTYPESnumeric_to_asc(num2, 2));
PGTYPESnumeric_free(num2);
PGTYPESdecimal_free(dec);
PGTYPESnumeric_free(num);
EXEC SQL COMMIT;
EXEC SQL DISCONNECT ALL;
return 0;
}
this is ERROR
ecpg -t -c -I/home/digoal/pgsql9.6/include -o t.c t.pgc
t.pgc:15: ERROR: unrecognized data type name "err"
And use #ifndef and -DABC also error.
ECPG parser cann't skip code in #ifdef or #ifndef ?
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
this is my pgc code.
...
#ifdef ABC
err *abc;
#endif
...
this is ERROR
ecpg -t -c -I/home/digoal/pgsql9.6/include -o t.c t.pgc
t.pgc:15: ERROR: unrecognized data type name "err"And use #ifndef and -DABC also error.
ECPG parser cann't skip code in #ifdef or #ifndef ?
'#ifdef' is a C precompiler command and thus is only parsed by cpp et
al. If you want ecpg to parse it you have to use 'exec sql ifdef'
instead.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
HI,
Thanks very much,
Because I see EDB's document ECPGplus can parser #ifdef.
so why postgresql community not do that?
I think many PG user need it to adpate some enviroment (like Oracle , pg, db2, ...) in .pgc code.
best regards ,
digoal
--
公益是一辈子的事,I'm Digoal,Just Do It.
At 2016-06-01 21:43:00, "Michael Meskes" <meskes@postgresql.org> wrote:
Show quoted text
this is my pgc code.
...
#ifdef ABC
err *abc;
#endif
...
this is ERROR
ecpg -t -c -I/home/digoal/pgsql9.6/include -o t.c t.pgc
t.pgc:15: ERROR: unrecognized data type name "err"And use #ifndef and -DABC also error.
ECPG parser cann't skip code in #ifdef or #ifndef ?'#ifdef' is a C precompiler command and thus is only parsed by cpp et
al. If you want ecpg to parse it you have to use 'exec sql ifdef'
instead.Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
On Thu, Jun 2, 2016 at 10:04 AM, 德哥 <digoal@126.com> wrote:
Because I see EDB's document ECPGplus can parser #ifdef.
so why postgresql community not do that?
Because EDB's stuff is not community stuff. I am not sure you can
expect both things to match, and it is not like ifdef grammar is not
supported as already mentioned by Michael.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs