Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 86aba60

Browse files
author
Nikita Glukhov
committed
Add json support for JSON_TABLE
1 parent a4d4fa2 commit 86aba60

File tree

5 files changed

+1541
-15
lines changed

5 files changed

+1541
-15
lines changed

src/backend/executor/nodeTableFuncscan.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@
2323
#include "postgres.h"
2424

2525
#include "nodes/execnodes.h"
26+
#include "catalog/pg_type.h"
2627
#include "executor/executor.h"
2728
#include "executor/nodeTableFuncscan.h"
2829
#include "executor/tablefunc.h"
2930
#include "miscadmin.h"
31+
#include "nodes/nodeFuncs.h"
3032
#include "utils/builtins.h"
3133
#include "utils/jsonpath.h"
3234
#include "utils/lsyscache.h"
@@ -170,7 +172,8 @@ ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
170172

171173
/* Only XMLTABLE and JSON_TABLE are supported currently */
172174
scanstate->routine =
173-
tf->functype == TFT_XMLTABLE ? &XmlTableRoutine : &JsonbTableRoutine;
175+
tf->functype == TFT_XMLTABLE ? &XmlTableRoutine :
176+
exprType(tf->docexpr) == JSONBOID ? &JsonbTableRoutine : &JsonTableRoutine;
174177

175178
scanstate->perValueCxt =
176179
AllocSetContextCreate(CurrentMemoryContext,

src/backend/parser/parse_expr.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4712,12 +4712,6 @@ transformJsonFuncExpr(ParseState *pstate, JsonFuncExpr *func)
47124712
jsexpr->returning.typid = exprType(contextItemExpr);
47134713
jsexpr->returning.typmod = -1;
47144714

4715-
if (jsexpr->returning.typid != JSONBOID)
4716-
ereport(ERROR,
4717-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4718-
errmsg("JSON_TABLE() is not yet implemented for json type"),
4719-
parser_errposition(pstate, func->location)));
4720-
47214715
break;
47224716
}
47234717

src/include/utils/jsonpath.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ extern Datum JsonPathQuery(Datum json, JsonPath *jp, JsonWrapper wrapper,
329329

330330
extern Datum EvalJsonPathVar(void *cxt, bool *isnull);
331331

332+
extern const TableFuncRoutine JsonTableRoutine;
332333
extern const TableFuncRoutine JsonbTableRoutine;
333334

334335
#endif

0 commit comments

Comments
 (0)