aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/ruleutils.c
diff options
context:
space:
mode:
authorAndrew Dunstan <andrew@dunslane.net>2022-03-05 08:07:15 -0500
committerAndrew Dunstan <andrew@dunslane.net>2022-03-31 15:45:24 -0400
commit49082c2cc3d8167cca70cfe697afb064710828ca (patch)
tree004b744b04f1014bf82634f08ea62f98e6e619f7 /src/backend/utils/adt/ruleutils.c
parentad43a413c4f7f5d024a5b2f51e00d280a22f1874 (diff)
downloadpostgresql-49082c2cc3d8167cca70cfe697afb064710828ca.tar.gz
postgresql-49082c2cc3d8167cca70cfe697afb064710828ca.zip
RETURNING clause for JSON() and JSON_SCALAR()
This patch is extracted from a larger patch that allowed setting the default returned value from these functions to json or jsonb. That had problems, but this piece of it is fine. For these functions only json or jsonb can be specified in the RETURNING clause. Extracted from an original patch from Nikita Glukhov Reviewers have included (in no particular order) Andres Freund, Alexander Korotkov, Pavel Stehule, Andrew Alsup, Erik Rijkers, Zihong Yu, Himanshu Upadhyaya, Daniel Gustafsson, Justin Pryzby. Discussion: https://postgr.es/m/cd0bb935-0158-78a7-08b5-904886deac4b@postgrespro.ru
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r--src/backend/utils/adt/ruleutils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 010d5a7a751..4458d2ff90a 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -10092,8 +10092,9 @@ get_json_constructor_options(JsonConstructorExpr *ctor, StringInfo buf)
if (ctor->unique)
appendStringInfoString(buf, " WITH UNIQUE KEYS");
- if (ctor->type != JSCTOR_JSON_PARSE &&
- ctor->type != JSCTOR_JSON_SCALAR)
+ if (!((ctor->type == JSCTOR_JSON_PARSE ||
+ ctor->type == JSCTOR_JSON_SCALAR) &&
+ ctor->returning->typid == JSONOID))
get_json_returning(ctor->returning, buf, true);
}