Regclass and quoted table names

From: Emmanuel Cecchet <manu(at)asterdata(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Regclass and quoted table names
Date: 2009-03-04 02:47:23
Message-ID: 49ADEBBB.2010108@asterdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

It looks like the behavior of regclass is not consistent when table
names are quoted. The name is returned without the quotes if the name is
lower case with eventual trailing numbers, otherwise it is returned with
quotes.
See some examples here:

tpch=# CREATE VIEW test AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "test1" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "'test2'" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "testcolumnVIEW" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "testcolumnview" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW testcolumnVIEW2 AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "1test" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "1test2abc" AS SELECT * FROM customer;
CREATE VIEW
tpch=# CREATE VIEW "1test2" AS SELECT * FROM customer;
CREATE VIEW
tpch=# select c.oid , c.oid::regclass from pg_class c where c.relname
like '%test%';
oid | oid
-------+------------------
16410 | test
16413 | test1
16416 | "'test2'"
16419 | "testcolumnVIEW"
16422 | testcolumnview
16425 | testcolumnview2
16428 | "1test2abc"
16431 | "1test2"
16434 | "1test"
(9 rows)

Is this a bug?
manu

--
Emmanuel Cecchet
Aster Data Systems
Web: http://www.asterdata.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-03-04 03:10:21 Re: Regclass and quoted table names
Previous Message Fujii Masao 2009-03-04 02:06:43 Re: Immediate shutdown and system(3)