diff --git a/src/interfaces/ecpg/ChangeLog b/src/interfaces/ecpg/ChangeLog
index 650577f74f7cd8136c6252daedba05e39bfbe4d9..8e3445f7eaba139af43239e9b6edcb5d30fd3f84 100644
--- a/src/interfaces/ecpg/ChangeLog
+++ b/src/interfaces/ecpg/ChangeLog
@@ -888,5 +888,11 @@ Thu Mar 30 11:11:13 CEST 2000
 Fri Mar 31 08:25:58 CEST 2000
 
 	- Synced preproc.y with gram.y.
+
+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. 
 	- Set library version to 3.1.0.
 	- Set ecpg version to 2.7.0.
diff --git a/src/interfaces/ecpg/lib/execute.c b/src/interfaces/ecpg/lib/execute.c
index aca7fce993496a6f1a50a0da73d6174468f23c9d..875eb843115587a59dad4e8ac6902361088229ae 100644
--- a/src/interfaces/ecpg/lib/execute.c
+++ b/src/interfaces/ecpg/lib/execute.c
@@ -317,12 +317,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%d,", ((short *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%hd,", ((short *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%hd", *((short *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -331,12 +336,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%d,", ((int *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%d", *((int *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -345,12 +355,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%d,", ((unsigned short *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%hu,", ((unsigned short *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%hu", *((unsigned short *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -359,12 +374,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%d,", ((unsigned int *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%u,", ((unsigned int *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%u", *((unsigned int *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -372,13 +392,18 @@ ECPGexecute(struct statement * stmt)
 				case ECPGt_long:
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
-
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
+						
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%ld,", ((long *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%ld", *((long *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -387,12 +412,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%ld,", ((unsigned long *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%lu,", ((unsigned long *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%lu", *((unsigned long *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -401,12 +431,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((float *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%.14g", *((float *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -415,12 +450,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%.14g,", ((double *) var->value)[element]);
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%.14g", *((double *) var->value));
 
 					tobeinserted = mallocedval;
 					break;
@@ -429,12 +469,17 @@ ECPGexecute(struct statement * stmt)
 					if (!(mallocedval = ecpg_alloc(var->arrsize * 20, stmt->lineno)))
 						return false;
 
-					sprintf(mallocedval, "%s", (var->arrsize > 1) ? "'{" : ""); 
+					if (var->arrsize > 1)
+					{
+						strncpy(mallocedval, "'{", sizeof("'{")); 
 						
-					for (element = 0; element < var->arrsize; element++)
-						sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
+						for (element = 0; element < var->arrsize; element++)
+							sprintf(mallocedval + strlen(mallocedval), "%c,", (((char *) var->value)[element]) ? 't' : 'f');
 						
-					sprintf(mallocedval + strlen(mallocedval) - 1, "%s", (var->arrsize > 1) ? "}'" : ""); 
+						strncpy(mallocedval + strlen(mallocedval) - 1, "}'", sizeof("}'")); 
+					}
+					else
+						sprintf(mallocedval, "%c,", (*((char *) var->value)) ? 't' : 'f');
 
 					tobeinserted = mallocedval;
 					break;
@@ -814,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.2 2000/03/17 23:26:31 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/execute.c,v 1.3 2000/04/03 19:34:25 meskes Exp $
  */
 
 PGconn *ECPG_internal_get_connection(char *name);
diff --git a/src/interfaces/ecpg/test/test4.pgc b/src/interfaces/ecpg/test/test4.pgc
index dbbf49d7f093d6f38e29766a53e8173061dc167a..ade00f56559a53e2048d1a2842f7d5fff39ef6cc 100644
--- a/src/interfaces/ecpg/test/test4.pgc
+++ b/src/interfaces/ecpg/test/test4.pgc
@@ -8,7 +8,8 @@ int
 main ()
 {
 EXEC SQL BEGIN DECLARE SECTION;
-	int i = 1;
+	int i = 3;
+	int *did = &i;
 	int a[10] = {9,8,7,6,5,4,3,2,1,0};
 	double f;
 EXEC SQL END DECLARE SECTION;
@@ -31,6 +32,8 @@ EXEC SQL END DECLARE SECTION;
 	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) VALUES(140787.0,2,:a);
+	
+	EXEC SQL INSERT INTO test(f,i,a) VALUES(14.07,:did,:a);
 
 	EXEC SQL COMMIT;