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

Commit 7c1dd5f

Browse files
author
Nikita Glukhov
committed
Add json support for JSON_TABLE
1 parent 11bea7b commit 7c1dd5f

File tree

5 files changed

+1568
-12
lines changed

5 files changed

+1568
-12
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"
@@ -164,7 +166,8 @@ ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
164166

165167
/* Only XMLTABLE and JSON_TABLE are supported currently */
166168
scanstate->routine =
167-
tf->functype == TFT_XMLTABLE ? &XmlTableRoutine : &JsonbTableRoutine;
169+
tf->functype == TFT_XMLTABLE ? &XmlTableRoutine :
170+
exprType(tf->docexpr) == JSONBOID ? &JsonbTableRoutine : &JsonTableRoutine;
168171

169172
scanstate->perValueCxt =
170173
AllocSetContextCreate(CurrentMemoryContext,

src/backend/parser/parse_expr.c

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

4734-
if (jsexpr->returning.typid != JSONBOID)
4735-
ereport(ERROR,
4736-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
4737-
errmsg("JSON_TABLE() is not yet implemented for json type"),
4738-
parser_errposition(pstate, func->location)));
4739-
47404734
break;
47414735
}
47424736

src/include/utils/jsonpath.h

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

315315
extern Datum EvalJsonPathVar(void *cxt, bool *isnull);
316316

317+
extern const TableFuncRoutine JsonTableRoutine;
317318
extern const TableFuncRoutine JsonbTableRoutine;
318319

319320
#endif

0 commit comments

Comments
 (0)