quote_ident and schemas (was Re: connectby with schema)

From: Joe Conway <mail(at)joeconway(dot)com>
To: Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: quote_ident and schemas (was Re: connectby with schema)
Date: 2002-11-22 18:19:40
Message-ID: 3DDE753C.3010909@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Masaru Sugawara wrote:
> CREATE SCHEMA ms;
> CREATE TABLE ms.test (id int4, parent_id int4, t text);
> INSERT INTO ms.test VALUES(11, null, 'aaa');
> INSERT INTO ms.test VALUES(101, 11, 'bbb');
> INSERT INTO ms.test VALUES(110, 11, 'ccc');
> INSERT INTO ms.test VALUES(111, 110, 'ddd');
> SELECT *
> FROM connectby('ms.test', 'id', 'parent_id', '101', 0, '.')
> as t(id int4, parent_id int4, level int, branch text);
>
> ERROR: Relation "ms.test" does not exist
>

I've tracked this down to the fact that connectby does a quote_ident on the
provided relname, and in quote_ident, (quote_ident_required(t)) ends up being
true. The problem will occur even with a simple query:

test=# SELECT id, parent_id FROM ms.test WHERE parent_id = '101' AND id IS NOT
NULL;
id | parent_id
----+-----------
(0 rows)
test=# SELECT id, parent_id FROM "ms.test" WHERE parent_id = '101' AND id IS
NOT NULL;
ERROR: Relation "ms.test" does not exist

But this is not the behavior for unqualified table names:

test=# select * from foo;
f1
----
1
(1 row)
test=# select * from "foo";
f1
----
1
(1 row)

Is quote_ident_required incorrectly dealing with schemas?

Thanks,

Joe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2002-11-22 18:33:50 Re: quote_ident and schemas (was Re: connectby with schema)
Previous Message snpe 2002-11-22 17:47:29 Re: nested transactions

Browse pgsql-patches by date

  From Date Subject
Next Message Joe Conway 2002-11-22 18:33:50 Re: quote_ident and schemas (was Re: connectby with schema)
Previous Message Fernando Nasser 2002-11-22 18:05:25 JDBC Emit SQLStatus for communication link errors