Re: BUG #8405: user can create a system table(eg, pg_class)

From: Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>
To: syxjxia(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8405: user can create a system table(eg, pg_class)
Date: 2013-08-28 15:27:11
Message-ID: 521E16CF.3040200@vmware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 28.08.2013 05:01, syxjxia(at)gmail(dot)com wrote:
> postgres=# create table pg_class(a int);
> CREATE TABLE
> postgres=# insert into pg_class values (1);
> ERROR: null value in column "relnamespace" violates not-null constraint
> DETAIL: Failing row contains (1, null, null, null, null, null, null, null,
> null, null, null, null, null, null, null, null, null, null, null, null,
> null, null, null, null, null, null, null).

That's not a bug. The table created is in the public schema, while all
the system tables are in pg_catalog schema. Yes, it's possible to create
a table in another schema with the same name. To avoid hijacking
applications that access the system tables, pg_catalog is implicitly in
front of search_path, if it's not listed there explicitly. So when you
do the insert, it refers to pg_catalog.pg_class.

- Heikki

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Pius Chan 2013-08-28 21:14:09 FW: BUG #8404: JDBC block hot standby replication?
Previous Message Andres Freund 2013-08-28 13:21:45 Re: BUG #7494: WAL replay speed depends heavily on the shared_buffers size