From: | Gang Chen <gchen(at)s2now(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | 回复: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists. |
Date: | 2025-04-14 08:55:04 |
Message-ID: | KL1PR03MB80701C89409607AF0B339330E5B32@KL1PR03MB8070.apcprd03.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Hello,
But isn't that kind of strange? If it's just a very simple view, first of all, referencing itself would result in an infinite recursion error. Also, it doesn't seem to have any practical use. Secondly, during pg_upgrade or backup and restore processes, it might introduce unnecessary errors and additional handling procedures.
Regards,
Gavin
________________________________
发件人: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
发送时间: 2025年4月13日 3:32
收件人: Gang Chen <gchen(at)s2now(dot)com>; pgsql-bugs(at)lists(dot)postgresql(dot)org <pgsql-bugs(at)lists(dot)postgresql(dot)org>
主题: Re: BUG #18892: When the view already exists, CREATE OR REPLACE VIEW does not check whether the table exists.
You don't often get email from david(dot)g(dot)johnston(at)gmail(dot)com(dot) Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
On Sat, Apr 12, 2025 at 11:59 AM PG Bug reporting form <noreply(at)postgresql(dot)org<mailto:noreply(at)postgresql(dot)org>> wrote:
The following bug has been logged on the website:
Bug reference: 18892
Logged by: Gavin
Email address: gchen(at)s2now(dot)com<mailto:gchen(at)s2now(dot)com>
PostgreSQL version: 16.8
Operating system: Red Hat Enterprise Linux release 9.5
Description:
However, as demonstrated in my test demo, when
the view already exists, running CREATE OR REPLACE VIEW does not check
whether the table exists.
Because of the whole shared namespace setup it would be impossible for a table of that name to exist when executing the "or replace" branch since the view being replaced occupies that name within the namespace. Any check for an actual table would return false. And "or replace" only happens if a view of that name exists.
Kirill's answer is correct; though it is a bit annoying that "create view" cannot detect the infinite recursion inherent in its body.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Robins Tharakan | 2025-04-14 09:18:32 | Re: BUG #18893: Segfault during analyze pg_database |
Previous Message | PG Bug reporting form | 2025-04-14 06:08:13 | BUG #18894: values of JLC_COLLATE and LC_CTYPE in the database have changed from Japanese_Japan.932 to ja-jp |