quote_ident and schemas (was Re: connectby with schema) - Mailing list pgsql-hackers

From Joe Conway
Subject quote_ident and schemas (was Re: connectby with schema)
Date
Msg-id 3DDE753C.3010909@joeconway.com
Whole thread Raw
In response to connectby with schema  (Masaru Sugawara <rk73@sea.plala.or.jp>)
Responses Re: quote_ident and schemas (was Re: connectby with schema)  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: snpe
Date:
Subject: Re: nested transactions
Next
From: Joe Conway
Date:
Subject: Re: quote_ident and schemas (was Re: connectby with schema)