($INBOX_DIR/description missing)  
help / color / mirror / Atom feed
From: Alvaro Herrera <[email protected]>
Subject: [PATCH 2/2] make the output generally usable, not just for datum_to_json[b]
Date: Thu, 13 Jul 2023 18:06:46 +0200

---
 src/backend/utils/adt/jsonfuncs.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index 764d48505b..a4bfa5e404 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -5705,16 +5705,10 @@ json_categorize_type(Oid typoid, bool is_jsonb,
 
 	*outfuncoid = InvalidOid;
 
-	/*
-	 * We need to get the output function for everything except date and
-	 * timestamp types, booleans, array and composite types, json and jsonb,
-	 * and non-builtin types where there's a cast to json. In this last case
-	 * we return the oid of the cast function instead.
-	 */
-
 	switch (typoid)
 	{
 		case BOOLOID:
+			*outfuncoid = F_BOOLOUT;
 			*tcategory = JSONTYPE_BOOL;
 			break;
 
@@ -5729,26 +5723,27 @@ json_categorize_type(Oid typoid, bool is_jsonb,
 			break;
 
 		case DATEOID:
+			*outfuncoid = F_DATE_OUT;
 			*tcategory = JSONTYPE_DATE;
 			break;
 
 		case TIMESTAMPOID:
+			*outfuncoid = F_TIMESTAMP_OUT;
 			*tcategory = JSONTYPE_TIMESTAMP;
 			break;
 
 		case TIMESTAMPTZOID:
+			*outfuncoid = F_TIMESTAMPTZ_OUT;
 			*tcategory = JSONTYPE_TIMESTAMPTZ;
 			break;
 
 		case JSONOID:
-			if (!is_jsonb)
-				getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
+			getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
 			*tcategory = JSONTYPE_JSON;
 			break;
 
 		case JSONBOID:
-			if (!is_jsonb)
-				getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
+			getTypeOutputInfo(typoid, outfuncoid, &typisvarlena);
 			*tcategory = is_jsonb ? JSONTYPE_JSONB : JSONTYPE_JSON;
 			break;
 
@@ -5756,9 +5751,15 @@ json_categorize_type(Oid typoid, bool is_jsonb,
 			/* Check for arrays and composites */
 			if (OidIsValid(get_element_type(typoid)) || typoid == ANYARRAYOID
 				|| typoid == ANYCOMPATIBLEARRAYOID || typoid == RECORDARRAYOID)
+			{
+				*outfuncoid = F_ARRAY_OUT;
 				*tcategory = JSONTYPE_ARRAY;
+			}
 			else if (type_is_rowtype(typoid))	/* includes RECORDOID */
+			{
+				*outfuncoid = F_RECORD_OUT;
 				*tcategory = JSONTYPE_COMPOSITE;
+			}
 			else
 			{
 				/*
-- 
2.30.2


--gwvzdwvxkrbebefn--





view thread (6+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH 2/2] make the output generally usable, not just for datum_to_json[b]
  In-Reply-To: <no-message-id-1854053@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox