typedef struct JsonTableExecContext { int magic; JsonTablePlanState *rootplanstate; JsonTablePlanState **colexprplans; } JsonTableExecContext;
imho, this kind of naming is kind of inconsistent. "state" and "plan" are mixed together. maybe typedef struct JsonTableExecContext { int magic; JsonTablePlanState *rootplanstate; JsonTablePlanState **colexprstates; } JsonTableExecContext; + cxt->colexprplans = palloc(sizeof(JsonTablePlanState *) * + list_length(tf->colvalexprs)); + /* Initialize plan */ - cxt->rootplanstate = JsonTableInitPlan(cxt, rootplan, args, + cxt->rootplanstate = JsonTableInitPlan(cxt, (Node *) rootplan, NULL, args, CurrentMemoryContext); I think, the comments "Initialize plan" is not right, here we initialize the rootplanstate (JsonTablePlanState) and also for each (no ordinality) columns, we also initialized the specific JsonTablePlanState. static void JsonTableRescan(JsonTablePlanState *planstate); @@ -331,6 +354,9 @@ static Datum JsonTableGetValue(TableFuncScanState *state, int colnum, Oid typid, int32 typmod, bool *isnull); static void JsonTableDestroyOpaque(TableFuncScanState *state); static bool JsonTablePlanNextRow(JsonTablePlanState *planstate); +static bool JsonTablePlanPathNextRow(JsonTablePlanState *planstate); +static void JsonTableRescan(JsonTablePlanState *planstate); JsonTableRescan included twice?