Re: ECPG and escape strings

Lists: pgsql-hackerspgsql-interfacespgsql-patches
From: Michael Fuhr <mike(at)fuhr(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ECPG and escape strings
Date: 2005-08-03 14:31:25
Message-ID: 20050803143124.GA28095@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-interfaces pgsql-patches

ECPG seems to be a little overzealous with the new escape string syntax:

% cat foo.pgc
int
main(void)
{
putchar('\n');
return 0;
}

% ecpg foo.pgc

% gcc -I`pg_config --includedir` -c foo.c
foo.pgc: In function `main':
foo.pgc:4: `E' undeclared (first use in this function)
foo.pgc:4: (Each undeclared identifier is reported only once
foo.pgc:4: for each function it appears in.)
foo.pgc:4: syntax error before character constant

% cat foo.c
/* Processed by ecpg (4.1.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "foo.pgc"
int
main(void)
{
putchar(E'\n');
return 0;
}

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: PostgreSQL-interfaces <pgsql-interfaces(at)postgresql(dot)org>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] ECPG and escape strings
Date: 2005-08-13 02:22:18
Message-ID: 200508130222.j7D2MIf29122@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-interfaces pgsql-patches


Would someone on the interface list look for a fix to this? Thanks.

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

Michael Fuhr wrote:
> ECPG seems to be a little overzealous with the new escape string syntax:
>
> % cat foo.pgc
> int
> main(void)
> {
> putchar('\n');
> return 0;
> }
>
> % ecpg foo.pgc
>
> % gcc -I`pg_config --includedir` -c foo.c
> foo.pgc: In function `main':
> foo.pgc:4: `E' undeclared (first use in this function)
> foo.pgc:4: (Each undeclared identifier is reported only once
> foo.pgc:4: for each function it appears in.)
> foo.pgc:4: syntax error before character constant
>
> % cat foo.c
> /* Processed by ecpg (4.1.1) */
> /* These include files are added by the preprocessor */
> #include <ecpgtype.h>
> #include <ecpglib.h>
> #include <ecpgerrno.h>
> #include <sqlca.h>
> /* End of automatic include section */
> #line 1 "foo.pgc"
> int
> main(void)
> {
> putchar(E'\n');
> return 0;
> }
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ECPG and escape strings
Date: 2005-08-22 20:27:45
Message-ID: 200508222027.j7MKRji03320@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-interfaces pgsql-patches


It turns out I made a mistake in trying to be too smart about adding E''
escapes for ecpg strings that have backslashes. I have reversed the
attached patch to fix the problem. Thanks for the report.

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

Michael Fuhr wrote:
> ECPG seems to be a little overzealous with the new escape string syntax:
>
> % cat foo.pgc
> int
> main(void)
> {
> putchar('\n');
> return 0;
> }
>
> % ecpg foo.pgc
>
> % gcc -I`pg_config --includedir` -c foo.c
> foo.pgc: In function `main':
> foo.pgc:4: `E' undeclared (first use in this function)
> foo.pgc:4: (Each undeclared identifier is reported only once
> foo.pgc:4: for each function it appears in.)
> foo.pgc:4: syntax error before character constant
>
> % cat foo.c
> /* Processed by ecpg (4.1.1) */
> /* These include files are added by the preprocessor */
> #include <ecpgtype.h>
> #include <ecpglib.h>
> #include <ecpgerrno.h>
> #include <sqlca.h>
> /* End of automatic include section */
> #line 1 "foo.pgc"
> int
> main(void)
> {
> putchar(E'\n');
> return 0;
> }
>
> --
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 20.7 KB

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ECPG and escape strings
Date: 2005-08-23 07:40:36
Message-ID: 20050823074036.GA8062@1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-interfaces pgsql-patches

On Wed, Aug 03, 2005 at 08:31:25AM -0600, Michael Fuhr wrote:
> ECPG seems to be a little overzealous with the new escape string syntax:

This comes from starting the string constant with ESCAPE_STRING_SYNTAX
in case there is '\' inside the string. Actually I have no idea at the
moment how that made it into. I comment it out for the time being. If
anyone knows a reason for this behaviour please tell me and maybe fresh
up my memory.

CVS commit to come as soon as I'm online again.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Michael Fuhr <mike(at)fuhr(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ECPG and escape strings
Date: 2005-08-24 12:49:15
Message-ID: 200508241249.j7OCnFb28770@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers pgsql-interfaces pgsql-patches

Michael Meskes wrote:
> On Wed, Aug 03, 2005 at 08:31:25AM -0600, Michael Fuhr wrote:
> > ECPG seems to be a little overzealous with the new escape string syntax:
>
> This comes from starting the string constant with ESCAPE_STRING_SYNTAX
> in case there is '\' inside the string. Actually I have no idea at the
> moment how that made it into. I comment it out for the time being. If
> anyone knows a reason for this behaviour please tell me and maybe fresh
> up my memory.
>
> CVS commit to come as soon as I'm online again.

I have removed that from CVS. It was a bug I introduced.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073