mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-04 00:02:52 -05:00 
			
		
		
		
	Simplify and merge unwanted-module drop logic in AdjustUpgrade.pm.
In be7800674 and followups, we failed to notice that there was already a better way to do it: instead of using DROP DATABASE IF EXISTS, we can check the list of existing DBs. Also, there seems no reason not to merge this into the pre-existing code for getting rid of unwanted module databases. Discussion: https://postgr.es/m/1066872.1710006597@sss.pgh.pa.us
This commit is contained in:
		
							parent
							
								
									76904eda25
								
							
						
					
					
						commit
						519443162d
					
				@ -86,7 +86,7 @@ sub adjust_database_contents
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	# remove dbs of modules known to cause pg_upgrade to fail
 | 
						# remove dbs of modules known to cause pg_upgrade to fail
 | 
				
			||||||
	# anything not builtin and incompatible should clean up its own db
 | 
						# anything not builtin and incompatible should clean up its own db
 | 
				
			||||||
	foreach my $bad_module ('test_ddl_deparse', 'tsearch2')
 | 
						foreach my $bad_module ('adminpack', 'test_ddl_deparse', 'tsearch2')
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if ($dbnames{"contrib_regression_$bad_module"})
 | 
							if ($dbnames{"contrib_regression_$bad_module"})
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
@ -94,6 +94,12 @@ sub adjust_database_contents
 | 
				
			|||||||
				"drop database contrib_regression_$bad_module");
 | 
									"drop database contrib_regression_$bad_module");
 | 
				
			||||||
			delete($dbnames{"contrib_regression_$bad_module"});
 | 
								delete($dbnames{"contrib_regression_$bad_module"});
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if ($dbnames{"regression_$bad_module"})
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								_add_st($result, 'postgres',
 | 
				
			||||||
 | 
									"drop database regression_$bad_module");
 | 
				
			||||||
 | 
								delete($dbnames{"regression_$bad_module"});
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# avoid no-path-to-downgrade-extension-version issues
 | 
						# avoid no-path-to-downgrade-extension-version issues
 | 
				
			||||||
@ -106,17 +112,6 @@ sub adjust_database_contents
 | 
				
			|||||||
			'drop extension if exists test_ext7');
 | 
								'drop extension if exists test_ext7');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	# we removed the adminpack extension in v17
 | 
					 | 
				
			||||||
	if ($old_version < 17)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		_add_st($result, 'postgres',
 | 
					 | 
				
			||||||
			'drop database if exists contrib_regression_adminpack');
 | 
					 | 
				
			||||||
		_add_st($result, 'postgres',
 | 
					 | 
				
			||||||
			'drop database if exists regression_adminpack');
 | 
					 | 
				
			||||||
		delete($dbnames{'contrib_regression_adminpack'});
 | 
					 | 
				
			||||||
		delete($dbnames{'regression_adminpack'});
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	# we removed this test-support function in v17
 | 
						# we removed this test-support function in v17
 | 
				
			||||||
	if ($old_version >= 15 && $old_version < 17)
 | 
						if ($old_version >= 15 && $old_version < 17)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user