Skip to content

Commit 8208629

Browse files
author
Herambh Shah
committed
Added limitOption
Signed-off-by: Herambh Shah <[email protected]>
1 parent b7885bd commit 8208629

File tree

3 files changed

+5
-19
lines changed

3 files changed

+5
-19
lines changed

src/backend/parser/analyze.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1445,7 +1445,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
14451445
qry->commandType = CMD_SELECT;
14461446

14471447
/* Transform query if percent Operator is present with Top Clause */
1448-
if(transform_percent_clause_hook && stmt->limitCount != NULL)
1448+
if(transform_percent_clause_hook)
14491449
{
14501450
(*transform_percent_clause_hook)(pstate, stmt);
14511451
}

src/include/nodes/nodes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ typedef enum LimitOption
429429
{
430430
LIMIT_OPTION_COUNT, /* FETCH FIRST... ONLY */
431431
LIMIT_OPTION_WITH_TIES, /* FETCH FIRST... WITH TIES */
432+
LIMIT_OPTION_PERCENT, /* FETCH FIRST... PERCENT */
432433
} LimitOption;
433434

434435
#endif /* NODES_H */

src/include/nodes/parsenodes.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ typedef struct InsertStmt
20512051
OverridingKind override; /* OVERRIDING clause */
20522052
Node *execStmt; /* for INSERT ... EXECUTE */
20532053
Node *limitCount; /* used by INSERT TOP in T-SQL*/
2054-
bool isPercent; /* Used with INSERT TOP N PERCENT in T-SQL*/
2054+
LimitOption limitOption; /* limit type */
20552055
} InsertStmt;
20562056

20572057
/* ----------------------
@@ -2067,7 +2067,7 @@ typedef struct DeleteStmt
20672067
List *returningList; /* list of expressions to return */
20682068
WithClause *withClause; /* WITH clause */
20692069
Node *limitCount; /* used with DELETE TOP in T-SQL */
2070-
bool isPercent; /* Used with DELETE TOP N PERCENT in T-SQL*/
2070+
LimitOption limitOption; /* limit type */
20712071
} DeleteStmt;
20722072

20732073
/* ----------------------
@@ -2084,7 +2084,7 @@ typedef struct UpdateStmt
20842084
List *returningList; /* list of expressions to return */
20852085
WithClause *withClause; /* WITH clause */
20862086
Node *limitCount; /* used with UPDATE TOP in T-SQL */
2087-
bool isPercent; /* Used with UPDATE TOP N PERCENT in T-SQL*/
2087+
LimitOption limitOption; /* limit type */
20882088
} UpdateStmt;
20892089

20902090
/* ----------------------
@@ -2179,24 +2179,9 @@ typedef struct SelectStmt
21792179
ColumnRef *pivotCol;
21802180
Node *aggFunc;
21812181

2182-
/* These field is used only with tsql_top clause - top N [PERCENT][WITH TIES]*/
2183-
bool isPercent;
21842182
} SelectStmt;
21852183

21862184

2187-
/*
2188-
* This node is used in gram-tsql-rule.y to store limitCount and Percent op information.
2189-
* Furthuremore, through this node, we are updating limitCount and isPercent( Added for supporing tsql Percent Op) fields
2190-
* in SelectStmt, UpdateStmt, DeleteStmt, InsertStmt
2191-
*/
2192-
typedef struct TopClause
2193-
{
2194-
NodeTag type; /* type tag */
2195-
Node *limitCount; /* expression for the limit count/percent */
2196-
bool isPercent; /* true if PERCENT specified */
2197-
} TopClause;
2198-
2199-
22002185

22012186
/* ----------------------
22022187
* Set Operation node for post-analysis query trees

0 commit comments

Comments
 (0)