On Tue, Nov 25, 2008 at 10:44:32AM +0000, Clemens Fischer wrote:
> Using ecpg and gcc generates the following output:
> ecpg -t -o ecpgtest-multidim.c ecpgtest-multidim.pgc
> cc -c -I/usr/local/pgsql/include ecpgtest-multidim.c
> ecpgtest-multidim.pgc: In function `main':
> ecpgtest-multidim.pgc:30: parse error before `_13'
> cc: /usr/qnx630/host/qnx6/x86/usr/lib/gcc-lib/ntox86/2.95.3/cc1 error 33
> make: *** [ecpgtest-multidim.o] Error 1

Thanks for reporting. Fixed in CVS HEAD and 8.3.

Patch is attached, it was just a small oversight that happened when the new
varchar naming was introduced.

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: [EMAIL PROTECTED]
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
--- pgsql-ecpg/preproc/type.c	2008-05-17 11:09:51.000000000 +0200
+++ pgsql/src/interfaces/ecpg/preproc/type.c	2008-11-26 14:15:03.000000000 +0100
@@ -327,8 +327,9 @@
 		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
 	else
 	{
-		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
-		char	   *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
+		char *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
+		char *offset = (char *) mm_alloc(strlen(name) + strlen("sizeof(struct varchar_)") + 1 + strlen(varcharsize) + sizeof(int) * CHAR_BIT * 10 / 3);
+		char *var_name; 
 
 		switch (type)
 		{
@@ -350,10 +351,14 @@
 				else
 					sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
 
+				/* remove trailing [] is name is array element */
+				var_name = strdup(name);
+				*(strchrnul(var_name, '[')) = '\0';
 				if (lineno)
-					sprintf(offset, "sizeof(struct varchar_%s_%d)", name, lineno);
+					sprintf(offset, "sizeof(struct varchar_%s_%d)", var_name, lineno);
 				else
-					sprintf(offset, "sizeof(struct varchar_%s)", name);
+					sprintf(offset, "sizeof(struct varchar_%s)", var_name);
+				free(var_name);
 				break;
 			case ECPGt_char:
 			case ECPGt_unsigned_char:
-- 
Sent via pgsql-bugs mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to