pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
4+ messages / 3 participants
[nested] [flat]

* BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
@ 2024-11-15 02:50 PG Bug reporting form <noreply@postgresql.org>
  2024-11-15 11:28 ` Re:BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios zengman <zengman@halodbtech.com>
  0 siblings, 1 reply; 4+ messages in thread

From: PG Bug reporting form @ 2024-11-15 02:50 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: zengman@halodbtech.com

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.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re:BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
  2024-11-15 02:50 BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios PG Bug reporting form <noreply@postgresql.org>
@ 2024-11-15 11:28 ` zengman <zengman@halodbtech.com>
  2024-11-18 03:09   ` Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios Michael Paquier <michael@paquier.xyz>
  0 siblings, 1 reply; 4+ messages in thread

From: zengman @ 2024-11-15 11:28 UTC (permalink / raw)
  To: pgsql-bugs <pgsql-bugs@lists.postgresql.org>; +Cc: 曾满 <zengman@halodbtech.com>

Hi everyone,


I just submitted a patch for this bug.  Please find the patch links below. 


https://commitfest.postgresql.org/51/5383/
https://www.postgresql.org/message-id/tencent_7ABF9B1F23B0C77606FC5FE3%40qq.com


Thanks,
Zeng Man
 
------------------ Original ------------------
From:  "PG Bug reporting form"<noreply@postgresql.org>;
Date:  Fri, Nov 15, 2024 10:51 AM
To:  "pgsql-bugs"<pgsql-bugs@lists.postgresql.org>; 
Cc:  "zengman"<zengman@halodbtech.com>; 
Subject:  BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios

 
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.

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
  2024-11-15 02:50 BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios PG Bug reporting form <noreply@postgresql.org>
  2024-11-15 11:28 ` Re:BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios zengman <zengman@halodbtech.com>
@ 2024-11-18 03:09   ` Michael Paquier <michael@paquier.xyz>
  2024-11-19 03:08     ` Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios zengman <zengman@halodbtech.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Michael Paquier @ 2024-11-18 03:09 UTC (permalink / raw)
  To: zengman <zengman@halodbtech.com>; +Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>

On Fri, Nov 15, 2024 at 07:28:25PM +0800, zengman wrote:
> I just submitted a patch for this bug.&nbsp; Please find the patch links below.&nbsp;
> 
> https://commitfest.postgresql.org/51/5383/
> https://www.postgresql.org/message-id/tencent_7ABF9B1F23B0C77606FC5FE3%40qq.com

Note that it is perfectly OK to create a CF entry with a thread
pointing to pgsql-bugs, as well.  What you have done is also fine, so
let's move the discussion to pgsql-hackers :)
--
Michael

Attachments:

  signature.asc (application/pgp-signature, 832B) download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios
  2024-11-15 02:50 BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios PG Bug reporting form <noreply@postgresql.org>
  2024-11-15 11:28 ` Re:BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios zengman <zengman@halodbtech.com>
  2024-11-18 03:09   ` Re: BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios Michael Paquier <michael@paquier.xyz>
@ 2024-11-19 03:08     ` zengman <zengman@halodbtech.com>
  0 siblings, 0 replies; 4+ messages in thread

From: zengman @ 2024-11-19 03:08 UTC (permalink / raw)
  To: Michael Paquier <michael@paquier.xyz>; +Cc: pgsql-bugs <pgsql-bugs@lists.postgresql.org>; 曾满 <zengman@halodbtech.com>

Hello, Michael 


Can I invite you to help me with the code review?  
This is a minor change, but it applies to all stable releases.


Thanks,
Man Zeng

 
 


On Fri, Nov 15, 2024 at 07:28:25PM +0800, zengman wrote:
> I just submitted a patch for this bug.&nbsp; Please find the patch links below.&nbsp;
> 
> https://commitfest.postgresql.org/51/5383/
> https://www.postgresql.org/message-id/tencent_7ABF9B1F23B0C77606FC5FE3%40qq.com

Note that it is perfectly OK to create a CF entry with a thread
pointing to pgsql-bugs, as well.  What you have done is also fine, so
let's move the discussion to pgsql-hackers :)
--
Michael

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2024-11-19 03:08 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-15 02:50 BUG #18710: "pg_get_viewdef" triggers assertions in special scenarios PG Bug reporting form <noreply@postgresql.org>
2024-11-15 11:28 ` zengman <zengman@halodbtech.com>
2024-11-18 03:09   ` Michael Paquier <michael@paquier.xyz>
2024-11-19 03:08     ` zengman <zengman@halodbtech.com>

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