forked from pganalyze/libpg_query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05_limit_option_enum_value_default.patch
39 lines (35 loc) · 1.44 KB
/
05_limit_option_enum_value_default.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
commit e855d8c81a0cd73aa1913825e7b4395961e6f2c9
Author: Lukas Fittl <[email protected]>
Date: Sun Jan 3 15:57:25 2021 -0800
LimitOption: Correctly order LIMIT_OPTION_DEFAULT enum value first
This seems like an oversight in the commit that added support for
FETCH FIRST... WITH TIES, and causes the parsetree to always have
limitOption = LIMIT_OPTION_COUNT, even when no LIMIT/OFFSET is specified.
diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c
index 425fbfc405..c9089fd462 100644
--- a/src/backend/executor/nodeLimit.c
+++ b/src/backend/executor/nodeLimit.c
@@ -154,7 +154,8 @@ ExecLimit(PlanState *pstate)
if (!node->noCount &&
node->position - node->offset >= node->count)
{
- if (node->limitOption == LIMIT_OPTION_COUNT)
+ if (node->limitOption == LIMIT_OPTION_COUNT ||
+ node->limitOption == LIMIT_OPTION_DEFAULT)
{
node->lstate = LIMIT_WINDOWEND;
return NULL;
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index f8e8fe699a..13ea9cae92 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -438,9 +438,9 @@ typedef enum OnConflictAction
*/
typedef enum LimitOption
{
+ LIMIT_OPTION_DEFAULT, /* No limit present */
LIMIT_OPTION_COUNT, /* FETCH FIRST... ONLY */
LIMIT_OPTION_WITH_TIES, /* FETCH FIRST... WITH TIES */
- LIMIT_OPTION_DEFAULT, /* No limit present */
} LimitOption;
#endif /* NODES_H */