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

Commit 388b432

Browse files
author
Nikita Glukhov
committed
JSON_TABLE for json type
1 parent 3f08b9f commit 388b432

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"
@@ -165,7 +167,8 @@ ExecInitTableFuncScan(TableFuncScan *node, EState *estate, int eflags)
165167

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

170173
scanstate->perTableCxt =
171174
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
@@ -342,6 +342,7 @@ extern Datum JsonPathQuery(Datum json, JsonPath *jp, JsonWrapper wrapper,
342342

343343
extern Datum EvalJsonPathVar(void *cxt, bool *isnull);
344344

345+
extern const TableFuncRoutine JsonTableRoutine;
345346
extern const TableFuncRoutine JsonbTableRoutine;
346347

347348
#endif

0 commit comments

Comments
 (0)