mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	In psql, avoid leaking a PGresult after a query is cancelled.
After a query cancel, the tail end of ExecQueryAndProcessResults took care to clear any not-yet-read PGresults; but it forgot about the one it has already read. There would only be such a result when handling a multi-command string made with "\;", so that you'd have to cancel an earlier command in such a string to reach the bug at all. Even then, there would only be leakage of a single PGresult per cancel, so it's not surprising nobody noticed this. But a leak is a leak. Noted while re-reviewing90f517821, but this is independent of that: it dates to7844c9918. Back-patch to v15 where that came in.
This commit is contained in:
		@@ -1662,6 +1662,8 @@ ExecQueryAndProcessResults(const char *query,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if (cancel_pressed)
 | 
							if (cancel_pressed)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								/* drop this next result, as well as any others not yet read */
 | 
				
			||||||
 | 
								ClearOrSaveResult(result);
 | 
				
			||||||
			ClearOrSaveAllResults();
 | 
								ClearOrSaveAllResults();
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user