pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: linyuzhe.lyz@gmail.com
Subject: BUG #18763: pg_get_viewdef returns an old def with new relation name
Date: Thu, 02 Jan 2025 06:43:57 +0000
Message-ID: <18763-92ec491c50111041@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18763
Logged by:          lyz
Email address:      linyuzhe.lyz@gmail.com
PostgreSQL version: 13.7
Operating system:   Linux
Description:        

in first connection

test5=# create table a1(c int);
CREATE TABLE
test5=# create table a2(c int);
CREATE TABLE
test5=# create view v as select * from a1;
CREATE VIEW

then rename relation names and replace view in one txn, but not commit. 

test5=# begin;
BEGIN
test5=*# alter table a1 rename to a3;
ALTER TABLE
test5=*# alter table a2 rename to a1;
ALTER TABLE
test5=*# create or replace view v as select * from a1;
CREATE VIEW

in second connection:

test5=# select pg_get_viewdef('v');

it will be stuck by AccessShareLock of 'v'.

Then we commit txn in first connection,
the result of second connection wii be: 

 pg_get_viewdef 
----------------
  SELECT a3.c  +
    FROM a3;
(1 row)

 old definition but using new relation name.



view thread (3+ messages)  latest in thread

Message-ID: <18763-92ec491c50111041@postgresql.org>
Permalink:  ../18763-92ec491c50111041@postgresql.org/
Also on:    postgresql.org/message-id/18763-92ec491c50111041@postgresql.org

 · 

reply

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: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, linyuzhe.lyz@gmail.com
  Subject: Re: BUG #18763: pg_get_viewdef returns an old def with new relation name
  In-Reply-To: <18763-92ec491c50111041@postgresql.org>

* 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