From 5384a73f98d9829725186a7b65bf4f8adb3cfaf1 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 31 Jan 2012 11:48:23 -0500 Subject: 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. --- src/backend/commands/explain.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/backend/commands/explain.c') diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index e297e9cfb9..e35ac59030 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -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; } -- cgit v1.2.1