mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Install a more future-proof fix for the snapshot-unset bug just found.
Per suggestion from Tom Lane.
This commit is contained in:
		@@ -10,7 +10,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * IDENTIFICATION
 | 
					 * IDENTIFICATION
 | 
				
			||||||
 *	  $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5.2.2 2005/11/28 13:34:10 alvherre Exp $
 | 
					 *	  $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.5.2.3 2005/11/28 17:23:12 alvherre Exp $
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 *-------------------------------------------------------------------------
 | 
					 *-------------------------------------------------------------------------
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
@@ -495,6 +495,9 @@ process_whole_db(void)
 | 
				
			|||||||
	/* Start a transaction so our commands have one to play into. */
 | 
						/* Start a transaction so our commands have one to play into. */
 | 
				
			||||||
	StartTransactionCommand();
 | 
						StartTransactionCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						 /* functions in indexes may want a snapshot set */
 | 
				
			||||||
 | 
						ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dbRel = heap_open(DatabaseRelationId, AccessShareLock);
 | 
						dbRel = heap_open(DatabaseRelationId, AccessShareLock);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Must use a table scan, since there's no syscache for pg_database */
 | 
						/* Must use a table scan, since there's no syscache for pg_database */
 | 
				
			||||||
@@ -556,6 +559,9 @@ do_autovacuum(PgStat_StatDBEntry *dbentry)
 | 
				
			|||||||
	/* Start a transaction so our commands have one to play into. */
 | 
						/* Start a transaction so our commands have one to play into. */
 | 
				
			||||||
	StartTransactionCommand();
 | 
						StartTransactionCommand();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						 /* functions in indexes may want a snapshot set */
 | 
				
			||||||
 | 
						ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * StartTransactionCommand and CommitTransactionCommand will automatically
 | 
						 * StartTransactionCommand and CommitTransactionCommand will automatically
 | 
				
			||||||
	 * switch to other contexts.  We need this one to keep the list of
 | 
						 * switch to other contexts.  We need this one to keep the list of
 | 
				
			||||||
@@ -898,14 +904,6 @@ autovacuum_do_vac_analyze(List *relids, bool dovacuum, bool doanalyze,
 | 
				
			|||||||
	vacstmt->relation = NULL;	/* all tables, or not used if relids != NIL */
 | 
						vacstmt->relation = NULL;	/* all tables, or not used if relids != NIL */
 | 
				
			||||||
	vacstmt->va_cols = NIL;
 | 
						vacstmt->va_cols = NIL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Functions in indexes may want a snapshot set.  Note we only need
 | 
					 | 
				
			||||||
	 * to do this in limited cases, because it'll be done in vacuum()
 | 
					 | 
				
			||||||
	 * otherwise.
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	if (doanalyze && !dovacuum && relids != NIL)
 | 
					 | 
				
			||||||
		ActiveSnapshot = CopySnapshot(GetTransactionSnapshot());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	vacuum(vacstmt, relids);
 | 
						vacuum(vacstmt, relids);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pfree(vacstmt);
 | 
						pfree(vacstmt);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user