mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Improve two error messages related to foreign keys on partitioned tables
Error messages for creating a foreign key on a partitioned table using ONLY or NOT VALID were wrong in mentioning the objects they worked on. This commit adds on the way some regression tests missing for those cases. Author: Laurenz Albe Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/c11c05810a9ed65e9b2c817a9ef442275a32fe80.camel@cybertec.at
This commit is contained in:
		@@ -7334,12 +7334,14 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
 | 
			
		||||
		if (!recurse)
 | 
			
		||||
			ereport(ERROR,
 | 
			
		||||
					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 | 
			
		||||
					 errmsg("foreign key referencing partitioned table \"%s\" must not be ONLY",
 | 
			
		||||
					 errmsg("cannot use ONLY for foreign key on partitioned table \"%s\" referencing relation \"%s\"",
 | 
			
		||||
							RelationGetRelationName(rel),
 | 
			
		||||
							RelationGetRelationName(pkrel))));
 | 
			
		||||
		if (fkconstraint->skip_validation && !fkconstraint->initially_valid)
 | 
			
		||||
			ereport(ERROR,
 | 
			
		||||
					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 | 
			
		||||
					 errmsg("cannot add NOT VALID foreign key to relation \"%s\"",
 | 
			
		||||
					 errmsg("cannot add NOT VALID foreign key on partitioned table \"%s\" referencing relation \"%s\"",
 | 
			
		||||
							RelationGetRelationName(rel),
 | 
			
		||||
							RelationGetRelationName(pkrel)),
 | 
			
		||||
					 errdetail("This feature is not yet supported on partitioned tables.")));
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user