postgresql/src/backend/commands
Tom Lane 862861ee77 Fix a couple of misbehaviors rooted in the fact that the default creation
namespace isn't necessarily first in the search path (there could be implicit
schemas ahead of it).  Examples are

test=# set search_path TO s1;

test=# create view pg_timezone_names as select * from pg_timezone_names();
ERROR:  "pg_timezone_names" is already a view

test=# create table pg_class (f1 int primary key);
ERROR:  permission denied: "pg_class" is a system catalog

You'd expect these commands to create the requested objects in s1, since
names beginning with pg_ aren't supposed to be reserved anymore.  What is
happening is that we create the requested base table and then execute
additional commands (here, CREATE RULE or CREATE INDEX), and that code is
passed the same RangeVar that was in the original command.  Since that
RangeVar has schemaname = NULL, the secondary commands think they should do a
path search, and that means they find system catalogs that are implicitly in
front of s1 in the search path.

This is perilously close to being a security hole: if the secondary command
failed to apply a permission check then it'd be possible for unprivileged
users to make schema modifications to system catalogs.  But as far as I can
find, there is no code path in which a check doesn't occur.  Which makes it
just a weird corner-case bug for people who are silly enough to want to
name their tables the same as a system catalog.

The relevant code has changed quite a bit since 8.2, which means this patch
wouldn't work as-is in the back branches.  Since it's a corner case no one
has reported from the field, I'm not going to bother trying to back-patch.
2007-08-27 03:36:08 +00:00
..
aggregatecmds.c Support enum data types. Along the way, use macros for the values of 2007-04-02 03:49:42 +00:00
alter.c Tsearch2 functionality migrates to core. The bulk of this work is by 2007-08-21 01:11:32 +00:00
analyze.c Make large sequential scans and VACUUMs work in a limited-size "ring" of 2007-05-30 20:12:03 +00:00
async.c RESET SESSION, plus related new DDL commands. Patch from Marko Kreen, 2007-04-12 06:53:49 +00:00
cluster.c Fix dumb compile error in the last patch. 2007-05-19 01:02:34 +00:00
comment.c Tsearch2 functionality migrates to core. The bulk of this work is by 2007-08-21 01:11:32 +00:00
conversioncmds.c Fix up foreign-key mechanism so that there is a sound semantic basis for the 2007-02-14 01:58:58 +00:00
copy.c Minor code cleanup: calling FreeFile() before ereport(ERROR) is not 2007-06-20 02:02:49 +00:00
dbcommands.c Support an optional asynchronous commit mode, in which we don't flush WAL 2007-08-01 22:45:09 +00:00
define.c Update CVS HEAD for 2007 copyright. Back branches are typically not 2007-01-05 22:20:05 +00:00
discard.c Rename the newly-added commands for discarding session state. 2007-04-26 16:13:15 +00:00
explain.c Arrange to cache a ResultRelInfo in the executor's EState for relations that 2007-08-15 21:39:50 +00:00
functioncmds.c Support enum data types. Along the way, use macros for the values of 2007-04-02 03:49:42 +00:00
indexcmds.c Fix brain fade in DefineIndex(): it was continuing to access the table's 2007-08-25 19:08:19 +00:00
lockcmds.c Update CVS HEAD for 2007 copyright. Back branches are typically not 2007-01-05 22:20:05 +00:00
Makefile Tsearch2 functionality migrates to core. The bulk of this work is by 2007-08-21 01:11:32 +00:00
opclasscmds.c Wording cleanup for error messages. Also change can't -> cannot. 2007-02-01 19:10:30 +00:00
operatorcmds.c Minimal message corrections found by spell checker. 2007-06-02 23:36:35 +00:00
portalcmds.c Modify processing of DECLARE CURSOR and EXPLAIN so that they can resolve the 2007-04-27 22:05:49 +00:00
prepare.c Separate parse-analysis for utility commands out of parser/analyze.c 2007-06-23 22:12:52 +00:00
proclang.c Allow non-superuser database owners to create procedural languages. 2007-03-26 16:58:41 +00:00
schemacmds.c Separate parse-analysis for utility commands out of parser/analyze.c 2007-06-23 22:12:52 +00:00
sequence.c Wording cleanup for error messages. Also change can't -> cannot. 2007-02-01 19:10:30 +00:00
tablecmds.c Tsearch2 functionality migrates to core. The bulk of this work is by 2007-08-21 01:11:32 +00:00
tablespace.c Support an optional asynchronous commit mode, in which we don't flush WAL 2007-08-01 22:45:09 +00:00
trigger.c Arrange to cache a ResultRelInfo in the executor's EState for relations that 2007-08-15 21:39:50 +00:00
tsearchcmds.c Suppress testing the options of CREATE TEXT SEARCH DICTIONARY during 2007-08-22 22:30:20 +00:00
typecmds.c CREATE DOMAIN ... DEFAULT NULL failed because gram.y special-cases DEFAULT 2007-06-20 18:15:49 +00:00
user.c Wording cleanup for error messages. Also change can't -> cannot. 2007-02-01 19:10:30 +00:00
vacuum.c Fix two bugs induced in VACUUM FULL by async-commit patch. 2007-08-13 19:08:26 +00:00
vacuumlazy.c Make large sequential scans and VACUUMs work in a limited-size "ring" of 2007-05-30 20:12:03 +00:00
variable.c Switch over to using the src/timezone functions for formatting timestamps 2007-08-04 01:26:54 +00:00
view.c Fix a couple of misbehaviors rooted in the fact that the default creation 2007-08-27 03:36:08 +00:00