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: zengman@halodbtech.com
Subject: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
Date: Fri, 15 Nov 2024 02:50:47 +0000
Message-ID: <18710-ceab935c95da55aa@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      18710
Logged by:          Man Zeng
Email address:      zengman@halodbtech.com
PostgreSQL version: 14.14
Operating system:   centos-8
Description:        

A prototype of the problem from
https://github.com/duckdb/pg_duckdb/issues/435
This exception can be reliably triggered by calling "pg_get_viewdef"

Step 1 :
CREATE VIEW view_a AS 
WITH RECURSIVE outermost(x) AS (
 SELECT 1
 UNION (WITH innermost1 AS (
 SELECT 2)
  SELECT * FROM outermost
  UNION SELECT * FROM innermost1)
 )
 SELECT * FROM outermost ORDER BY 1;

Step 2 :
SELECT oid FROM pg_class where relname = 'view_a';

Step 3:
SELECT pg_get_viewdef( this oid ); -- error

The abnormalities appear as follows
[postgres@iZuf6hwo0wgeev4dvua4csZ postgres]$ psql
psql (14.14)
Type "help" for help.

postgres=# CREATE VIEW view_a AS 
postgres-# WITH RECURSIVE outermost(x) AS (
postgres(#  SELECT 1
postgres(#  UNION (WITH innermost1 AS (
postgres(#  SELECT 2)
postgres(#   SELECT * FROM outermost
postgres(#   UNION SELECT * FROM innermost1)
postgres(#  )
postgres-#  SELECT * FROM outermost ORDER BY 1;
CREATE VIEW
postgres=# SELECT * FROM pg_class where relname = 'view_a';
  oid  | relname | relnamespace | reltype | reloftype | relowner | relam |
relfilenode | reltablespace | relpages | reltuples | relallvisible |
reltoastrelid | relhasindex | relisshared | relpersistence | relkind |
relnatt
s | relchecks | relhasrules | relhastriggers | relhassubclass |
relrowsecurity | relforcerowsecurity | relispopulated | relreplident |
relispartition | relrewrite | relfrozenxid | relminmxid | relacl |
reloptions | relpart
bound 
-------+---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+----------------+---------+--------
--+-----------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+----------------+------------+--------------+------------+--------+------------+--------
------
 32768 | view_a  |         2200 |   32770 |         0 |       10 |     0 |  
        0 |             0 |        0 |        -1 |             0 |          
  0 | f           | f           | p              | v       |        
1 |         0 | t           | f              | f              | f           
  | f                   | t              | n            | f              |  
       0 |            0 |          0 |        |            | 
(1 row)

postgres=# select pg_get_viewdef(32768);
TRAP: FailedAssertion("subquery->setOperations == NULL", File:
"ruleutils.c", Line: 6094, PID: 325948)
postgres: postgres postgres [local]
SELECT(ExceptionalCondition+0xb9)[0xb1a6c1]
postgres: postgres postgres [local] SELECT[0xa95d6b]
postgres: postgres postgres [local] SELECT[0xa960b5]
......

Maybe we can comment out the assertion that raises the exception, because I
looked up the code and found that the assertion doesn't seem to make a lot
of sense here.
I look forward to your discussion.



view thread (4+ messages)  latest in thread

Message-ID: <18710-ceab935c95da55aa@postgresql.org>
Permalink:  ../18710-ceab935c95da55aa@postgresql.org/
Also on:    postgresql.org/message-id/18710-ceab935c95da55aa@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, zengman@halodbtech.com
  Subject: Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
  In-Reply-To: <18710-ceab935c95da55aa@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