summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorAndrew Dunstan2017-02-22 16:10:49 +0000
committerAndrew Dunstan2017-02-22 16:10:49 +0000
commit502a3832cc54c7115dacb8a2dae06f0620995ac6 (patch)
tree60b620acde2bea72fabbdfad7ce02ea9ffcaec54 /src/backend
parent4c728f382970b6346142fe4409212063ee3e92dc (diff)
Correctly handle array pseudotypes in to_json and to_jsonb
Columns with array pseudotypes have not been identified as arrays, so they have been rendered as strings in the json and jsonb conversion routines. This change allows them to be rendered as json arrays, making it possible to deal correctly with the anyarray columns in pg_stats.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/utils/adt/json.c5
-rw-r--r--src/backend/utils/adt/jsonb.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index 628e9de616..0ed6a10a44 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -1397,9 +1397,10 @@ json_categorize_type(Oid typoid,
default:
/* Check for arrays and composites */
- if (OidIsValid(get_element_type(typoid)))
+ if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
+ || typoid == RECORDARRAYOID)
*tcategory = JSONTYPE_ARRAY;
- else if (type_is_rowtype(typoid))
+ else if (type_is_rowtype(typoid)) /* includes RECORDOID */
*tcategory = JSONTYPE_COMPOSITE;
else
{
diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c
index b9bf18ffe5..5b6178badf 100644
--- a/src/backend/utils/adt/jsonb.c
+++ b/src/backend/utils/adt/jsonb.c
@@ -644,9 +644,10 @@ jsonb_categorize_type(Oid typoid,
default:
/* Check for arrays and composites */
- if (OidIsValid(get_element_type(typoid)))
+ if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
+ || typoid == RECORDARRAYOID)
*tcategory = JSONBTYPE_ARRAY;
- else if (type_is_rowtype(typoid))
+ else if (type_is_rowtype(typoid)) /* includes RECORDOID */
*tcategory = JSONBTYPE_COMPOSITE;
else
{