mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-31 00:03:57 -04:00 
			
		
		
		
	This patch fixes two tiny memory leaks in pg_dump and two in pg_dumpall.
Neil Conway
This commit is contained in:
		
							parent
							
								
									cf4e603e2c
								
							
						
					
					
						commit
						3026493ff2
					
				| @ -12,7 +12,7 @@ | |||||||
|  *	by PostgreSQL |  *	by PostgreSQL | ||||||
|  * |  * | ||||||
|  * IDENTIFICATION |  * IDENTIFICATION | ||||||
|  *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.308 2002/11/23 03:59:08 momjian Exp $ |  *	  $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.309 2002/11/29 16:38:42 momjian Exp $ | ||||||
|  * |  * | ||||||
|  *------------------------------------------------------------------------- |  *------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| @ -3226,6 +3226,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo) | |||||||
| 					  "WHERE contypid = '%s'::pg_catalog.oid", | 					  "WHERE contypid = '%s'::pg_catalog.oid", | ||||||
| 					  tinfo->oid); | 					  tinfo->oid); | ||||||
| 
 | 
 | ||||||
|  | 	PQclear(res); | ||||||
| 	res = PQexec(g_conn, chkquery->data); | 	res = PQexec(g_conn, chkquery->data); | ||||||
| 	if (!res || | 	if (!res || | ||||||
| 		PQresultStatus(res) != PGRES_TUPLES_OK) | 		PQresultStatus(res) != PGRES_TUPLES_OK) | ||||||
| @ -3269,6 +3270,7 @@ dumpOneDomain(Archive *fout, TypeInfo *tinfo) | |||||||
| 	destroyPQExpBuffer(q); | 	destroyPQExpBuffer(q); | ||||||
| 	destroyPQExpBuffer(delq); | 	destroyPQExpBuffer(delq); | ||||||
| 	destroyPQExpBuffer(query); | 	destroyPQExpBuffer(query); | ||||||
|  | 	destroyPQExpBuffer(chkquery); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | |||||||
| @ -6,7 +6,7 @@ | |||||||
|  * Portions Copyright (c) 1994, Regents of the University of California |  * Portions Copyright (c) 1994, Regents of the University of California | ||||||
|  * |  * | ||||||
|  * |  * | ||||||
|  * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.10 2002/11/22 03:09:43 tgl Exp $ |  * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.11 2002/11/29 16:38:42 momjian Exp $ | ||||||
|  * |  * | ||||||
|  *------------------------------------------------------------------------- |  *------------------------------------------------------------------------- | ||||||
|  */ |  */ | ||||||
| @ -403,7 +403,7 @@ dumpCreateDB(PGconn *conn) | |||||||
| 
 | 
 | ||||||
| 	for (i = 0; i < PQntuples(res); i++) | 	for (i = 0; i < PQntuples(res); i++) | ||||||
| 	{ | 	{ | ||||||
| 		PQExpBuffer buf = createPQExpBuffer(); | 		PQExpBuffer buf; | ||||||
| 		char	   *dbname = PQgetvalue(res, i, 0); | 		char	   *dbname = PQgetvalue(res, i, 0); | ||||||
| 		char	   *dbowner = PQgetvalue(res, i, 1); | 		char	   *dbowner = PQgetvalue(res, i, 1); | ||||||
| 		char	   *dbencoding = PQgetvalue(res, i, 2); | 		char	   *dbencoding = PQgetvalue(res, i, 2); | ||||||
| @ -413,6 +413,8 @@ dumpCreateDB(PGconn *conn) | |||||||
| 		if (strcmp(dbname, "template1") == 0) | 		if (strcmp(dbname, "template1") == 0) | ||||||
| 			continue; | 			continue; | ||||||
| 
 | 
 | ||||||
|  | 		buf = createPQExpBuffer(); | ||||||
|  | 
 | ||||||
| 		if (output_clean) | 		if (output_clean) | ||||||
| 			appendPQExpBuffer(buf, "DROP DATABASE %s\n;", fmtId(dbname)); | 			appendPQExpBuffer(buf, "DROP DATABASE %s\n;", fmtId(dbname)); | ||||||
| 
 | 
 | ||||||
| @ -692,6 +694,7 @@ connectDatabase(const char *dbname, const char *pghost, const char *pgport, | |||||||
| 			exit(1); | 			exit(1); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 	PQclear(res); | ||||||
| 
 | 
 | ||||||
| 	return conn; | 	return conn; | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user