From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kirill Reshke <reshkekirill@gmail.com>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: gchen@s2now.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists.
Date: Sun, 13 Apr 2025 10:05:05 -0400
Message-ID: <828700.1744553105@sss.pgh.pa.us> (raw)
In-Reply-To: <CALdSSPgvZmd=Bc1n8CCuFws1uEmejbKeSQ-UpNoVyQ6AceCu7A@mail.gmail.com>
References: <18892-dc187cc800710924@postgresql.org>
<CAKFQuwaczG7zLiutpk7WzZc-8v2avugcbNq0OcLZbk+0EutWSA@mail.gmail.com>
<CALdSSPgvZmd=Bc1n8CCuFws1uEmejbKeSQ-UpNoVyQ6AceCu7A@mail.gmail.com>
Kirill Reshke <reshkekirill@gmail.com> writes:
> On Sun, 13 Apr 2025 at 00:33, David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>> Kirill's answer is correct; though it is a bit annoying that "create view" cannot detect the infinite recursion inherent in its body.
> Hm, if we can detect infinite recursion at runtime, we should also be
> able to do it definition-time, on "create or replace". Is there any
> reason we omit such a check (for recursive views/relations) when
> executing ddl?
I don't think this would be an improvement, because it would cause
errors that need not happen. For example, if the recursion is through
two views, then altering either one might be enough to remove the
problem. Refusing to create the second view is pre-judging where
the problem lies. And it's not like the run-time error is obscure.
I think this suggestion is much like the one we recently
rejected about throwing an error if the user tries to attach a
default to a view column whose underlying column is generated.
In short: "if you were to try to execute this right now, it would
fail" is not a great argument for refusing to create an object
whose behavior is intertwined with other objects.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, reshkekirill@gmail.com, david.g.johnston@gmail.com, gchen@s2now.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists.
In-Reply-To: <828700.1744553105@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox