citusdata / citusdata/citus

Select with intersect & union all from reference table (assertion) crashes at ruleutils

Open
#4,093 0 comments 0 reactions 0 assignees View on GitHub
bug vanilla test
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

```sql
CREATE TABLE INT8_TBL(q1 int8, q2 int8);
SELECT create_reference_table('INT8_TBL');
(((
SELECT q1 FROM int8_tbl
INTERSECT
SELECT q2 FROM int8_tbl ORDER BY 1
)))
UNION ALL
SELECT q2 FROM int8_tbl;
```

Above select crashes due to assertion failure with below backtrace:

```c
#2 0x0000000000aae380 in ExceptionalCondition (conditionName=0x7f5ffa87d158 "!(subquery->setOperations == ((void *)0))",
errorType=0x7f5ffa87ca81 "FailedAssertion", fileName=0x7f5ffa87caf1 "deparser/ruleutils_12.c", lineNumber=2573) at assert.c:54
#3 0x00007f5ffa7cf8dd in get_setop_query (setOp=0x1df7a68, query=0x1de7220, context=0x7ffeb0977df0, resultDesc=0x0) at deparser/ruleutils_12.c:2573
#4 0x00007f5ffa7cfa80 in get_setop_query (setOp=0x1df7a10, query=0x1de7220, context=0x7ffeb0977df0, resultDesc=0x0) at deparser/ruleutils_12.c:2625
#5 0x00007f5ffa7cebff in get_select_query_def (query=0x1de7220, context=0x7ffeb0977df0, resultDesc=0x0) at deparser/ruleutils_12.c:2150
#6 0x00007f5ffa7ce64a in get_query_def_extended (query=0x1de7220, buf=0x1e09bd8, parentnamespace=0x0, distrelid=0, shardid=0, resultDesc=0x0,
prettyFlags=0, wrapColumn=0, startIndent=0) at deparser/ruleutils_12.c:1964
#7 0x00007f5ffa7ce48c in get_query_def (query=0x1de7220, buf=0x1e09bd8, parentnamespace=0x0, resultDesc=0x0, prettyFlags=0, wrapColumn=0, startIndent=0)
at deparser/ruleutils_12.c:1907
#8 0x00007f5ffa7cb2d4 in pg_get_query_def (query=0x1de7220, buffer=0x1e09bd8) at deparser/ruleutils_12.c:457
#9 0x00007f5ffa8099db in DeparseTaskQuery (task=0x1e08420, query=0x1de7220) at planner/deparse_shard_query.c:499
#10 0x00007f5ffa809b20 in TaskQueryString (task=0x1e08420) at planner/deparse_shard_query.c:564
#11 0x00007f5ffa7e833d in ExecuteLocalTaskListExtended (taskList=0x1e31590, orig_paramListInfo=0x0, distributedPlan=0x1e06ee8, defaultTupleDest=0x1e31300,
isUtilityCommand=false) at executor/local_executor.c:281
#12 0x00007f5ffa7dcd23 in RunLocalExecution (scanState=0x1d73270, execution=0x1e31338) at executor/adaptive_executor.c:825
#13 0x00007f5ffa7dcb52 in AdaptiveExecutor (scanState=0x1d73270) at executor/adaptive_executor.c:751
#14 0x00007f5ffa7e1f53 in CitusExecScan (node=0x1d73270) at executor/citus_custom_scan.c:224
#15 0x0000000000732cc9 in ExecCustomScan (pstate=0x1d73270) at nodeCustom.c:116
#16 0x000000000071a5d6 in ExecProcNodeFirst (node=0x1d73270) at execProcnode.c:445
#17 0x000000000070f414 in ExecProcNode (node=0x1d73270) at ../../../src/include/executor/executor.h:239
#18 0x0000000000711c4f in ExecutePlan (estate=0x1d72f28, planstate=0x1d73270, use_parallel_mode=false, operation=CMD_SELECT, sendTuples=true,
numberTuples=0, direction=ForwardScanDirection, dest=0x1e097d8, execute_once=true) at execMain.c:1646
#19 0x000000000070fa51 in standard_ExecutorRun (queryDesc=0x1cb0c58, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:364
#20 0x00007f5ffa7ea6e7 in CitusExecutorRun (queryDesc=0x1cb0c58, direction=ForwardScanDirection, count=0, execute_once=true)
at executor/multi_executor.c:202
#21 0x000000000070f874 in ExecutorRun (queryDesc=0x1cb0c58, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:306
#22 0x0000000000924d35 in PortalRunSelect (portal=0x1cf87d8, forward=true, count=0, dest=0x1e097d8) at pquery.c:929
#23 0x0000000000924969 in PortalRun (portal=0x1cf87d8, count=9223372036854775807, isTopLevel=true, run_once=true, dest=0x1e097d8, altdest=0x1e097d8,
completionTag=0x7ffeb0978690 "") at pquery.c:770
#24 0x000000000091e5b4 in exec_simple_query (
query_string=0x1c1fae8 "(((\n SELECT q1 FROM int8_tbl\n INTERSECT\n SELECT q2 FROM int8_tbl ORDER BY 1\n)))\nUNION ALL\nSELECT q2 FROM int8_tbl;")
at postgres.c:1215
#25 0x0000000000922a7c in PostgresMain (argc=1, argv=0x1cb9578, dbname=0x1cb93b8 "postgres", username=0x1cb9390 "postgres") at postgres.c:4247
#26 0x00000000008713bd in BackendRun (port=0x1c3b9f0) at postmaster.c:4448
#27 0x0000000000870b06 in BackendStartup (port=0x1c3b9f0) at postmaster.c:4139
#28 0x000000000086cc46 in ServerLoop () at postmaster.c:1704
#29 0x000000000086c46d in PostmasterMain (argc=3, argv=0x1c1a760) at postmaster.c:1377
#30 0x00000000007850f7 in main (argc=3, argv=0x1c1a760) at main.c:228
```

And if we disable assertions, we get no errors nor warnings.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.