Skip site navigation (1) Skip section navigation (2)

Re: ECPG, two varchars with same name on same line

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: ECPG, two varchars with same name on same line
Date: 2009-05-01 12:49:47
Message-ID: 49FAEFEB.6080906@enterprisedb.com (view raw)
ECPG constructs internal struct names for VARCHAR fields using the field 
name and line number it's defined on. In a contrived example, though, 
that's not unique. Consider the following example:

...
EXEC SQL BEGIN DECLARE SECTION;
struct teststruct1 {
         VARCHAR a[20];
         VARCHAR b[20];
};
struct teststruct2 {
         VARCHAR a[20];
         VARCHAR b[20];
};

EXEC SQL END DECLARE SECTION;
...

This works, but if you remove all the newlines, it fails:
varcharstructs2.pgc:8: error: redefinition of ‘struct varchar_a_8’
varcharstructs2.pgc:8: error: redefinition of ‘struct varchar_b_8’

Attached is a full test case.

That hardly happens in practice, of course, but it's trivial to fix by 
just adding some more salt to the struct name, like a simple counter, so 
it seems we should.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com
Attachment: varcharstructs.pgc
Description: text/plain (699 bytes)
From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ECPG, two varchars with same name on same line
Date: 2009-05-07 09:54:08
Message-ID: 20090507095408.GA29463@feivel.credativ.lan (view raw)
On Fri, May 01, 2009 at 03:49:47PM +0300, Heikki Linnakangas wrote:
> ECPG constructs internal struct names for VARCHAR fields using the field  
> name and line number it's defined on. In a contrived example, though,  
> that's not unique. Consider the following example:
> ...
> That hardly happens in practice, of course, but it's trivial to fix by  
> just adding some more salt to the struct name, like a simple counter, so  
> it seems we should.

In principle you're right. However, the change needs to be added in several
places like the internal variable structure that keeps the lineno anyway but
needs to add the counter too. BTW we can remove the lineno then I think.
Anyway, given that we are close to a release and the bug apparently never got
up in a real life usage for years I'd prefer to not change it now but wait
until the release has been done.

Comments anyone?

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

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ECPG, two varchars with same name on same line
Date: 2009-05-07 11:33:16
Message-ID: 4A02C6FC.9020305@enterprisedb.com (view raw)
Michael Meskes wrote:
> On Fri, May 01, 2009 at 03:49:47PM +0300, Heikki Linnakangas wrote:
>> ECPG constructs internal struct names for VARCHAR fields using the field  
>> name and line number it's defined on. In a contrived example, though,  
>> that's not unique. Consider the following example:
>> ...
>> That hardly happens in practice, of course, but it's trivial to fix by  
>> just adding some more salt to the struct name, like a simple counter, so  
>> it seems we should.
> 
> In principle you're right. However, the change needs to be added in several
> places like the internal variable structure that keeps the lineno anyway but
> needs to add the counter too. BTW we can remove the lineno then I think.
> Anyway, given that we are close to a release and the bug apparently never got
> up in a real life usage for years I'd prefer to not change it now but wait
> until the release has been done.

Yeah, if the fix isn't trivial, it's not worth it.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ECPG, two varchars with same name on same line
Date: 2010-02-27 03:23:19
Message-ID: 201002270323.o1R3NJs24865@momjian.us (view raw)
Michael Meskes wrote:
> On Fri, May 01, 2009 at 03:49:47PM +0300, Heikki Linnakangas wrote:
> > ECPG constructs internal struct names for VARCHAR fields using the field  
> > name and line number it's defined on. In a contrived example, though,  
> > that's not unique. Consider the following example:
> > ...
> > That hardly happens in practice, of course, but it's trivial to fix by  
> > just adding some more salt to the struct name, like a simple counter, so  
> > it seems we should.
> 
> In principle you're right. However, the change needs to be added in several
> places like the internal variable structure that keeps the lineno anyway but
> needs to add the counter too. BTW we can remove the lineno then I think.
> Anyway, given that we are close to a release and the bug apparently never got
> up in a real life usage for years I'd prefer to not change it now but wait
> until the release has been done.

Was this fixed?

-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com
  PG East:  http://www.enterprisedb.com/community/nav-pg-east-2010.do
  + If your life is a hard drive, Christ can be your backup. +

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>,Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>,PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ECPG, two varchars with same name on same line
Date: 2010-02-27 21:09:44
Message-ID: 20100227210944.GA22113@feivel.credativ.lan (view raw)
On Fri, Feb 26, 2010 at 10:23:19PM -0500, Bruce Momjian wrote:
> Was this fixed?

No, need to get along to fixing it.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes(at)jabber(dot)org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, bruce(at)momjian(dot)us
Subject: Re: ECPG, two varchars with same name on same line
Date: 2010-03-09 11:10:26
Message-ID: 20100309111026.GA5524@feivel.credativ.lan (view raw)
On Fri, May 01, 2009 at 03:49:47PM +0300, Heikki Linnakangas wrote:
> ECPG constructs internal struct names for VARCHAR fields using the
> field name and line number it's defined on. In a contrived example,
> though, that's not unique. Consider the following example:
> ...

This should now be fixed.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes(at)jabber(dot)org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL


Privacy Policy | About PostgreSQL
Copyright © 1996-2013 The PostgreSQL Global Development Group