From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kirill Reshke <reshkekirill(at)gmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, gchen(at)s2now(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists. |
Date: | 2025-04-13 14:05:05 |
Message-ID: | 828700.1744553105@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Kirill Reshke <reshkekirill(at)gmail(dot)com> writes:
> On Sun, 13 Apr 2025 at 00:33, David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2025-04-13 14:13:31 | Re: BUG #18893: Segfault during analyze pg_database |
Previous Message | Kirill Reshke | 2025-04-13 13:09:19 | Re: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists. |