Skip to content

Commit c6f1f66

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

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
@@ -2053,7 +2053,7 @@ typedef struct InsertStmt
20532053
OverridingKind override; /* OVERRIDING clause */
20542054
Node *execStmt; /* for INSERT ... EXECUTE */
20552055
Node *limitCount; /* used by INSERT TOP in T-SQL*/
2056-
bool isPercent; /* Used with INSERT TOP N PERCENT in T-SQL*/
2056+
LimitOption limitOption; /* limit type */
20572057
} InsertStmt;
20582058

20592059
/* ----------------------
@@ -2069,7 +2069,7 @@ typedef struct DeleteStmt
20692069
List *returningList; /* list of expressions to return */
20702070
WithClause *withClause; /* WITH clause */
20712071
Node *limitCount; /* used with DELETE TOP in T-SQL */
2072-
bool isPercent; /* Used with DELETE TOP N PERCENT in T-SQL*/
2072+
LimitOption limitOption; /* limit type */
20732073
} DeleteStmt;
20742074

20752075
/* ----------------------
@@ -2086,7 +2086,7 @@ typedef struct UpdateStmt
20862086
List *returningList; /* list of expressions to return */
20872087
WithClause *withClause; /* WITH clause */
20882088
Node *limitCount; /* used with UPDATE TOP in T-SQL */
2089-
bool isPercent; /* Used with UPDATE TOP N PERCENT in T-SQL*/
2089+
LimitOption limitOption; /* limit type */
20902090
} UpdateStmt;
20912091

20922092
/* ----------------------
@@ -2181,24 +2181,9 @@ typedef struct SelectStmt
21812181
ColumnRef *pivotCol;
21822182
Node *aggFunc;
21832183

2184-
/* These field is used only with tsql_top clause - top N [PERCENT][WITH TIES]*/
2185-
bool isPercent;
21862184
} SelectStmt;
21872185

21882186

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

22032188
/* ----------------------
22042189
* Set Operation node for post-analysis query trees

0 commit comments

Comments
 (0)