ECPG, two varchars with same name on same line
От | Heikki Linnakangas |
---|---|
Тема | ECPG, two varchars with same name on same line |
Дата | |
Msg-id | 49FAEFEB.6080906@enterprisedb.com обсуждение исходный текст |
Ответы |
Re: ECPG, two varchars with same name on same line
Re: ECPG, two varchars with same name on same line |
Список | 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 #include <stdio.h> #include <stdlib.h> #include <string.h> EXEC SQL INCLUDE ../regression; 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; int main(int argc, char* argv[]) { EXEC SQL BEGIN DECLARE SECTION; struct teststruct1 ts1; struct teststruct2 ts2; EXEC SQL END DECLARE SECTION; ECPGdebug(1, stderr); EXEC SQL CONNECT TO REGRESSDB1; EXEC SQL SELECT 'foo', 'bar' into :ts1; EXEC SQL SELECT 'foz', 'baz' into :ts2; printf("test\na b\n%s %s\n%s %s\n", ts1.a.arr, ts1.b.arr, ts2.a.arr, ts2.b.arr); EXEC SQL DISCONNECT ALL; return 0; }
В списке pgsql-hackers по дате отправления: