Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions src/planner/agg_bookend.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ build_first_last_path(PlannerInfo *root, FirstLastAggInfo *fl_info, Oid eqop, Oi
{
ListCell *prev = NULL;
ListCell *next = list_head(subroot->append_rel_list);
Assert(rte->inh);
rte->inh = false;
/* query planner gets confused when entries in the
* append_rel_list refer to entries in the relarray that
Expand Down Expand Up @@ -757,17 +756,6 @@ build_first_last_path(PlannerInfo *root, FirstLastAggInfo *fl_info, Oid eqop, Oi

final_rel = query_planner(subroot, first_last_qp_callback, NULL);

/* we need to disable inheritance so the chunks are re-expanded correctly in the subroot */
foreach (lc, root->parse->rtable)
{
RangeTblEntry *rte = lfirst_node(RangeTblEntry, lc);

if (ts_rte_is_hypertable(rte))
{
rte->inh = true;
}
}

/*
* Since we didn't go through subquery_planner() to handle the subquery,
* we have to do some of the same cleanup it would do, in particular cope
Expand Down
28 changes: 28 additions & 0 deletions test/expected/agg_bookends-15.out
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
-> Seq Scan on _hyper_1_4_chunk (actual rows=1.00 loops=1)
-> Seq Scan on _hyper_1_5_chunk (actual rows=1.00 loops=1)

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

:PREFIX SELECT last(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
--- QUERY PLAN ---
Expand Down Expand Up @@ -940,6 +951,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
2 | 35.3
2 | 35.3

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
first
-------


:PREFIX SELECT last(temp, time) FROM ONLY btest;
last
------


-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
first
Expand Down Expand Up @@ -1132,6 +1154,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down Expand Up @@ -1252,6 +1277,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down
28 changes: 28 additions & 0 deletions test/expected/agg_bookends-16.out
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
-> Seq Scan on _hyper_1_4_chunk (actual rows=1.00 loops=1)
-> Seq Scan on _hyper_1_5_chunk (actual rows=1.00 loops=1)

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

:PREFIX SELECT last(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
--- QUERY PLAN ---
Expand Down Expand Up @@ -940,6 +951,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
2 | 35.3
2 | 35.3

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
first
-------


:PREFIX SELECT last(temp, time) FROM ONLY btest;
last
------


-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
first
Expand Down Expand Up @@ -1132,6 +1154,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down Expand Up @@ -1252,6 +1277,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down
28 changes: 28 additions & 0 deletions test/expected/agg_bookends-17.out
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
-> Seq Scan on _hyper_1_4_chunk (actual rows=1.00 loops=1)
-> Seq Scan on _hyper_1_5_chunk (actual rows=1.00 loops=1)

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

:PREFIX SELECT last(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
--- QUERY PLAN ---
Expand Down Expand Up @@ -890,6 +901,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
2 | 35.3
2 | 35.3

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
first
-------


:PREFIX SELECT last(temp, time) FROM ONLY btest;
last
------


-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
first
Expand Down Expand Up @@ -1082,6 +1104,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down Expand Up @@ -1202,6 +1227,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down
28 changes: 28 additions & 0 deletions test/expected/agg_bookends-18.out
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
-> Seq Scan on _hyper_1_4_chunk (actual rows=1.00 loops=1)
-> Seq Scan on _hyper_1_5_chunk (actual rows=1.00 loops=1)

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

:PREFIX SELECT last(temp, time) FROM ONLY btest;
--- QUERY PLAN ---
Aggregate (actual rows=1.00 loops=1)
-> Seq Scan on btest (actual rows=0.00 loops=1)

-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
--- QUERY PLAN ---
Expand Down Expand Up @@ -890,6 +901,17 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
2 | 35.3
2 | 35.3

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
first
-------


:PREFIX SELECT last(temp, time) FROM ONLY btest;
last
------


-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
first
Expand Down Expand Up @@ -1082,6 +1104,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down Expand Up @@ -1202,6 +1227,9 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
:PREFIX SELECT first(temp, time) FROM btest WHERE time >= '2017-01-20 09:00:47';
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;
-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;
-- test constants
:PREFIX SELECT first(100, 100) FROM btest;
-- create an index so we can test optimization
Expand Down
4 changes: 4 additions & 0 deletions test/sql/include/agg_bookends_query.sql
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ INSERT INTO btest_numeric VALUES('2020-01-20T09:00:43', 30.5);
-- can't do index scan when using WINDOW function
:PREFIX SELECT gp, last(temp, time) OVER (PARTITION BY gp) AS last FROM btest;

-- parent-only scan
:PREFIX SELECT first(temp, time) FROM ONLY btest;
:PREFIX SELECT last(temp, time) FROM ONLY btest;

-- test constants
:PREFIX SELECT first(100, 100) FROM btest;

Expand Down
Loading