diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 8e3445f7eaba139af43239e9b6edcb5d30fd3f84..be83084ee4900ae01b1cbbfdeed73f6690b93de5 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -894,5 +894,13 @@ Mon Apr  3 21:20:27 CEST 2000
 	- Made sure pointers are correctly inserted by libecpg. My thanks go
 	  to Jan Urbanek <jan@urbanek.cz> for findin many bugs before the
 	  release. 
+
+Wed Apr  5 07:54:56 CEST 2000
+
+	- Added patch by Peter Eisentraut <e99re41@DoCS.UU.SE> to fix some
+	  duplicate definittions in preproc.y.
+	- Removed duplicate ',' in execute.c.
+	- Changed error message for backend errors so it fits into sqlca.
+	- Fixed array handling.
 	- Set library version to 3.1.0.
 	- Set ecpg version to 2.7.0.
diff --git a/src/interfaces/ecpg/include/ecpglib.h b/src/interfaces/ecpg/include/ecpglib.h
index 03b09668ba9b42552f9c006dfe285bbed725e52c..8b8dd3f3b5cda891d38e4e425468bc4d9aa47471 100644
--- a/src/interfaces/ecpg/include/ecpglib.h
+++ b/src/interfaces/ecpg/include/ecpglib.h
@@ -34,7 +34,7 @@ extern		"C"
 							const char *descriptor,const char *query);
 	bool		ECPGdeallocate_desc(int line,const char *name);
 	bool		ECPGallocate_desc(int line,const char *name);
-	void		ECPGraise(int line, int code, const char *str);
+	void		ECPGraise(int line, int code, char *str);
 	bool		ECPGget_desc_header(int, char *, int *);
 	bool		ECPGget_desc(int, char *, int, ...);
 	
diff --git a/src/interfaces/ecpg/lib/error.c b/src/interfaces/ecpg/lib/error.c
index 5aa4b771566b3f7f35e4589acfa7fac367cbdf12..e7e976116b8a909be20e30086eeb1174bcdb6520 100644
--- a/src/interfaces/ecpg/lib/error.c
+++ b/src/interfaces/ecpg/lib/error.c
@@ -7,9 +7,10 @@
 #include <sqlca.h>
 
 void
-ECPGraise(int line, int code, const char *str)
+ECPGraise(int line, int code, char *str)
 {
 	sqlca.sqlcode = code;
+	
 	switch (code)
 	{ 
 		case ECPG_NOT_FOUND: 
@@ -117,9 +118,13 @@ ECPGraise(int line, int code, const char *str)
 				"Variable is not a character type in line %d.", line);
 			break;
 			
-		case ECPG_PGSQL: 
+		case ECPG_PGSQL:
+			/* strip trailing newline */
+			if (str[strlen(str)-1] == '\n') 
+				str[strlen(str)-1] = '\0';
+							
 			snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"Postgres error '%s' in line %d.", str, line);
+				"'%s' in line %d.", str, line);
 			break;
 			
 		case ECPG_TRANS: 
@@ -134,12 +139,12 @@ ECPGraise(int line, int code, const char *str)
 			
 		default:
 		    	snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
-				"SQL error #%d in line %d.",code, line);
+				"SQL error #%d in line %d.", code, line);
 			break;
 	}
 	
 	sqlca.sqlerrm.sqlerrml = strlen(sqlca.sqlerrm.sqlerrmc);
-	
+
         /* free all memory we have allocated for the user */
         free_auto_mem();
 }
diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c
index 875eb843115587a59dad4e8ac6902361088229ae..89d756787e26ed371b3ce9fc17f974282bedaee7 100644
--- a/src/interfaces/ecpg/lib/execute.c
+++ b/src/interfaces/ecpg/lib/execute.c
@@ -479,7 +479,7 @@ ECPGexecute(struct statement * stmt)
 						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
 					}
 					else
-						sprintf(mallocedval, "%c,", (*((char *) var->value)) ? 't' : 'f');
+						sprintf(mallocedval, "%c", (*((char *) var->value)) ? 't' : 'f');
 
 					tobeinserted = mallocedval;
 					break;
@@ -541,7 +541,7 @@ ECPGexecute(struct statement * stmt)
 
 				default:
 					/* Not implemented yet */
-					ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, ECPGtype_name(var->type));
+					ECPGraise(stmt->lineno, ECPG_UNSUPPORTED, (char *)ECPGtype_name(var->type));
 					return false;
 					break;
 			}
@@ -859,7 +859,7 @@ ECPGdo(int lineno, const char *connection_name, char *query, ...)
  *
  * Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
  *
- * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.3 2000/04/03 19:34:25 meskes Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.4 2000/04/05 09:05:28 meskes Exp $
  */
 
 PGconn *ECPG_internal_get_connection(char *name);
@@ -1024,6 +1024,6 @@ bool ECPGdo_descriptor(int line,const char *connection,
 	    }
 	}
 	
-	ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, descriptor);
+	ECPGraise(line, ECPG_UNKNOWN_DESCRIPTOR, (char *) descriptor);
 	return false;
 }
diff --git a/src/interfaces/ecpg/preproc/pgc.l b/src/interfaces/ecpg/preproc/pgc.l
index 847a5437334d1a5d3b5f2763857dc92d05b5bbf7..82daf7188d5c0648e9a0ed218d056e5dcfa31b67 100644
--- a/src/interfaces/ecpg/preproc/pgc.l
+++ b/src/interfaces/ecpg/preproc/pgc.l
@@ -12,7 +12,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.57 2000/03/30 11:41:40 meskes Exp $
+ *	  $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.58 2000/04/05 09:05:34 meskes Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -827,6 +827,7 @@ lex_init(void)
 	braces_open = 0;
 
 	preproc_tos = 0;
+	yylineno = 0;
 	ifcond = TRUE;
 	stacked_if_value[preproc_tos].condition = ifcond;
 	stacked_if_value[preproc_tos].else_branch = FALSE;
diff --git a/src/interfaces/ecpg/preproc/preproc.y b/src/interfaces/ecpg/preproc/preproc.y
index ac98aa333c42e8d8d3d336128fc497a6f2cd79d9..266745c3d64af1d830b61bc063033f8cd09e6119 100644
--- a/src/interfaces/ecpg/preproc/preproc.y
+++ b/src/interfaces/ecpg/preproc/preproc.y
@@ -325,7 +325,7 @@ make_name(void)
 %type  <str>    TriggerActionTime CreateTrigStmt DropPLangStmt PLangTrusted
 %type  <str>    CreatePLangStmt IntegerOnly TriggerFuncArgs TriggerFuncArg
 %type  <str>    ViewStmt LoadStmt CreatedbStmt createdb_opt_encoding
-%type  <str>	createdb_opt_location opt_encoding AlterTableStmt
+%type  <str>	createdb_opt_location opt_encoding
 %type  <str>    DropdbStmt ClusterStmt grantee RevokeStmt table_expr Bit bit
 %type  <str>	GrantStmt privileges operation_commalist operation
 %type  <str>	opt_cursor opt_lmode ConstraintsSetStmt comment_tg
@@ -333,7 +333,7 @@ make_name(void)
 %type  <str>    select_clause opt_select_limit select_limit_value ConstraintTimeSpec
 %type  <str>    select_offset_value using_expr join_expr ReindexStmt
 %type  <str>	using_list from_expr join_clause join_type
-%type  <str>	join_qual update_list join_clause join_clause_with_union
+%type  <str>	join_qual update_list join_clause_with_union
 %type  <str>	opt_level opt_lock lock_type users_in_new_group_clause
 %type  <str>    OptConstrFromTable comment_op OptTempTableName
 %type  <str>    constraints_set_list constraints_set_namelist comment_fn
@@ -359,7 +359,7 @@ make_name(void)
 %type  <str>	enum_type civariableonly ECPGCursorStmt ECPGDeallocate
 %type  <str>	ECPGFree ECPGDeclare ECPGVar opt_at enum_definition
 %type  <str>    struct_type s_struct declaration declarations variable_declarations
-%type  <str>    s_struct s_union union_type ECPGSetAutocommit on_off
+%type  <str>    s_union union_type ECPGSetAutocommit on_off
 %type  <str>	ECPGAllocateDescr ECPGDeallocateDescr symbol opt_symbol
 %type  <str>	ECPGGetDescriptorHeader ECPGColId ECPGColLabel ECPGTypeName
 %type  <str>	ECPGLabelTypeName
@@ -4349,7 +4349,7 @@ variable: opt_pointer ECPGColLabel opt_array_bounds opt_initializer
                                $$ = cat_str(4, $1, mm_strdup($2), $3.str, $4);
                                break;
                            case ECPGt_varchar:
-                               if (dimension == -1)
+                               if (dimension < 0)
                                    type = ECPGmake_simple_type(actual_type[struct_level].type_enum, length);
                                else
                                    type = ECPGmake_array_type(ECPGmake_simple_type(actual_type[struct_level].type_enum, length), dimension);
diff --git a/src/interfaces/ecpg/preproc/type.c b/src/interfaces/ecpg/preproc/type.c
index eff50f6a812ac1cbf9519f77276c543b532ae0aa..95c79e3f09ea8683fdefa8be6e2b6571d4257218 100644
--- a/src/interfaces/ecpg/preproc/type.c
+++ b/src/interfaces/ecpg/preproc/type.c
@@ -198,13 +198,6 @@ static void ECPGdump_a_struct(FILE *o, const char *name, const char *ind_name, l
 void
 ECPGdump_a_type(FILE *o, const char *name, struct ECPGtype * typ, const char *ind_name, struct ECPGtype * ind_typ, const char *prefix, const char *ind_prefix)
 {
-#if 0
-	if (ind_typ == NULL)
-	{
-		ind_typ = &ecpg_no_indicator;
-		ind_name = "no_indicator";
-	}
-#endif
 	switch (typ->typ)
 	{
 		case ECPGt_array:
@@ -273,23 +266,35 @@ ECPGdump_a_simple(FILE *o, const char *name, enum ECPGttype typ,
 		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);
 
-		/* we have to use the pointer except for arrays with given bounds */
-		if (arrsize > 0)
-			sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
-		else
-			sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
-
 		switch (typ)
 		{
 			case ECPGt_varchar:
+				/* we have to use the pointer except for arrays with given bounds */
+				if (arrsize > 0)
+					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+				else
+					sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
 				sprintf(offset, "sizeof(struct varchar_%s)", name);
 				break;
 			case ECPGt_char:
 			case ECPGt_unsigned_char:
 			case ECPGt_char_variable:
+				/* we have to use the pointer except for arrays with given bounds */
+				if (varcharsize > 1 || arrsize > 0)
+					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+				else
+					sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
 				sprintf(offset, "%ld*sizeof(char)", varcharsize == 0 ? 1 : varcharsize);
 				break;
 			default:
+				/* we have to use the pointer except for arrays with given bounds */
+				if (arrsize > 0)
+					sprintf(variable, "(%s%s)", prefix ? prefix : "", name);
+				else
+					sprintf(variable, "&(%s%s)", prefix ? prefix : "", name);
+
 				sprintf(offset, "sizeof(%s)", ECPGtype_name(typ));
 				break;
 		}
diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index 7e824c021ab0f13342a71d1b520ec37f4119a31c..3f2f7f6771b93ff3aa60a98527d8c6621b4c2c8e 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -1,7 +1,7 @@
 all: test1 test2 test3 test4 perftest dyntest dyntest2
 
-#LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
-LDFLAGS=-g -I../include -I/usr/include/postgresql  -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt 
+LDFLAGS=-g -I /usr/local/pgsql/include -L/usr/local/pgsql/lib -lecpg -lpq -lcrypt
+#LDFLAGS=-g -I../include -I/usr/include/postgresql  -L../lib -L/usr/lib/postgresql -lecpg -lpq -lcrypt 
 #LDFLAGS=-g -I/usr/include/postgresql -lecpg -lpq -lcrypt
 
 #ECPG=/usr/local/pgsql/bin/ecpg
diff --git a/src/interfaces/ecpg/test/test4.pgc b/src/interfaces/ecpg/test/test4.pgc
index ade00f56559a53e2048d1a2842f7d5fff39ef6cc..10312b694422d653d6c218aba390f54f1a197246 100644
--- a/src/interfaces/ecpg/test/test4.pgc
+++ b/src/interfaces/ecpg/test/test4.pgc
@@ -11,6 +11,8 @@ EXEC SQL BEGIN DECLARE SECTION;
 	int i = 3;
 	int *did = &i;
 	int a[10] = {9,8,7,6,5,4,3,2,1,0};
+	char text[10] = "klmnopqrst";
+	char *t = "uvwxyz1234";
 	double f;
 EXEC SQL END DECLARE SECTION;
 	FILE *dbgs;
@@ -26,34 +28,36 @@ EXEC SQL END DECLARE SECTION;
 
  	EXEC SQL BEGIN WORK;
 
-/*	EXEC SQL CREATE TABLE test (f decimal(8,2), i int, a int[10]);*/
-	EXEC SQL CREATE TABLE test (f float, i int, a int[10]);
+	EXEC SQL CREATE TABLE test (f float, i int, a int[10], text char(10));
 
-	EXEC SQL INSERT INTO test(f,i,a) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}');
+	EXEC SQL INSERT INTO test(f,i,a,text) VALUES(404.90,1,'{0,1,2,3,4,5,6,7,8,9}','abcdefghij');
 
-	EXEC SQL INSERT INTO test(f,i,a) VALUES(140787.0,2,:a);
+	EXEC SQL INSERT INTO test(f,i,a,text) VALUES(140787.0,2,:a,:text);
 	
-	EXEC SQL INSERT INTO test(f,i,a) VALUES(14.07,:did,:a);
+	EXEC SQL INSERT INTO test(f,i,a,text) VALUES(14.07,:did,:a,:t);
 
 	EXEC SQL COMMIT;
 
 	EXEC SQL BEGIN WORK; 
 
-	EXEC SQL SELECT f
-         INTO :f
+	EXEC SQL SELECT f,text
+         INTO :f,:text
          FROM test
-         WHERE i = :i;
+         WHERE i = 1;
 
-	printf("Found f=%f\n", f);
+	printf("Found f=%f text=%10.10s\n", f, text);
 
-	EXEC SQL SELECT a
-	 INTO :a
+	f=14.07;
+	EXEC SQL SELECT a,text
+	 INTO :a,:t
 	 FROM test
 	 WHERE f = :f;
 
 	for (i = 0; i < 10; i++)
 		printf("Found a[%d] = %d\n", i, a[i]);
 
+	printf("Found text=%10.10s\n", t);
+
 	EXEC SQL DROP TABLE test;
 
 	EXEC SQL COMMIT;