Skip to content

Commit

Permalink
Added hook to move identity function at the end of target list
Browse files Browse the repository at this point in the history
Task: BABEL-4388

Signed-off-by: Deepakshi Mittal <[email protected]>
  • Loading branch information
deepakshi-mittal committed Nov 7, 2023
1 parent a0d7401 commit 3ccfb87
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/backend/parser/analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ pre_transform_setop_sort_clause_hook_type pre_transform_setop_sort_clause_hook =
/* Hooks for transform TSQL pivot clause in select stmt */
transform_pivot_clause_hook_type transform_pivot_clause_hook = NULL;

/* Hook to transform target list to move identity function at the end of target list*/
bbf_rewrite_targetlist_hook_type bbf_rewrite_targetlist_hook = NULL;

static Query *transformOptionalSelectInto(ParseState *pstate, Node *parseTree);
static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt);
static Query *transformInsertStmt(ParseState *pstate, InsertStmt *stmt);
Expand Down Expand Up @@ -1413,6 +1416,8 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
/* process the FROM clause */
transformFromClause(pstate, stmt->fromClause);

if(sql_dialect == SQL_DIALECT_TSQL && bbf_rewrite_targetlist_hook)
(*bbf_rewrite_targetlist_hook)(stmt->targetList);
/* transform targetlist */
qry->targetList = transformTargetList(pstate, stmt->targetList,
EXPR_KIND_SELECT_TARGET);
Expand Down
4 changes: 4 additions & 0 deletions src/include/parser/analyze.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ extern PGDLLIMPORT pre_transform_setop_sort_clause_hook_type pre_transform_setop
typedef void (*transform_pivot_clause_hook_type)(ParseState *pstate, SelectStmt *stmt);
extern PGDLLIMPORT transform_pivot_clause_hook_type transform_pivot_clause_hook;

/* Hook to transform target list to move identity function at the end of target list*/
typedef void (*bbf_rewrite_targetlist_hook_type)(List *targetList);
extern PGDLLIMPORT bbf_rewrite_targetlist_hook_type bbf_rewrite_targetlist_hook;

extern Query *parse_analyze_fixedparams(RawStmt *parseTree, const char *sourceText,
const Oid *paramTypes, int numParams, QueryEnvironment *queryEnv);
extern Query *parse_analyze(RawStmt *parseTree, const char *sourceText,
Expand Down

0 comments on commit 3ccfb87

Please sign in to comment.