addressing review

pull/7665/head
eaydingol 2024-07-31 07:41:52 +00:00
parent 8eba822bfd
commit 257c2c8a35
3 changed files with 32 additions and 1 deletions

View File

@ -4753,11 +4753,14 @@ WorkerLimitCount(Node *limitCount, Node *limitOffset, OrderByLimitReference
if (workerLimitNode != NULL && limitOffset != NULL) if (workerLimitNode != NULL && limitOffset != NULL)
{ {
Const *workerLimitConst = (Const *) workerLimitNode; Const *workerLimitConst = (Const *) workerLimitNode;
/* Only update the worker limit if the const is not null.*/
if (!workerLimitConst->constisnull) if (!workerLimitConst->constisnull)
{ {
/* Only update the worker limit if the const is not null.*/
Const *workerOffsetConst = (Const *) limitOffset; Const *workerOffsetConst = (Const *) limitOffset;
int64 workerLimitCount = DatumGetInt64(workerLimitConst->constvalue); int64 workerLimitCount = DatumGetInt64(workerLimitConst->constvalue);
/* If the offset is null, it defaults to 0 when cast to int64. */
int64 workerOffsetCount = DatumGetInt64(workerOffsetConst->constvalue); int64 workerOffsetCount = DatumGetInt64(workerOffsetConst->constvalue);
workerLimitCount = workerLimitCount + workerOffsetCount; workerLimitCount = workerLimitCount + workerOffsetCount;
workerLimitNode = (Node *) MakeIntegerConstInt64(workerLimitCount); workerLimitNode = (Node *) MakeIntegerConstInt64(workerLimitCount);

View File

@ -578,6 +578,29 @@ DEBUG: push down of limit count: 1
1 1
(1 row) (1 row)
-- check if we can correctly push the limit when it is all
SELECT l_orderkey FROM lineitem WHERE l_orderkey < 2 LIMIT all;
DEBUG: push down of limit count: ALL
l_orderkey
---------------------------------------------------------------------
1
1
1
1
1
1
(6 rows)
SELECT l_orderkey FROM lineitem WHERE l_orderkey < 2 OFFSET 2 LIMIT all;
DEBUG: push down of limit count: ALL
l_orderkey
---------------------------------------------------------------------
1
1
1
1
(4 rows)
SET client_min_messages TO NOTICE; SET client_min_messages TO NOTICE;
-- non constants should not push down -- non constants should not push down
CREATE OR REPLACE FUNCTION my_limit() CREATE OR REPLACE FUNCTION my_limit()

View File

@ -236,6 +236,11 @@ SELECT l_orderkey FROM lineitem WHERE l_orderkey < 3 ORDER BY l_orderkey OFFSET
SELECT l_orderkey FROM lineitem WHERE l_orderkey < 3 ORDER BY l_orderkey OFFSET null LIMIT 1; SELECT l_orderkey FROM lineitem WHERE l_orderkey < 3 ORDER BY l_orderkey OFFSET null LIMIT 1;
-- check if we can correctly push the limit when it is all
SELECT l_orderkey FROM lineitem WHERE l_orderkey < 2 LIMIT all;
SELECT l_orderkey FROM lineitem WHERE l_orderkey < 2 OFFSET 2 LIMIT all;
SET client_min_messages TO NOTICE; SET client_min_messages TO NOTICE;
-- non constants should not push down -- non constants should not push down