1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

Built-in JSON data type.

Like the XML data type, we simply store JSON data as text, after checking
that it is valid.  More complex operations such as canonicalization and
comparison may come later, but this is enough for not.

There are a few open issues here, such as whether we should attempt to
detect UTF-8 surrogate pairs represented as \uXXXX\uYYYY, but this gets
the basic framework in place.
This commit is contained in:
Robert Haas
2012-01-31 11:48:23 -05:00
parent 4c6cedd1b0
commit 5384a73f98
11 changed files with 1059 additions and 5 deletions

View File

@ -242,7 +242,7 @@ ExplainResultDesc(ExplainStmt *stmt)
{
TupleDesc tupdesc;
ListCell *lc;
bool xml = false;
Oid result_type = TEXTOID;
/* Check for XML format option */
foreach(lc, stmt->options)
@ -253,7 +253,12 @@ ExplainResultDesc(ExplainStmt *stmt)
{
char *p = defGetString(opt);
xml = (strcmp(p, "xml") == 0);
if (strcmp(p, "xml") == 0)
result_type = XMLOID;
else if (strcmp(p, "json") == 0)
result_type = JSONOID;
else
result_type = TEXTOID;
/* don't "break", as ExplainQuery will use the last value */
}
}
@ -261,7 +266,7 @@ ExplainResultDesc(ExplainStmt *stmt)
/* Need a tuple descriptor representing a single TEXT or XML column */
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, "QUERY PLAN",
xml ? XMLOID : TEXTOID, -1, 0);
result_type, -1, 0);
return tupdesc;
}