Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIsAd-0004qY-Ca for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 14:47:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qIsAc-0000bL-8U for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Jul 2023 14:47:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qIsAb-0000bC-VR for pgsql-hackers@lists.postgresql.org; Mon, 10 Jul 2023 14:47:21 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qIsAY-003IQ9-LW for pgsql-hackers@postgresql.org; Mon, 10 Jul 2023 14:47:21 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 751D632004E7; Mon, 10 Jul 2023 10:47:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Mon, 10 Jul 2023 10:47:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1689000434; x= 1689086834; bh=qjkZJBzHWNe48rDnQEvFmrIZ92tIi15dkpv7/Nib5Yc=; b=n OcIAw3+p/ieVYj5lZPLgj6Y/0JYXCZYE/hqUNn2sLeagwEvQjfboqbuWIY5t5Oxv IU/cgHHiwtqk0itCiH7GRqRK3b4aIE/qJzzMGHGtCOmF8tR2Ys+gcMRVEZzl715Z uYmMxCtBjLRY80nOLfsv8nGqHtSiclpJbNAgvhc5zGzjj0GiPn15SKoC0YjUEDIy j4ZlA+prFaIJEyEWIOhDdXLdh0vH0+RTYt69jXRftFmztFL/ZrRGWHYScQC/fo/p y5qv75DRZUP95sIpr4FhTMj6EpONHa8TxSeEfYHPmKj5OtdrjyFDqe66A/smLgEw ZU+AWFSar28UOdF96Es+g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrvdekgdejudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 10 Jul 2023 10:47:14 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id C5AEA9D; Mon, 10 Jul 2023 16:47:12 +0200 (CEST) Date: Mon, 10 Jul 2023 16:47:12 +0200 From: Alvaro Herrera To: Amit Langote Cc: PostgreSQL-development Subject: Re: remaining sql/json patches Message-ID: <20230710144712.7xih2h5dry3uiydp@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Jul-10, Amit Langote wrote: > > I see that you add json_returning_clause_opt, but we already have > > json_output_clause_opt. Shouldn't these two be one and the same? > > I think the new name is more sensible than the old one, since the > > governing keyword is RETURNING; I suppose naming it "output" comes from > > the fact that the standard calls this . > > One difference between the two is that json_output_clause_opt allows > specifying the FORMAT clause in addition to the RETURNING type name, > while json_returning_clause_op only allows specifying the type name. > > I'm inclined to keep only json_returning_clause_opt as you suggest and > make parse_expr.c output an error if the FORMAT clause is specified in > JSON() and JSON_SCALAR(), so turning the current syntax error on > specifying RETURNING ... FORMAT for these functions into a parsing > error. Done that way in the attached updated patch and also updated > the latter patch that adds JSON_EXISTS() and JSON_VALUE() to have > similar behavior. Yeah, that's reasonable. > > I'm not in love with the fact that JSON and JSONB have pretty much > > parallel type categorizing functionality. It seems entirely artificial. > > Maybe this didn't matter when these were contained inside each .c file > > and nobody else had to deal with that, but I think it's not good to make > > this an exported concept. Is it possible to do away with that? I mean, > > reduce both to a single categorization enum, and a single categorization > > API. Here you have to cast the enum value to int in order to make > > ExecInitExprRec work, and that seems a bit lame; moreso when the > > "is_jsonb" is determined separately (cf. ExecEvalJsonConstructor) > > OK, I agree that a unified categorizing API might be better. I'll > look at making this better. Btw, does src/include/common/jsonapi.h > look like an appropriate place for that? Hmm, that header is frontend-available, and the type-category appears to be backend-only, so maybe no. Perhaps jsonfuncs.h is more apropos? execExpr.c is already dealing with array internals, so having to deal with json internals doesn't seem completely out of place. > > In the 2023 standard, JSON_SCALAR is just > > > > ::= JSON_SCALAR > > > > but we seem to have added a clause to it. Should > > we really? > > Hmm, I am not seeing in the rule for JSON_SCALAR, Agh, yeah, I confused myself, sorry. > Per what I wrote above, the grammar for JSON() and JSON_SCALAR() does > not allow specifying the FORMAT clause. Though considering what you > wrote, the RETURNING clause does appear to be an extension to the > standard's spec. Hmm, I see that (which is RETURNING plus optional FORMAT) appears included in JSON_OBJECT, JSON_ARRAY, JSON_QUERY, JSON_SERIALIZE, JSON_OBJECTAGG, JSON_ARRAYAGG. It's not necessarily a bad thing to have it in other places, but we should consider it carefully. Do we really want/need it in JSON() and JSON_SCALAR()? -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/