Re: Create recursive view schema.name

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lele Gaifax <lele(at)metapensiero(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Create recursive view schema.name
Date: 2016-10-11 13:46:13
Message-ID: 25887.1476193573@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lele Gaifax <lele(at)metapensiero(dot)it> writes:
> I have a working recursive-CTE query, and I tried wrapping it in a view:
> reading the documentation I found the "CREATE RECURSIVE VIEW" form, so I tried
> it.

> It works as far as I use a "simple" name for the view:
> but I get an error when I create it in a specific schema:

The manual says
CREATE RECURSIVE VIEW name (columns) AS SELECT ...;
is equivalent to
CREATE VIEW name AS WITH RECURSIVE name (columns) AS (SELECT ...) SELECT columns FROM name;

I guess it could be more explicit about the fact that the implied CTE just
has the base name of the view; but since CTE names can't be qualified,
that's not that hard to guess. Short answer is that you don't qualify the
view's internal self-reference, even if you are using a schema name in the
CREATE.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message arnaud gaboury 2016-10-11 13:47:35 Re: confusion about user paring with pg_hba and pg_ident
Previous Message Adrian Klaver 2016-10-11 13:45:27 Re: confusion about user paring with pg_hba and pg_ident