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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
varcharstructs.pgc text/plain 699 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-05-01 12:58:08 Re: Perl coding style in postgresql
Previous Message Dave Page 2009-05-01 10:23:18 Re: windows shared memory error