Index: contrib/dbase/dbf.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/dbase/dbf.c,v
retrieving revision 1.3
diff -c -r1.3 dbf.c
*** contrib/dbase/dbf.c	25 Oct 2001 05:49:19 -0000	1.3
--- contrib/dbase/dbf.c	12 Aug 2002 16:42:59 -0000
***************
*** 437,443 ****
  	format: sprintf format-string to get the right precision with real numbers
  
  	NOTE: this declaration of 'foo' can cause overflow when the contents-field
! 	is longer the 127 chars (which is highly unlikely, cos it is not used
  	in text-fields).
  */
  /*	REMEMBER THAT THERE'S A 0x1A AT THE END OF THE FILE, SO DON'T
--- 437,443 ----
  	format: sprintf format-string to get the right precision with real numbers
  
  	NOTE: this declaration of 'foo' can cause overflow when the contents-field
! 	is longer the 127 chars (which is highly unlikely, because it is not used
  	in text-fields).
  */
  /*	REMEMBER THAT THERE'S A 0x1A AT THE END OF THE FILE, SO DON'T
***************
*** 488,498 ****
  				if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0))
  				{
  					fl = atof(rec[t].db_contents);
! 					sprintf(format, "%%.%df", rec[t].db_dec);
! 					sprintf(foo, format, fl);
  				}
  				else
! 					strcpy(foo, rec[t].db_contents);
  				if (strlen(foo) > rec[t].db_flen)
  					length = rec[t].db_flen;
  				else
--- 488,498 ----
  				if ((rec[t].db_type == 'N') && (rec[t].db_dec != 0))
  				{
  					fl = atof(rec[t].db_contents);
! 					snprintf(format, 32, "%%.%df", rec[t].db_dec);
! 					snprintf(foo, 128, format, fl);
  				}
  				else
! 					strncpy(foo, rec[t].db_contents, 128);
  				if (strlen(foo) > rec[t].db_flen)
  					length = rec[t].db_flen;
  				else
Index: contrib/dbase/dbf2pg.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/dbase/dbf2pg.c,v
retrieving revision 1.9
diff -c -r1.9 dbf2pg.c
*** contrib/dbase/dbf2pg.c	10 Jan 2002 01:11:45 -0000	1.9
--- contrib/dbase/dbf2pg.c	12 Aug 2002 16:42:59 -0000
***************
*** 308,314 ****
  				if (dbh->db_fields[i].db_flen > 1)
  				{
  					strcat(query, " varchar");
! 					sprintf(t, "(%d)",
  							dbh->db_fields[i].db_flen);
  					strcat(query, t);
  				}
--- 308,314 ----
  				if (dbh->db_fields[i].db_flen > 1)
  				{
  					strcat(query, " varchar");
! 					snprintf(t, 20, "(%d)",
  							dbh->db_fields[i].db_flen);
  					strcat(query, t);
  				}
***************
*** 467,473 ****
  				{
  					if ((strlen(foo) == 8) && isinteger(foo))
  					{
! 						sprintf(pgdate, "%c%c%c%c-%c%c-%c%c",
  								foo[0], foo[1], foo[2], foo[3],
  								foo[4], foo[5], foo[6], foo[7]);
  						strcat(query, pgdate);
--- 467,473 ----
  				{
  					if ((strlen(foo) == 8) && isinteger(foo))
  					{
! 						snprintf(pgdate, 10, "%c%c%c%c-%c%c-%c%c",
  								foo[0], foo[1], foo[2], foo[3],
  								foo[4], foo[5], foo[6], foo[7]);
  						strcat(query, pgdate);
Index: contrib/findoidjoins/findoidjoins.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/findoidjoins/findoidjoins.c,v
retrieving revision 1.15
diff -c -r1.15 findoidjoins.c
*** contrib/findoidjoins/findoidjoins.c	25 Apr 2002 02:56:55 -0000	1.15
--- contrib/findoidjoins/findoidjoins.c	12 Aug 2002 16:42:59 -0000
***************
*** 68,81 ****
  		{
  			unset_result(relres);
  			if (strcmp(typname, "oid") == 0)
! 				sprintf(query, "\
  					DECLARE c_matches BINARY CURSOR FOR \
  					SELECT	count(*)::int4 \
  						FROM \"%s\" t1, \"%s\" t2 \
  					WHERE t1.\"%s\" = t2.oid ",
  						relname, relname2, attname);
  			else
! 				sprintf(query, "\
  					DECLARE c_matches BINARY CURSOR FOR \
  					SELECT	count(*)::int4 \
  						FROM \"%s\" t1, \"%s\" t2 \
--- 68,81 ----
  		{
  			unset_result(relres);
  			if (strcmp(typname, "oid") == 0)
! 				snprintf(query, 4000, "\
  					DECLARE c_matches BINARY CURSOR FOR \
  					SELECT	count(*)::int4 \
  						FROM \"%s\" t1, \"%s\" t2 \
  					WHERE t1.\"%s\" = t2.oid ",
  						relname, relname2, attname);
  			else
! 				sprintf(query, 4000, "\
  					DECLARE c_matches BINARY CURSOR FOR \
  					SELECT	count(*)::int4 \
  						FROM \"%s\" t1, \"%s\" t2 \
Index: contrib/lo/lo.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/lo/lo.c,v
retrieving revision 1.11
diff -c -r1.11 lo.c
*** contrib/lo/lo.c	7 Dec 2001 04:18:31 -0000	1.11
--- contrib/lo/lo.c	12 Aug 2002 16:42:59 -0000
***************
*** 92,98 ****
  		return (NULL);
  
  	result = (char *) palloc(32);
! 	sprintf(result, "%u", *addr);
  	return (result);
  }
  
--- 92,98 ----
  		return (NULL);
  
  	result = (char *) palloc(32);
! 	snprintf(result, 32, "%u", *addr);
  	return (result);
  }
  
Index: contrib/mSQL-interface/mpgsql.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/mSQL-interface/mpgsql.c,v
retrieving revision 1.3
diff -c -r1.3 mpgsql.c
*** contrib/mSQL-interface/mpgsql.c	25 Oct 2001 05:49:19 -0000	1.3
--- contrib/mSQL-interface/mpgsql.c	12 Aug 2002 16:42:59 -0000
***************
*** 106,112 ****
  {
  	char		tbuf[BUFSIZ];
  
! 	sprintf(tbuf, "create database %s", b);
  	return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
  }
  
--- 106,112 ----
  {
  	char		tbuf[BUFSIZ];
  
! 	snprintf(tbuf, BUFSIZ, "create database %s", b);
  	return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
  }
  
***************
*** 115,121 ****
  {
  	char		tbuf[BUFSIZ];
  
! 	sprintf(tbuf, "drop database %s", b);
  	return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
  }
  
--- 115,121 ----
  {
  	char		tbuf[BUFSIZ];
  
! 	snprintf(tbuf, BUFSIZ, "drop database %s", b);
  	return msqlQuery(a, tbuf) >= 0 ? 0 : -1;
  }
  
***************
*** 262,268 ****
  	m_result   *m;
  	char		tbuf[BUFSIZ];
  
! 	sprintf(tbuf, "select relname from pg_class where relkind='r' and relowner=%d", getuid());
  	if (msqlQuery(a, tbuf) > 0)
  	{
  		m = msqlStoreResult();
--- 262,270 ----
  	m_result   *m;
  	char		tbuf[BUFSIZ];
  
! 	snprintf(tbuf, BUFSIZ,
! 			 "select relname from pg_class where relkind='r' and relowner=%d",
! 			 getuid());
  	if (msqlQuery(a, tbuf) > 0)
  	{
  		m = msqlStoreResult();
***************
*** 284,290 ****
  	m_result   *m;
  	char		tbuf[BUFSIZ];
  
! 	sprintf(tbuf, "select relname from pg_class where relkind='i' and relowner=%d", getuid());
  	if (msqlQuery(a, tbuf) > 0)
  	{
  		m = msqlStoreResult();
--- 286,294 ----
  	m_result   *m;
  	char		tbuf[BUFSIZ];
  
! 	snprintf(tbuf, BUFSIZ,
! 			 "select relname from pg_class where relkind='i' and relowner=%d",
! 			 getuid());
  	if (msqlQuery(a, tbuf) > 0)
  	{
  		m = msqlStoreResult();
Index: contrib/oid2name/oid2name.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/oid2name/oid2name.c,v
retrieving revision 1.14
diff -c -r1.14 oid2name.c
*** contrib/oid2name/oid2name.c	12 Jun 2002 21:09:09 -0000	1.14
--- contrib/oid2name/oid2name.c	12 Aug 2002 16:42:59 -0000
***************
*** 337,343 ****
  	char		todo[1024];
  
  	/* get the oid and database name from the system pg_database table */
! 	sprintf(todo, "select oid,datname from pg_database");
  
  	sql_exec(conn, todo, 0);
  }
--- 337,343 ----
  	char		todo[1024];
  
  	/* get the oid and database name from the system pg_database table */
! 	snprintf(todo, 1024, "select oid,datname from pg_database");
  
  	sql_exec(conn, todo, 0);
  }
***************
*** 351,359 ****
  
  	/* don't exclude the systables if this is set */
  	if (systables == 1)
! 		sprintf(todo, "select relfilenode,relname from pg_class order by relname");
  	else
! 		sprintf(todo, "select relfilenode,relname from pg_class where relname not like 'pg_%%' order by relname");
  
  	sql_exec(conn, todo, 0);
  }
--- 351,359 ----
  
  	/* don't exclude the systables if this is set */
  	if (systables == 1)
! 		snprintf(todo, 1024, "select relfilenode,relname from pg_class order by relname");
  	else
! 		snprintf(todo, 1024, "select relfilenode,relname from pg_class where relname not like 'pg_%%' order by relname");
  
  	sql_exec(conn, todo, 0);
  }
***************
*** 367,373 ****
  	char		todo[1024];
  
  	/* get the oid and tablename where the name matches tablename */
! 	sprintf(todo, "select relfilenode,relname from pg_class where relname = '%s'", tablename);
  
  	returnvalue = sql_exec(conn, todo, 1);
  
--- 367,373 ----
  	char		todo[1024];
  
  	/* get the oid and tablename where the name matches tablename */
! 	snprintf(todo, 1024, "select relfilenode,relname from pg_class where relname = '%s'", tablename);
  
  	returnvalue = sql_exec(conn, todo, 1);
  
***************
*** 386,392 ****
  	int			returnvalue;
  	char		todo[1024];
  
! 	sprintf(todo, "select relfilenode,relname from pg_class where oid = %i", oid);
  
  	returnvalue = sql_exec(conn, todo, 1);
  
--- 386,392 ----
  	int			returnvalue;
  	char		todo[1024];
  
! 	snprintf(todo, 1024, "select relfilenode,relname from pg_class where oid = %i", oid);
  
  	returnvalue = sql_exec(conn, todo, 1);
  
Index: contrib/pg_dumplo/lo_export.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/pg_dumplo/lo_export.c,v
retrieving revision 1.8
diff -c -r1.8 lo_export.c
*** contrib/pg_dumplo/lo_export.c	25 Oct 2001 05:49:19 -0000	1.8
--- contrib/pg_dumplo/lo_export.c	12 Aug 2002 16:42:59 -0000
***************
*** 110,117 ****
  		/*
  		 * Query: find the LOs referenced by this column
  		 */
! 		sprintf(Qbuff, "SELECT DISTINCT l.loid FROM \"%s\" x, pg_largeobject l WHERE x.\"%s\" = l.loid",
! 				ll->lo_table, ll->lo_attr);
  
  		/* puts(Qbuff); */
  
--- 110,118 ----
  		/*
  		 * Query: find the LOs referenced by this column
  		 */
! 		snprintf(Qbuff, QUERY_BUFSIZ,
! 				 "SELECT DISTINCT l.loid FROM \"%s\" x, pg_largeobject l WHERE x.\"%s\" = l.loid",
! 				 ll->lo_table, ll->lo_attr);
  
  		/* puts(Qbuff); */
  
***************
*** 140,146 ****
  			if (pgLO->action != ACTION_SHOW)
  			{
  
! 				sprintf(path, "%s/%s/%s", pgLO->space, pgLO->db,
  						ll->lo_table);
  
  				if (mkdir(path, DIR_UMASK) == -1)
--- 141,147 ----
  			if (pgLO->action != ACTION_SHOW)
  			{
  
! 				snprintf(path, BUFSIZ, "%s/%s/%s", pgLO->space, pgLO->db,
  						ll->lo_table);
  
  				if (mkdir(path, DIR_UMASK) == -1)
***************
*** 152,158 ****
  					}
  				}
  
! 				sprintf(path, "%s/%s/%s/%s", pgLO->space, pgLO->db,
  						ll->lo_table, ll->lo_attr);
  
  				if (mkdir(path, DIR_UMASK) == -1)
--- 153,159 ----
  					}
  				}
  
! 				snprintf(path, BUFSIZ, "%s/%s/%s/%s", pgLO->space, pgLO->db,
  						ll->lo_table, ll->lo_attr);
  
  				if (mkdir(path, DIR_UMASK) == -1)
***************
*** 185,191 ****
  					continue;
  				}
  
! 				sprintf(path, "%s/%s/%s/%s/%s", pgLO->space,
  						pgLO->db, ll->lo_table, ll->lo_attr, val);
  
  				if (lo_export(pgLO->conn, lo, path) < 0)
--- 186,192 ----
  					continue;
  				}
  
! 				snprintf(path, BUFSIZ, "%s/%s/%s/%s/%s", pgLO->space,
  						pgLO->db, ll->lo_table, ll->lo_attr, val);
  
  				if (lo_export(pgLO->conn, lo, path) < 0)
Index: contrib/pg_dumplo/lo_import.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/pg_dumplo/lo_import.c,v
retrieving revision 1.6
diff -c -r1.6 lo_import.c
*** contrib/pg_dumplo/lo_import.c	25 Oct 2001 05:49:19 -0000	1.6
--- contrib/pg_dumplo/lo_import.c	12 Aug 2002 16:42:59 -0000
***************
*** 48,54 ****
  		loa.lo_table = tab;
  		loa.lo_attr = attr;
  
! 		sprintf(lo_path, "%s/%s", pgLO->space, path);
  
  		/*
  		 * Import LO
--- 48,54 ----
  		loa.lo_table = tab;
  		loa.lo_attr = attr;
  
! 		snprintf(lo_path, BUFSIZ, "%s/%s", pgLO->space, path);
  
  		/*
  		 * Import LO
***************
*** 81,87 ****
  		/*
  		 * UPDATE oid in tab
  		 */
! 		sprintf(Qbuff, "UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u",
  			loa.lo_table, loa.lo_attr, new_oid, loa.lo_attr, loa.lo_oid);
  
  		/* fprintf(stderr, Qbuff); */
--- 81,88 ----
  		/*
  		 * UPDATE oid in tab
  		 */
! 		snprintf(Qbuff, QUERY_BUFSIZ,
! 			"UPDATE \"%s\" SET \"%s\"=%u WHERE \"%s\"=%u",
  			loa.lo_table, loa.lo_attr, new_oid, loa.lo_attr, loa.lo_oid);
  
  		/* fprintf(stderr, Qbuff); */
Index: contrib/pg_dumplo/utils.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/pg_dumplo/utils.c,v
retrieving revision 1.4
diff -c -r1.4 utils.c
*** contrib/pg_dumplo/utils.c	22 Mar 2001 03:59:10 -0000	1.4
--- contrib/pg_dumplo/utils.c	12 Aug 2002 16:42:59 -0000
***************
*** 36,42 ****
  	if (pgLO->action == ACTION_SHOW)
  		return;
  
! 	sprintf(path, "%s/%s", pgLO->space, pgLO->db);
  
  	if (pgLO->action == ACTION_EXPORT_ATTR ||
  		pgLO->action == ACTION_EXPORT_ALL)
--- 36,42 ----
  	if (pgLO->action == ACTION_SHOW)
  		return;
  
! 	snprintf(path, BUFSIZ, "%s/%s", pgLO->space, pgLO->db);
  
  	if (pgLO->action == ACTION_EXPORT_ATTR ||
  		pgLO->action == ACTION_EXPORT_ALL)
***************
*** 51,57 ****
  			}
  		}
  
! 		sprintf(path, "%s/lo_dump.index", path);
  
  		if ((pgLO->index = fopen(path, "w")) == NULL)
  		{
--- 51,57 ----
  			}
  		}
  
! 		snprintf(path, BUFSIZ, "%s/lo_dump.index", path);
  
  		if ((pgLO->index = fopen(path, "w")) == NULL)
  		{
***************
*** 63,69 ****
  	else if (pgLO->action != ACTION_NONE)
  	{
  
! 		sprintf(path, "%s/lo_dump.index", path);
  
  		if ((pgLO->index = fopen(path, "r")) == NULL)
  		{
--- 63,69 ----
  	else if (pgLO->action != ACTION_NONE)
  	{
  
! 		snprintf(path, BUFSIZ, "%s/lo_dump.index", path);
  
  		if ((pgLO->index = fopen(path, "r")) == NULL)
  		{
Index: contrib/pg_resetxlog/pg_resetxlog.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/pg_resetxlog/pg_resetxlog.c,v
retrieving revision 1.18
diff -c -r1.18 pg_resetxlog.c
*** contrib/pg_resetxlog/pg_resetxlog.c	20 Jun 2002 20:29:24 -0000	1.18
--- contrib/pg_resetxlog/pg_resetxlog.c	12 Aug 2002 16:42:59 -0000
***************
*** 352,358 ****
  		if (strlen(xlde->d_name) == 16 &&
  			strspn(xlde->d_name, "0123456789ABCDEF") == 16)
  		{
! 			sprintf(path, "%s/%s", XLogDir, xlde->d_name);
  			if (unlink(path) < 0)
  			{
  				perror(path);
--- 352,358 ----
  		if (strlen(xlde->d_name) == 16 &&
  			strspn(xlde->d_name, "0123456789ABCDEF") == 16)
  		{
! 			snprintf(path, MAXPGPATH, "%s/%s", XLogDir, xlde->d_name);
  			if (unlink(path) < 0)
  			{
  				perror(path);
Index: contrib/pgbench/pgbench.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/pgbench/pgbench.c,v
retrieving revision 1.17
diff -c -r1.17 pgbench.c
*** contrib/pgbench/pgbench.c	20 Jul 2002 03:02:01 -0000	1.17
--- contrib/pgbench/pgbench.c	12 Aug 2002 16:42:59 -0000
***************
*** 310,335 ****
  				gettimeofday(&(st->txn_begin), 0);
  			break;
  		case 1:
! 			sprintf(sql, "update accounts set abalance = abalance + %d where aid = %d\n", st->delta, st->aid);
  			break;
  		case 2:
! 			sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
  			break;
  		case 3:
  			if (ttype == 0)
  			{
! 			    sprintf(sql, "update tellers set tbalance = tbalance + %d where tid = %d\n",
  				    st->delta, st->tid);
  			    break;
  			}
  		case 4:
  			if (ttype == 0)
  			{
! 			    sprintf(sql, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
  			    break;
  			}
  		case 5:
! 			sprintf(sql, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')",
  					st->tid, st->bid, st->aid, st->delta);
  			break;
  		case 6:
--- 310,335 ----
  				gettimeofday(&(st->txn_begin), 0);
  			break;
  		case 1:
! 			snprintf(sql, 256, "update accounts set abalance = abalance + %d where aid = %d\n", st->delta, st->aid);
  			break;
  		case 2:
! 			snprintf(sql, 256, "select abalance from accounts where aid = %d", st->aid);
  			break;
  		case 3:
  			if (ttype == 0)
  			{
! 			    snprintf(sql, 256, "update tellers set tbalance = tbalance + %d where tid = %d\n",
  				    st->delta, st->tid);
  			    break;
  			}
  		case 4:
  			if (ttype == 0)
  			{
! 			    snprintf(sql, 256, "update branches set bbalance = bbalance + %d where bid = %d", st->delta, st->bid);
  			    break;
  			}
  		case 5:
! 			snprintf(sql, 256, "insert into history(tid,bid,aid,delta,mtime) values(%d,%d,%d,%d,'now')",
  					st->tid, st->bid, st->aid, st->delta);
  			break;
  		case 6:
***************
*** 426,432 ****
  	{
  		case 0:
  			st->aid = getrand(1, naccounts * tps);
! 			sprintf(sql, "select abalance from accounts where aid = %d", st->aid);
  			break;
  	}
  
--- 426,432 ----
  	{
  		case 0:
  			st->aid = getrand(1, naccounts * tps);
! 			snprintf(sql, 256, "select abalance from accounts where aid = %d", st->aid);
  			break;
  	}
  
***************
*** 500,506 ****
  
  	for (i = 0; i < nbranches * tps; i++)
  	{
! 		sprintf(sql, "insert into branches(bid,bbalance) values(%d,0)", i + 1);
  		res = PQexec(con, sql);
  		if (PQresultStatus(res) != PGRES_COMMAND_OK)
  		{
--- 500,506 ----
  
  	for (i = 0; i < nbranches * tps; i++)
  	{
! 		snprintf(sql, 256, "insert into branches(bid,bbalance) values(%d,0)", i + 1);
  		res = PQexec(con, sql);
  		if (PQresultStatus(res) != PGRES_COMMAND_OK)
  		{
***************
*** 512,518 ****
  
  	for (i = 0; i < ntellers * tps; i++)
  	{
! 		sprintf(sql, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
  				,i + 1, i / ntellers + 1);
  		res = PQexec(con, sql);
  		if (PQresultStatus(res) != PGRES_COMMAND_OK)
--- 512,518 ----
  
  	for (i = 0; i < ntellers * tps; i++)
  	{
! 		snprintf(sql, 256, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)"
  				,i + 1, i / ntellers + 1);
  		res = PQexec(con, sql);
  		if (PQresultStatus(res) != PGRES_COMMAND_OK)
***************
*** 550,556 ****
  			PQclear(res);
  		}
  
! 		sprintf(sql, "%d\t%d\t%d\t\n", j, j / naccounts, 0);
  		if (PQputline(con, sql))
  		{
  			fprintf(stderr, "PQputline failed\n");
--- 550,556 ----
  			PQclear(res);
  		}
  
! 		snprintf(sql, 256, "%d\t%d\t%d\t\n", j, j / naccounts, 0);
  		if (PQputline(con, sql))
  		{
  			fprintf(stderr, "PQputline failed\n");
Index: contrib/rserv/rserv.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/rserv/rserv.c,v
retrieving revision 1.7
diff -c -r1.7 rserv.c
*** contrib/rserv/rserv.c	20 Jul 2002 05:16:56 -0000	1.7
--- contrib/rserv/rserv.c	12 Aug 2002 16:42:59 -0000
***************
*** 102,110 ****
  
  	if (keynum == ObjectIdAttributeNumber)
  	{
! 		sprintf(oidbuf, "%u", rel->rd_rel->relhasoids
! 		                      ? HeapTupleGetOid(tuple)
! 		                      : InvalidOid);
  		key = oidbuf;
  	}
  	else
--- 102,111 ----
  
  	if (keynum == ObjectIdAttributeNumber)
  	{
! 		snprintf(oidbuf, "%u", 64,
! 				 rel->rd_rel->relhasoids
! 		         ? HeapTupleGetOid(tuple)
! 		         : InvalidOid);
  		key = oidbuf;
  	}
  	else
***************
*** 129,135 ****
  	else
  		okey = key;
  
! 	sprintf(sql, "update _RSERV_LOG_ set logid = %d, logtime = now(), "
  			"deleted = %d where reloid = %u and key = '%s'",
  			GetCurrentTransactionId(), deleted, rel->rd_id, okey);
  
--- 130,136 ----
  	else
  		okey = key;
  
! 	snprintf(sql, 8192, "update _RSERV_LOG_ set logid = %d, logtime = now(), "
  			"deleted = %d where reloid = %u and key = '%s'",
  			GetCurrentTransactionId(), deleted, rel->rd_id, okey);
  
***************
*** 148,154 ****
  		elog(ERROR, "_rserv_log_: duplicate tuples");
  	else if (SPI_processed == 0)
  	{
! 		sprintf(sql, "insert into _RSERV_LOG_ "
  				"(reloid, logid, logtime, deleted, key) "
  				"values (%u, %d, now(), %d, '%s')",
  				rel->rd_id, GetCurrentTransactionId(),
--- 149,155 ----
  		elog(ERROR, "_rserv_log_: duplicate tuples");
  	else if (SPI_processed == 0)
  	{
! 		snprintf(sql, 8192, "insert into _RSERV_LOG_ "
  				"(reloid, logid, logtime, deleted, key) "
  				"values (%u, %d, now(), %d, '%s')",
  				rel->rd_id, GetCurrentTransactionId(),
***************
*** 173,179 ****
  		else
  			okey = newkey;
  
! 		sprintf(sql, "insert into _RSERV_LOG_ "
  				"(reloid, logid, logtime, deleted, key) "
  				"values (%u, %d, now(), 0, '%s')",
  				rel->rd_id, GetCurrentTransactionId(), okey);
--- 174,180 ----
  		else
  			okey = newkey;
  
! 		snprintf(sql, 8192, "insert into _RSERV_LOG_ "
  				"(reloid, logid, logtime, deleted, key) "
  				"values (%u, %d, now(), 0, '%s')",
  				rel->rd_id, GetCurrentTransactionId(), okey);
***************
*** 222,235 ****
  	buf[0] = 0;
  	for (xcnt = 0; xcnt < SerializableSnapshot->xcnt; xcnt++)
  	{
! 		sprintf(buf + strlen(buf), "%s%u", (xcnt) ? ", " : "",
  				SerializableSnapshot->xip[xcnt]);
  	}
  
  	if ((ret = SPI_connect()) < 0)
  		elog(ERROR, "_rserv_sync_: SPI_connect returned %d", ret);
  
! 	sprintf(sql, "insert into _RSERV_SYNC_ "
  			"(server, syncid, synctime, status, minid, maxid, active) "
  	  "values (%u, currval('_rserv_sync_seq_'), now(), 0, %d, %d, '%s')",
  			server, SerializableSnapshot->xmin, SerializableSnapshot->xmax, active);
--- 223,237 ----
  	buf[0] = 0;
  	for (xcnt = 0; xcnt < SerializableSnapshot->xcnt; xcnt++)
  	{
! 		snprintf(buf + strlen(buf), 8192 - strlen(buf),
! 				"%s%u", (xcnt) ? ", " : "",
  				SerializableSnapshot->xip[xcnt]);
  	}
  
  	if ((ret = SPI_connect()) < 0)
  		elog(ERROR, "_rserv_sync_: SPI_connect returned %d", ret);
  
! 	snprintf(sql, 8192, "insert into _RSERV_SYNC_ "
  			"(server, syncid, synctime, status, minid, maxid, active) "
  	  "values (%u, currval('_rserv_sync_seq_'), now(), 0, %d, %d, '%s')",
  			server, SerializableSnapshot->xmin, SerializableSnapshot->xmax, active);
Index: contrib/spi/refint.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/spi/refint.c,v
retrieving revision 1.19
diff -c -r1.19 refint.c
*** contrib/spi/refint.c	3 May 2002 04:11:07 -0000	1.19
--- contrib/spi/refint.c	12 Aug 2002 16:42:59 -0000
***************
*** 112,118 ****
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan.
  	 */
! 	sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &PPlans, &nPPlans);
  
  	/* if there is no plan then allocate argtypes for preparation */
--- 112,118 ----
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan.
  	 */
! 	snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &PPlans, &nPPlans);
  
  	/* if there is no plan then allocate argtypes for preparation */
***************
*** 160,169 ****
  		 * Construct query: SELECT 1 FROM _referenced_relation_ WHERE
  		 * Pkey1 = $1 [AND Pkey2 = $2 [...]]
  		 */
! 		sprintf(sql, "select 1 from %s where ", relname);
  		for (i = 0; i < nkeys; i++)
  		{
! 			sprintf(sql + strlen(sql), "%s = $%d %s",
  			  args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : "");
  		}
  
--- 160,169 ----
  		 * Construct query: SELECT 1 FROM _referenced_relation_ WHERE
  		 * Pkey1 = $1 [AND Pkey2 = $2 [...]]
  		 */
! 		snprintf(sql, 8192, "select 1 from %s where ", relname);
  		for (i = 0; i < nkeys; i++)
  		{
! 			snprintf(sql + strlen(sql), 8192 - strlen(sql), "%s = $%d %s",
  			  args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : "");
  		}
  
***************
*** 320,326 ****
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan(s).
  	 */
! 	sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &FPlans, &nFPlans);
  
  	/* if there is no plan(s) then allocate argtypes for preparation */
--- 320,326 ----
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan(s).
  	 */
! 	snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &FPlans, &nFPlans);
  
  	/* if there is no plan(s) then allocate argtypes for preparation */
***************
*** 411,417 ****
  			 */
  			if (action == 'r')
  
! 				sprintf(sql, "select 1 from %s where ", relname);
  
  			/*---------
  			 * For 'C'ascade action we construct DELETE query
--- 411,417 ----
  			 */
  			if (action == 'r')
  
! 				snprintf(sql, 8192, "select 1 from %s where ", relname);
  
  			/*---------
  			 * For 'C'ascade action we construct DELETE query
***************
*** 438,444 ****
  					char	   *nv;
  					int			k;
  
! 					sprintf(sql, "update %s set ", relname);
  					for (k = 1; k <= nkeys; k++)
  					{
  						int			is_char_type = 0;
--- 438,444 ----
  					char	   *nv;
  					int			k;
  
! 					snprintf(sql, 8192, "update %s set ", relname);
  					for (k = 1; k <= nkeys; k++)
  					{
  						int			is_char_type = 0;
***************
*** 461,467 ****
  						 * is_char_type =1 i set ' ' for define a new
  						 * value
  						 */
! 						sprintf(sql + strlen(sql), " %s = %s%s%s %s ",
  								args2[k], (is_char_type > 0) ? "'" : "",
  								nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
  						is_char_type = 0;
--- 461,468 ----
  						 * is_char_type =1 i set ' ' for define a new
  						 * value
  						 */
! 						snprintf(sql + strlen(sql), 8192 - strlen(sql),
! 								" %s = %s%s%s %s ",
  								args2[k], (is_char_type > 0) ? "'" : "",
  								nv, (is_char_type > 0) ? "'" : "", (k < nkeys) ? ", " : "");
  						is_char_type = 0;
***************
*** 471,477 ****
  				}
  				else
  /* DELETE */
! 					sprintf(sql, "delete from %s where ", relname);
  
  			}
  
--- 472,478 ----
  				}
  				else
  /* DELETE */
! 					snprintf(sql, 8192, "delete from %s where ", relname);
  
  			}
  
***************
*** 483,492 ****
  			 */
  			else if (action == 's')
  			{
! 				sprintf(sql, "update %s set ", relname);
  				for (i = 1; i <= nkeys; i++)
  				{
! 					sprintf(sql + strlen(sql), "%s = null%s",
  							args2[i], (i < nkeys) ? ", " : "");
  				}
  				strcat(sql, " where ");
--- 484,494 ----
  			 */
  			else if (action == 's')
  			{
! 				snprintf(sql, 8192, "update %s set ", relname);
  				for (i = 1; i <= nkeys; i++)
  				{
! 					snprintf(sql + strlen(sql), 8192 - strlen(sql),
! 							"%s = null%s",
  							args2[i], (i < nkeys) ? ", " : "");
  				}
  				strcat(sql, " where ");
***************
*** 495,501 ****
  			/* Construct WHERE qual */
  			for (i = 1; i <= nkeys; i++)
  			{
! 				sprintf(sql + strlen(sql), "%s = $%d %s",
  						args2[i], i, (i < nkeys) ? "and " : "");
  			}
  
--- 497,503 ----
  			/* Construct WHERE qual */
  			for (i = 1; i <= nkeys; i++)
  			{
! 				snprintf(sql + strlen(sql), 8192 - strlen(sql), "%s = $%d %s",
  						args2[i], i, (i < nkeys) ? "and " : "");
  			}
  
***************
*** 545,551 ****
  
  		relname = args[0];
  
! 		sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
  		plan = find_plan(ident, &FPlans, &nFPlans);
  		ret = SPI_execp(plan->splan[r], kvals, NULL, tcount);
  		/* we have no NULLs - so we pass   ^^^^  here */
--- 547,553 ----
  
  		relname = args[0];
  
! 		snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id);
  		plan = find_plan(ident, &FPlans, &nFPlans);
  		ret = SPI_execp(plan->splan[r], kvals, NULL, tcount);
  		/* we have no NULLs - so we pass   ^^^^  here */
Index: contrib/spi/timetravel.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/spi/timetravel.c,v
retrieving revision 1.10
diff -c -r1.10 timetravel.c
*** contrib/spi/timetravel.c	5 Nov 2001 17:46:23 -0000	1.10
--- contrib/spi/timetravel.c	12 Aug 2002 16:42:59 -0000
***************
*** 250,256 ****
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan.
  	 */
! 	sprintf(ident, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &Plans, &nPlans);
  
  	/* if there is no plan ... */
--- 250,256 ----
  	 * Construct ident string as TriggerName $ TriggeredRelationId and try
  	 * to find prepared execution plan.
  	 */
! 	snprintf(ident, 2 * NAMEDATALEN, "%s$%u", trigger->tgname, rel->rd_id);
  	plan = find_plan(ident, &Plans, &nPlans);
  
  	/* if there is no plan ... */
***************
*** 266,275 ****
  		/*
  		 * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
  		 */
! 		sprintf(sql, "INSERT INTO %s VALUES (", relname);
  		for (i = 1; i <= natts; i++)
  		{
! 			sprintf(sql + strlen(sql), "$%d%s",
  					i, (i < natts) ? ", " : ")");
  			ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
  		}
--- 266,275 ----
  		/*
  		 * Construct query: INSERT INTO _relation_ VALUES ($1, ...)
  		 */
! 		snprintf(sql, 8192, "INSERT INTO %s VALUES (", relname);
  		for (i = 1; i <= natts; i++)
  		{
! 			snprintf(sql + strlen(sql), 8192 - strlen(sql), "$%d%s",
  					i, (i < natts) ? ", " : ")");
  			ctypes[i - 1] = SPI_gettypeid(tupdesc, i);
  		}
Index: contrib/vacuumlo/vacuumlo.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/contrib/vacuumlo/vacuumlo.c,v
retrieving revision 1.12
diff -c -r1.12 vacuumlo.c
*** contrib/vacuumlo/vacuumlo.c	20 Jun 2002 20:29:24 -0000	1.12
--- contrib/vacuumlo/vacuumlo.c	12 Aug 2002 16:42:59 -0000
***************
*** 288,294 ****
  		 * Postgres-ism and not portable to other DBMSs, but then this
  		 * whole program is a Postgres-ism.
  		 */
! 		sprintf(buf, "DELETE FROM vacuum_l WHERE lo = \"%s\".\"%s\" ",
  				table, field);
  		res2 = PQexec(conn, buf);
  		if (PQresultStatus(res2) != PGRES_COMMAND_OK)
--- 288,294 ----
  		 * Postgres-ism and not portable to other DBMSs, but then this
  		 * whole program is a Postgres-ism.
  		 */
! 		snprintf(buf, BUFSIZE, "DELETE FROM vacuum_l WHERE lo = \"%s\".\"%s\" ",
  				table, field);
  		res2 = PQexec(conn, buf);
  		if (PQresultStatus(res2) != PGRES_COMMAND_OK)
