mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Fix incorrect permissions check in information_schema.key_column_usage view:
it was checking a pg_constraint OID instead of pg_class OID, resulting in "relation with OID nnnnn does not exist" failures for anyone who wasn't owner of the table being examined. Per bug #2848 from Laurence Rowe. Note: for existing 8.2 installations a simple version update won't fix this; the easiest fix is to CREATE OR REPLACE this view with the corrected definition.
This commit is contained in:
		@@ -4,7 +4,7 @@
 | 
				
			|||||||
 *
 | 
					 *
 | 
				
			||||||
 * Copyright (c) 2003-2006, PostgreSQL Global Development Group
 | 
					 * Copyright (c) 2003-2006, PostgreSQL Global Development Group
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.38 2006/11/10 18:10:10 tgl Exp $
 | 
					 * $PostgreSQL: pgsql/src/backend/catalog/information_schema.sql,v 1.38.2.1 2007/01/16 18:32:32 tgl Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
@@ -964,10 +964,10 @@ CREATE VIEW key_column_usage AS
 | 
				
			|||||||
                AND r.relkind = 'r'
 | 
					                AND r.relkind = 'r'
 | 
				
			||||||
                AND (NOT pg_is_other_temp_schema(nr.oid))
 | 
					                AND (NOT pg_is_other_temp_schema(nr.oid))
 | 
				
			||||||
                AND (pg_has_role(r.relowner, 'USAGE')
 | 
					                AND (pg_has_role(r.relowner, 'USAGE')
 | 
				
			||||||
                     OR has_table_privilege(c.oid, 'SELECT')
 | 
					                     OR has_table_privilege(r.oid, 'SELECT')
 | 
				
			||||||
                     OR has_table_privilege(c.oid, 'INSERT')
 | 
					                     OR has_table_privilege(r.oid, 'INSERT')
 | 
				
			||||||
                     OR has_table_privilege(c.oid, 'UPDATE')
 | 
					                     OR has_table_privilege(r.oid, 'UPDATE')
 | 
				
			||||||
                     OR has_table_privilege(c.oid, 'REFERENCES')) ) AS ss
 | 
					                     OR has_table_privilege(r.oid, 'REFERENCES')) ) AS ss
 | 
				
			||||||
    WHERE ss.roid = a.attrelid
 | 
					    WHERE ss.roid = a.attrelid
 | 
				
			||||||
          AND a.attnum = (ss.x).x
 | 
					          AND a.attnum = (ss.x).x
 | 
				
			||||||
          AND NOT a.attisdropped;
 | 
					          AND NOT a.attisdropped;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user