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

Commit 4c3c4f4

Browse files
author
Nikita Glukhov
committed
Add SQL/JSON parsing
1 parent 2804aea commit 4c3c4f4

File tree

8 files changed

+931
-20
lines changed

8 files changed

+931
-20
lines changed

src/backend/nodes/makefuncs.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "fmgr.h"
2121
#include "nodes/makefuncs.h"
2222
#include "nodes/nodeFuncs.h"
23+
#include "utils/errcodes.h"
2324
#include "utils/lsyscache.h"
2425

2526

@@ -611,3 +612,56 @@ makeGroupingSet(GroupingSetKind kind, List *content, int location)
611612
n->location = location;
612613
return n;
613614
}
615+
616+
Node *
617+
makeJsonBehavior(JsonBehaviorKind kind, Node *expr)
618+
{
619+
JsonBehavior *n = makeNode(JsonBehavior);
620+
621+
n->kind = kind;
622+
n->expr = expr;
623+
624+
return (Node *) n;
625+
}
626+
627+
JsonEncoding
628+
makeJsonEncoding(char *name)
629+
{
630+
if (!pg_strcasecmp(name, "utf8"))
631+
return JS_ENC_UTF8;
632+
if (!pg_strcasecmp(name, "utf16"))
633+
return JS_ENC_UTF16;
634+
if (!pg_strcasecmp(name, "utf32"))
635+
return JS_ENC_UTF32;
636+
637+
ereport(ERROR,
638+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
639+
errmsg("unrecognized JSON encoding: %s", name)));
640+
641+
return JS_ENC_DEFAULT;
642+
}
643+
644+
Node *
645+
makeJsonKeyValue(Node *key, Node *value)
646+
{
647+
JsonKeyValue *n = makeNode(JsonKeyValue);
648+
649+
n->key = (Expr *) key;
650+
n->value = castNode(JsonValueExpr, value);
651+
652+
return (Node *) n;
653+
}
654+
655+
Node *
656+
makeJsonPredicate(Node *expr, JsonFormat format, JsonValueType vtype,
657+
bool unique_keys)
658+
{
659+
JsonIsPredicate *n = makeNode(JsonIsPredicate);
660+
661+
n->expr = expr;
662+
n->format = format;
663+
n->vtype = vtype;
664+
n->unique_keys = unique_keys;
665+
666+
return (Node *) n;
667+
}

0 commit comments

Comments
 (0)