pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gláucio Barros Barcelos <glauciobb@hotmail.com>
To: John McKown <john.archie.mckown@gmail.com>
To: Michael Meskes <meskes@postgresql.org>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13676: C typedef code generated by ecpg with wrong syntax
Date: Mon, 19 Oct 2015 09:55:55 -0200
Message-ID: <SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl> (raw)
In-Reply-To: <CAAJSdjg+9aHzvSsiOOTqBc=8WjiK=G5b5Fza9oRt=QO4AAcy9w@mail.gmail.com>
References: <20151013192757.2798.91073@wrigleys.postgresql.org>
	<96336568.NSo5MdvYlz@feivel>
	<CAAJSdjg+9aHzvSsiOOTqBc=8WjiK=G5b5Fza9oRt=QO4AAcy9w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Dear John and Michael, 
Thanks for your help.  Everything is working now.
Regards,Gláucio Barros Barcelos

Date: Fri, 16 Oct 2015 13:09:34 -0500
Subject: Re: [BUGS] BUG #13676: C typedef code generated by ecpg with wrong syntax
From: john.archie.mckown@gmail.com
To: meskes@postgresql.org
CC: pgsql-bugs@postgresql.org; glauciobb@hotmail.com

I did a "git pull" from the PostrgeSQL repository. then did a "make ecpg" in the src/interfaces/ecpg directory. I then used the new ecpg on the example code, followed by a gcc compile. The compile went fine. I made a slight change to the code, just because to be:
#include <stdio.h>EXEC SQL TYPE t_char_10  IS char[10];EXEC SQL TYPE t_char_10d  IS struct { char data[10];};EXEC SQL TYPE char_ptr IS char reference;int main(){    t_char_10 string10;    int len=sizeof string10;    printf("size is: %d\n",len);    int status = 0;    return status;}
And then:
ecpg -c test-ecpg.pgc && gcc test-ecpg.c && ./a.out
which printed:
size is 10
Looks good to me on Linux, Fedora 22 x86_64.
On Fri, Oct 16, 2015 at 10:33 AM, Michael Meskes <meskes@postgresql.org> wrote:
> I trying to migrate my application developed using Pro*c to ECPG. But, when

> I run the code below with "ecpg -c" command to generate c code, the syntax

> for typedef generated appears to be wrong. Below is an sample code and the

> steps to generate error return by C compiler due the wrong syntax for

> typedef.



Thanks for spotting and reporting. The order of the arguments seems to be

broken.



Please try this to fix:

diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer

b/src/interfaces/ecpg/preproc/ecpg.trailer

index 8cc3844..16359a3 100644

--- a/src/interfaces/ecpg/preproc/ecpg.trailer

+++ b/src/interfaces/ecpg/preproc/ecpg.trailer

@@ -1311,7 +1311,7 @@ ECPGTypedef: TYPE_P

                        if (auto_create_c == false)

                                $$ = cat_str(7, mm_strdup("/* exec sql type"),

mm_strdup($3), mm_strdup("is"), mm_strdup($5.type_str), mm_strdup($6.str), $7,

mm_strdup("*/"));

                        else

-                               $$ = cat_str(6, mm_strdup("typedef "),

mm_strdup($5.type_str), *$7?mm_strdup("*"):mm_strdup(""), mm_strdup($6.str),

mm_strdup($3), mm_strdup(";"));

+                               $$ = cat_str(6, mm_strdup("typedef "),

mm_strdup($5.type_str), *$7?mm_strdup("*"):mm_strdup(""), mm_strdup($3),

mm_strdup($6.str), mm_strdup(";"));

                }

                ;



Already committed to HEAD. Will do backports later.



Thanks again.



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.meskes at gmail dot com

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



-- 

Schrodinger's backup: The condition of any backup is unknown until a restore is attempted.

Yoda of Borg, we are. Futile, resistance is, yes. Assimilated, you will be.

He's about as useful as a wax frying pan.

10 to the 12th power microphones = 1 Megaphone

Maranatha! <><
John McKown
 		 	   		  =

view thread (5+ messages)

Message-ID: <SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl>
Permalink:  ../SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl/
Also on:    postgresql.org/message-id/SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: glauciobb@hotmail.com, john.archie.mckown@gmail.com, meskes@postgresql.org
  Subject: Re: BUG #13676: C typedef code generated by ecpg with wrong syntax
  In-Reply-To: <SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl>
  References: <20151013192757.2798.91073@wrigleys.postgresql.org> <96336568.NSo5MdvYlz@feivel> <CAAJSdjg+9aHzvSsiOOTqBc=8WjiK=G5b5Fza9oRt=QO4AAcy9w@mail.gmail.com> <SNT149-W30C104EA2DB4C2EB5658CB53A0@phx.gbl>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox