Skip to content

Commit 3fd80cb

Browse files
committed
[BABEL-4673] Remove newly added pivot fields in fcinfo
Removed newly added pivot fields in fcinfo and set the fcinfo->context to pivot data when the FuncExpr is a bbf_pivot function Task: BABEL-4673 Signed-off-by: Yanjie Xu <[email protected]>
1 parent 6746474 commit 3fd80cb

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/backend/executor/execSRF.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ ExecMakeTableFunctionResult(SetExprState *setexpr,
204204
InitFunctionCallInfoData(*fcinfo, NULL, 0, InvalidOid, NULL, NULL);
205205
}
206206

207-
if (sql_dialect == SQL_DIALECT_TSQL && IsA(setexpr->expr, FuncExpr))
207+
/* if current FuncExpr is a bbf_pivot function, we set the fcinfo context to pivot data */
208+
if (sql_dialect == SQL_DIALECT_TSQL && IsA(setexpr->expr, FuncExpr)
209+
&& ((FuncExpr*) setexpr->expr)->pivot_parsetree != NIL
210+
&& ((FuncExpr*) setexpr->expr)->pivot_extrainfo != NIL)
208211
{
209-
fcinfo->pivot_parsetree = ((FuncExpr*) setexpr->expr)->pivot_parsetree;
210-
fcinfo->pivot_extrainfo = ((FuncExpr*) setexpr->expr)->pivot_extrainfo;
212+
fcinfo->context = (Node *) list_make2(((FuncExpr*) setexpr->expr)->pivot_parsetree, ((FuncExpr*) setexpr->expr)->pivot_extrainfo);
211213
}
212214

213215
/*

src/include/fmgr.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ typedef struct FunctionCallInfoBaseData
9292
#define FIELDNO_FUNCTIONCALLINFODATA_ISNULL 4
9393
bool isnull; /* function must set true if result is NULL */
9494
short nargs; /* # arguments actually passed */
95-
List *pivot_parsetree; /* bbf_pivot function required rewritted parsetrees */
96-
List *pivot_extrainfo; /* bbf_pivot function required aggregation function and source sql string */
97-
#define FIELDNO_FUNCTIONCALLINFODATA_ARGS 8
95+
#define FIELDNO_FUNCTIONCALLINFODATA_ARGS 6
9896
NullableDatum args[FLEXIBLE_ARRAY_MEMBER];
9997
} FunctionCallInfoBaseData;
10098

@@ -158,8 +156,6 @@ extern void fmgr_symbol(Oid functionId, char **mod, char **fn);
158156
(Fcinfo).fncollation = (Collation); \
159157
(Fcinfo).isnull = false; \
160158
(Fcinfo).nargs = (Nargs); \
161-
(Fcinfo).pivot_parsetree = NIL; \
162-
(Fcinfo).pivot_extrainfo = NIL; \
163159
} while (0)
164160

165161
/*

0 commit comments

Comments
 (0)