BUG #17088: FailedAssertion in prepagg.c

The Post Office <noreply@postgresql.org>

From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: cyg0810@gmail.com
Date: 2021-07-07T06:33:07Z
Lists: pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17088
Logged by:          yaoguang chen
Email address:      cyg0810@gmail.com
PostgreSQL version: 14beta2
Operating system:   Linux supersix 5.4.0-39-generic #43-Ubuntu SMP Fri
Description:        

run the following sql command through client and the PostgreSQL database
process will crash:

CREATE TEMP TABLE v0 ( v1 INT PRIMARY KEY ) ON COMMIT DELETE ROWS ; 
SELECT FROM ( VALUES ( ( SELECT - - 84 FROM v0 LIMIT - -1 ) ) ) v1 ( v1 )
GROUP BY ROLLUP ( v1 , v1 ) , ROLLUP ( ROW ( ) , ROW ( - - - - -128 ,
6099928.000000 ) , v1 ) ORDER BY v1 = v1 AND v1 = - - ( SELECT GROUPING ( v1
) GROUP BY v1 ) ASC FETCH FIRST ROWS WITH TIES

crash log:

HINT:  Future log output will go to log destination "csvlog".
TRAP: FailedAssertion("!IsA(node, SubLink)", File:
"/home/supersix/fuzz/Squirrel/PostgreSQL/postgres/build/../src/backend/optimizer/prep/prepagg.c",
Line: 341, PID: 2310031)
postgres: supersix x 127.0.0.1(65126)
SELECT(ExceptionalCondition+0xbb)[0x562398112ffb]
postgres: supersix x 127.0.0.1(65126)
SELECT(preprocess_aggrefs+0x0)[0x562397d2da10]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x641)[0x562397c8cd01]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x7ef)[0x562397c8ceaf]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x159)[0x562397c8c819]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x159)[0x562397c8c819]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x159)[0x562397c8c819]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x832)[0x562397c8cef2]
postgres: supersix x 127.0.0.1(65126)
SELECT(expression_tree_walker+0x95)[0x562397c8c755]
postgres: supersix x 127.0.0.1(65126) SELECT(+0x592dd9)[0x562397d1bdd9]
postgres: supersix x 127.0.0.1(65126)
SELECT(subquery_planner+0xf63)[0x562397d1e8e3]
postgres: supersix x 127.0.0.1(65126)
SELECT(standard_planner+0x165)[0x562397d1f535]
postgres: supersix x 127.0.0.1(65126)
SELECT(pg_plan_query+0x6a)[0x562397ebceaa]
postgres: supersix x 127.0.0.1(65126)
SELECT(pg_plan_queries+0x4d)[0x562397ebcffd]
postgres: supersix x 127.0.0.1(65126) SELECT(+0x7359f2)[0x562397ebe9f2]
postgres: supersix x 127.0.0.1(65126)
SELECT(PostgresMain+0x1ae7)[0x562397ec0d57]
postgres: supersix x 127.0.0.1(65126) SELECT(+0x61671f)[0x562397d9f71f]
postgres: supersix x 127.0.0.1(65126)
SELECT(PostmasterMain+0x1182)[0x562397da2672]
postgres: supersix x 127.0.0.1(65126) SELECT(main+0x533)[0x562397852133]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f6aa088f0b3]
postgres: supersix x 127.0.0.1(65126) SELECT(_start+0x2e)[0x56239785228e]

Commits

  1. Fix assorted missing logic for GroupingFunc nodes.