BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

Started by Vladimir Zvagolskiyabout 10 years ago13 messagesbugs
Jump to latest
#1Vladimir Zvagolskiy
Vladimir.Zvagolskiy@nasdaq.com

The following bug has been logged on the website:

Bug reference: 13898
Logged by: vladimir zvagolskiy
Email address: vladimir.zvagolskiy@nasdaq.com
PostgreSQL version: 9.4.5
Operating system: Centos 7.1
Description:

Hi guys,

We experience a ecpg build issue for INFORMIX dialect:

[vlzv@inetlinux10 ecpg_9.4_issue]$ cat simple.ec
EXEC SQL include datetime;

[vlzv@inetlinux10 ecpg_9.4_issue]$ /usr/pgsql-9.4/bin/ecpg -C INFORMIX -I
/usr/pgsql-9.4/include/informix/esql simple.ec
/usr/pgsql-9.4/include/informix/esql/datetime.h:9: ERROR: nested /* ... */
comments

[vlzv@inetlinux10 ecpg_9.4_issue]$ rpm -qf
/usr/pgsql-9.4/include/informix/esql/datetime.h
postgresql94-devel-9.4.5-1PGDG.rhel7.x86_64

once I modify datetime.h file as per below diff, the issue disappears.
[vlzv@inetlinux10 ecpg_9.4_issue]$ cat -n
/usr/pgsql-9.4/include/informix/esql/datetime.h
1 /* src/interfaces/ecpg/include/datetime.h */
2
3 #ifndef _ECPG_DATETIME_H
4 #define _ECPG_DATETIME_H
5
6 #include <ecpg_informix.h>
7
8 #ifndef _ECPGLIB_H /* source created by
ecpg which defines thes
9 /*
symbols */
10 typedef timestamp dtime_t;
11 typedef interval intrvl_t;
12 #endif /* ndef _ECPGLIB_H */
13
14 #endif /* ndef _ECPG_DATETIME_H */

[vlzv@inetlinux10 ecpg_9.4_issue]$ diff
/usr/pgsql-9.4/include/informix/esql/datetime.h
/usr/pgsql-9.4/include/informix/esql/datetime.h.orig
9c9
< /* symbols
*/
---

* symbols

*/

[vlzv@inetlinux10 ecpg_9.4_issue]$ /usr/pgsql-9.4/bin/ecpg -C INFORMIX -I
/usr/pgsql-9.4/include/informix/esql simple.ec
[vlzv@inetlinux10 ecpg_9.4_issue]$ ls -l ./simple.c
-rw-rw-r-- 1 vlzv vlzv 700 Jan 29 11:15 ./simple.c

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

#2Michael Meskes
meskes@postgresql.org
In reply to: Vladimir Zvagolskiy (#1)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

once I modify datetime.h file as per below diff, the issue
disappears.
 
[vlzv@inetlinux10 ecpg_9.4_issue]$ diff
/usr/pgsql-9.4/include/informix/esql/datetime.h
/usr/pgsql-9.4/include/informix/esql/datetime.h.orig
9c9
<                                                                /*
symbols
*/
---

                                                               *
symbols

*/

I'm a bit confused. My 9.4.5 source tree does not show a "/*" in line
9, but only a "*", or in other words the patch you applied seems to
only bring your source back to what originally was in 9.4.5.

What do I miss here?

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

#3Vladimir Zvagolskiy
Vladimir.Zvagolskiy@nasdaq.com
In reply to: Michael Meskes (#2)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

Hi Michael,

Sorry for being confusing with this.
You're right, I've modified the file manually by putting "/" in front of "*" on line 9, and then made a diff.
*.orig is the original file as you have it in your 9.4.5 sources tree.

Thanks!

Cheers,
Vlad

-----Original Message-----
From: Michael Meskes [mailto:meskes@postgresql.org]
Sent: Saturday, 30 January 2016 11:02 PM
To: pgsql-bugs@postgresql.org
Cc: Vladimir Zvagolskiy <Vladimir.Zvagolskiy@nasdaq.com>
Subject: Re: [BUGS] BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

once I modify datetime.h file as per below diff, the issue disappears.
 
[vlzv@inetlinux10 ecpg_9.4_issue]$ diff
/usr/pgsql-9.4/include/informix/esql/datetime.h
/usr/pgsql-9.4/include/informix/esql/datetime.h.orig
9c9
<                                                                /*
symbols */
---

                                                               *
symbols

*/

I'm a bit confused. My 9.4.5 source tree does not show a "/*" in line 9, but only a "*", or in other words the patch you applied seems to only bring your source back to what originally was in 9.4.5.

What do I miss here?

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

***********************************************************
CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient and may constitute non-public information. If you received this e-mail in error, disclosing, copying, distributing or taking any action in reliance of this e-mail is strictly prohibited and may be unlawful. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive any work product or other applicable legal privilege(s) by the transmission of this message.
***********************************************************

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

#4Michael Meskes
meskes@postgresql.org
In reply to: Vladimir Zvagolskiy (#3)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Sun, Jan 31, 2016 at 10:23:39PM +0000, Vladimir Zvagolskiy wrote:

Sorry for being confusing with this.
You're right, I've modified the file manually by putting "/" in front of "*" on line 9, and then made a diff.
*.orig is the original file as you have it in your 9.4.5 sources tree.

I.e. you don't see the nested comments problem with 9.4.5 sources either, right?

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

#5Vladimir Zvagolskiy
Vladimir.Zvagolskiy@nasdaq.com
In reply to: Michael Meskes (#4)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

No, I do see problems with 9.3.5.
Until I've done the described modification in datetime.h

Cheers,
Vlad

-----Original Message-----
From: Michael Meskes [mailto:meskes@postgresql.org]
Sent: Monday, 1 February 2016 7:57 PM
To: Vladimir Zvagolskiy <Vladimir.Zvagolskiy@nasdaq.com>
Cc: Michael Meskes <meskes@postgresql.org>; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Sun, Jan 31, 2016 at 10:23:39PM +0000, Vladimir Zvagolskiy wrote:

Sorry for being confusing with this.
You're right, I've modified the file manually by putting "/" in front of "*" on line 9, and then made a diff.
*.orig is the original file as you have it in your 9.4.5 sources tree.

I.e. you don't see the nested comments problem with 9.4.5 sources either, right?

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

***********************************************************
CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient and may constitute non-public information. If you received this e-mail in error, disclosing, copying, distributing or taking any action in reliance of this e-mail is strictly prohibited and may be unlawful. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive any work product or other applicable legal privilege(s) by the transmission of this message.
***********************************************************

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

#6Michael Meskes
meskes@postgresql.org
In reply to: Vladimir Zvagolskiy (#5)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Mon, Feb 01, 2016 at 08:59:17AM +0000, Vladimir Zvagolskiy wrote:

No, I do see problems with 9.3.5.

Any reason why you're on 9.3.5 and not a later 9.3 version?

Until I've done the described modification in datetime.h

Anyway, I cannot see a nested comment in that version either. Could you send a small test case to reproduce? 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

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Michael Meskes (#6)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

Michael Meskes <meskes@postgresql.org> writes:

On Mon, Feb 01, 2016 at 08:59:17AM +0000, Vladimir Zvagolskiy wrote:

Until I've done the described modification in datetime.h

Anyway, I cannot see a nested comment in that version either. Could you send a small test case to reproduce? Thanks.

It seems a bit fishy that the comment in question starts on an #if line
and ends on an ordinary line. I am not sure what the C standard says
about such cases, but I can certainly imagine that some tools might not
be very happy with that.

It looks like that code was last touched by pgindent in d747140279426607:

-#ifndef _ECPGLIB_H /* source created by ecpg which defines these symbols */
+#ifndef _ECPGLIB_H             /* source created by ecpg which defines these
+                                * symbols */

Perhaps that was a bad change, and you should make it look like

/* helpful comment here */
#ifndef _ECPGLIB_H

regards, tom lane

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

#8Vladimir Zvagolskiy
Vladimir.Zvagolskiy@nasdaq.com
In reply to: Michael Meskes (#6)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

Hi Michael,

I've installed from yum repository for RHEL7, that was the latest 9.3.x version available.

Here is the small test that throws the error:

[vlzv@inetlinux10 ecpg_9.4_issue]$ cat simple.ec
EXEC SQL include datetime;

[vlzv@inetlinux10 ecpg_9.4_issue]$ /usr/pgsql-9.4/bin/ecpg -C INFORMIX -I /usr/pgsql-9.4/include/informix/esql simple.ec
/usr/pgsql-9.4/include/informix/esql/datetime.h:9: ERROR: nested /* ... */ comments

Thanks again!

Cheers,
Vlad

-----Original Message-----
From: Michael Meskes [mailto:meskes@postgresql.org]
Sent: Monday, 1 February 2016 8:44 PM
To: Vladimir Zvagolskiy <Vladimir.Zvagolskiy@nasdaq.com>
Cc: Michael Meskes <meskes@postgresql.org>; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Mon, Feb 01, 2016 at 08:59:17AM +0000, Vladimir Zvagolskiy wrote:

No, I do see problems with 9.3.5.

Any reason why you're on 9.3.5 and not a later 9.3 version?

Until I've done the described modification in datetime.h

Anyway, I cannot see a nested comment in that version either. Could you send a small test case to reproduce? 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

***********************************************************
CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient and may constitute non-public information. If you received this e-mail in error, disclosing, copying, distributing or taking any action in reliance of this e-mail is strictly prohibited and may be unlawful. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive any work product or other applicable legal privilege(s) by the transmission of this message.
***********************************************************

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

#9Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#7)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Mon, Feb 01, 2016 at 10:56:44AM +0100, Tom Lane wrote:

It seems a bit fishy that the comment in question starts on an #if line
and ends on an ordinary line. I am not sure what the C standard says
about such cases, but I can certainly imagine that some tools might not
be very happy with that.

Very good catch. Vladimir, which compiler are you using?

It looks like that code was last touched by pgindent in d747140279426607:

Let me guess, pg_indent?

It sure looks like it.

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

#10Vladimir Zvagolskiy
Vladimir.Zvagolskiy@nasdaq.com
In reply to: Michael Meskes (#9)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

Hi Michael, Tom,

We use gcc-4.9.1, but it is ecpg pre-compiler that throws the error.
I'm not familiar with pg_indent.

Cheers,
Vlad

-----Original Message-----
From: Michael Meskes [mailto:meskes@postgresql.org]
Sent: Monday, 1 February 2016 9:48 PM
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Meskes <meskes@postgresql.org>; Vladimir Zvagolskiy <Vladimir.Zvagolskiy@nasdaq.com>; pgsql-bugs@postgresql.org
Subject: Re: [BUGS] BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Mon, Feb 01, 2016 at 10:56:44AM +0100, Tom Lane wrote:

It seems a bit fishy that the comment in question starts on an #if
line and ends on an ordinary line. I am not sure what the C standard
says about such cases, but I can certainly imagine that some tools
might not be very happy with that.

Very good catch. Vladimir, which compiler are you using?

It looks like that code was last touched by pgindent in d747140279426607:

Let me guess, pg_indent?

It sure looks like it.

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

***********************************************************
CONFIDENTIALITY NOTICE: This e-mail and any attachments are for the exclusive and confidential use of the intended recipient and may constitute non-public information. If you received this e-mail in error, disclosing, copying, distributing or taking any action in reliance of this e-mail is strictly prohibited and may be unlawful. Instead, please notify us immediately by return e-mail and promptly delete this message and its attachments from your computer system. We do not waive any work product or other applicable legal privilege(s) by the transmission of this message.
***********************************************************

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

#11Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#7)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On Mon, Feb 01, 2016 at 10:56:44AM +0100, Tom Lane wrote:

It seems a bit fishy that the comment in question starts on an #if line
and ends on an ordinary line. I am not sure what the C standard says
about such cases, but I can certainly imagine that some tools might not
be very happy with that.

It turns out ecpg is one of these tools. Lines starting with #<whatever> are
considered CPP code and not parsed for C language comments. In the C code it
then finds only the end of the comment and throws the error.

It does surprise me, though, that the error only pops up now. I was pretty sure
at least one of these headers was used in the regression suit.

Will fix.

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

#12Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#7)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

and ends on an ordinary line. I am not sure what the C standard says
about such cases, but I can certainly imagine that some tools might not
be very happy with that.

We/I have to figure out what the standard says, because if it allows these comments, the lexer itself has to be fixed to work correctly instead of just fixing the header files.

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

#13Peter J. Holzer
hjp-pgsql@hjp.at
In reply to: Michael Meskes (#12)
Re: BUG #13898: ecpg complains on nested comments in /usr/pgsql-9.4/include/informix/esql/datetime.h

On 2016-02-01 13:16:20 +0100, Michael Meskes wrote:

and ends on an ordinary line. I am not sure what the C standard says
about such cases, but I can certainly imagine that some tools might not
be very happy with that.

We/I have to figure out what the standard says, because if it allows
these comments, the lexer itself has to be fixed to work correctly
instead of just fixing the header files.

The relevant translation phases are 3 and 4 according to the C standard
(section 5.1.1.2 in C11):

| 3. The source file is decomposed into preprocessing tokens7) and
| sequences of white-space characters (including comments). A source
| file shall not end in a partial preprocessing token or in a partial
| comment. Each comment is replaced by one space character. New-line
| characters are retained. Whether each nonempty sequence of
| white-space characters other than new-line is retained or replaced
| by one space character is implementation-defined.
|
| 4. Preprocessing directives are executed, macro invocations are
| expanded, and _Pragma unary operator expressions are executed. If a
| character sequence that matches the syntax of a universal character
| name is produced by token concatenation (6.10.3.3), the behavior is
| undefined. A #include preprocessing directive causes the named
| header or source file to be processed from phase 1 through phase 4,
| recursively. All preprocessing directives are then deleted.

Comments are replaced with whitespace in phase 3, preprocessing
directives are are only considered in phase 4. So code like

----------------------------------------------------------------------------
#ifndef _ECPGLIB_H /* source created by ecpg which defines these␤
* symbols */␤
----------------------------------------------------------------------------

is valid C and should be exactly equivalent to

----------------------------------------------------------------------------
#ifndef _ECPGLIB_H ␤

----------------------------------------------------------------------------

(␤ denotes a newline character here)

hp

--
_ | Peter J. Holzer | I want to forget all about both belts and
|_|_) | | suspenders; instead, I want to buy pants
| | | hjp@hjp.at | that actually fit.
__/ | http://www.hjp.at/ | -- http://noncombatant.org/