Thread: [BUGS] BUG #14776: ecpg 4.12.0 issues with macros containing line continuedblocks

The following bug has been logged on the website:

Bug reference:      14776
Logged by:          Thomas Chin
Email address:      thom@genx.net
PostgreSQL version: 9.6.3
Operating system:   Linux
Description:

It appears that starting in ecpg 4.12.0, the pre-processor has issues with
macros code blocks ({ }) when a line continuation is used (\). When
encountered, "EXEC SQL TYPE" declarations are not registered, which results
in a "unregistered data type name" error. In another instance, variables
declared in an "EXEC SQL ... DECLARE SECTION" are unavailable given the same
conditions.


--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

> It appears that starting in ecpg 4.12.0, the pre-processor has issues with
> macros code blocks ({ }) when a line continuation is used (\). When
> encountered, "EXEC SQL TYPE" declarations are not registered, which results
> in a "unregistered data type name" error. In another instance, variables
> declared in an "EXEC SQL ... DECLARE SECTION" are unavailable given the same
> conditions.

Would it be possible for you to post an example?

Thanks

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! Go 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

Hello Michael,

Yes, I can. I had hit the "Save" button prematurely, expecting another
page to provide code fragments.

---

typedef char test_t[3];

EXEC SQL TYPE test_t IS VARCHAR[2];

// COMMENT OUT macros with line continued code block to get working
#define TEST_MACROS(x) { \       }

EXEC SQL BEGIN DECLARE SECTION;
test_t test;
EXEC SQL END DECLARE SECTION;

---

ecpg -o test.c test.pgc
test.pgc:10: ERROR: unrecognized data type name "test_t"

---

This test case works with ecpg (PostgreSQL 9.4.7) 4.10.0.
This test case works with ecpg (PostgreSQL 9.5.7) 4.11.0.
This test case does not work with ecpg (PostgreSQL 9.6.3) 4.12.0.

The code is processed successfully if the macros is omitted, commented
out or changed to be on a single line:
#define TEST_MACROS(x) { }

Thanks!

Best,
Thomas S. Chin


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Thanks Thomas.

Yes, I think the bug was introduced by commit
fc1ae7d2eb6a3de47f5f5cd6ebf2d18d226b8036 which was supposed to handle
the case of a cpp line with a linebreak but without a continuation
character. 

Suggestions for a fix are welcome, otherwise I'll look into it when I
find time.

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

Hello Michael,

Fixing it when you find time would be great. Currently, I have a
workaround, and can revert that commit when an updated ecpg build is
available.

Thank you Michael, and I hope to hear from you in the near future.

Kind regards,
Thomas S. Chin

On 08/11/2017 09:04 AM, Michael Meskes wrote:
> Thanks Thomas.
> 
> Yes, I think the bug was introduced by commit
> fc1ae7d2eb6a3de47f5f5cd6ebf2d18d226b8036 which was supposed to handle
> the case of a cpp line with a linebreak but without a continuation
> character. 
> 
> Suggestions for a fix are welcome, otherwise I'll look into it when I
> find time.
> 
> Michael
> 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

> Yes, I can. I had hit the "Save" button prematurely, expecting
> another
> page to provide code fragments.
> ...

Thanks for that. This example compiles on current master branch with
the fix I committed. Would you be able to try with your full source?

As usual I'm planning to backport if I don't get any negative feedback.

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

Hello again Michael,

Just did a full build of my tree with the postgres-master version of
ecpg, and it is working like a charm once again. Thank you for the
prompt fix, and I look forward to removing the workarounds when the
formal release is available.

Best,
Thomas S. Chin

On 08/15/2017 11:16 AM, Michael Meskes wrote:
>> Yes, I can. I had hit the "Save" button prematurely, expecting
>> another
>> page to provide code fragments.
>> ...
> 
> Thanks for that. This example compiles on current master branch with
> the fix I committed. Would you be able to try with your full source?
> 
> As usual I'm planning to backport if I don't get any negative feedback.
> 
> Michael
> 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs