Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tvGkq-002x3H-FH for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 14:20:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tvGkp-002NBq-7d for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Mar 2025 14:20:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tvGir-002Jft-Eh for pgsql-hackers@lists.postgresql.org; Thu, 20 Mar 2025 14:18:14 +0000 Received: from fout-b7-smtp.messagingengine.com ([202.12.124.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tvGip-0008hN-2K for pgsql-hackers@postgresql.org; Thu, 20 Mar 2025 14:18:12 +0000 Received: from phl-compute-13.internal (phl-compute-13.phl.internal [10.202.2.53]) by mailfout.stl.internal (Postfix) with ESMTP id 7716A11401B9; Thu, 20 Mar 2025 10:18:10 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-13.internal (MEProxy); Thu, 20 Mar 2025 10:18:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm3; t=1742480290; x=1742566690; bh=8P1G9x/cD3nu5EDgst90ojEnQwJQwZ61 0Z7YLGg6PSY=; b=d5keJqgYzmy5AVIRGpi9z8jm2jxAsSGXOa/xpXpkBOYdKZpE Qq+HSYzu2guFuHsb8cH+cLgb2ISOovw1EihwpfiLC6MscGq31rD2H098jG/4LxjM RfrFpv0bDuOSfjnabAide/+xozedG/4ZDHizCAToa3l4pbLtAonYJToOTiImUKYB nfD9SkIcn2No4swJvgUsaUL5+3U5Bo6On39y1e0Mckhlkg/Q6O2LWJe4tBeotCCr WgJpz39TYeTdJS4+obz6BqG05mV56KSSLf/zZo8TK+uEGMIriDsKWp9ix/Jw2eY8 5A/10nfxOEEHvoCnxN/UZt8w1u7K38jYezRs0w== 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 :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1742480290; x= 1742566690; bh=8P1G9x/cD3nu5EDgst90ojEnQwJQwZ610Z7YLGg6PSY=; b=5 EfPzRNNY4HmFGe9XxuLs6pl2RUhCIToEXFEhVzKDsUu1zH3I7kKqDLiDrFeIde1B wsis06Rrv5Lk92lgWcGEIplisUJpvwZwdHXOfPwjc3Pr0Ld3SXCUIkYTgQ8gza59 TFTM0N5+nX4d405sApSEpHvutp3D56+qULJTIDnkEaMQV0SbZFaA1qrPzCFZ7W8L 5dKxVSEyEg0oDsqauydHncgu68qe4ux40RDWIGdp46ybqQXXLKYLIyX9jBHLQwN4 6G+dbcCzpM0wY2Tg5XnxRmIrD8Yp6Osl0+U/AQTfoSSwPZGSw+oiAqHZj5SgV4zY x7VD9szTFwfp/CjrbDgcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddugeekgeefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpih gvnhhtshculddquddttddmnecujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddt vdejnecuhfhrohhmpefrvghtvghrucfgihhsvghnthhrrghuthcuoehpvghtvghrsegvih hsvghnthhrrghuthdrohhrgheqnecuggftrfgrthhtvghrnhepfeetueefkeetteeuvdev gfffjeejvdetgeeijeekueejkeeuffefgfevffeuheefnecuffhomhgrihhnpehpghgtrd gsvghsthenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhm pehpvghtvghrsegvihhsvghnthhrrghuthdrohhrghdpnhgspghrtghpthhtohepkedpmh houggvpehsmhhtphhouhhtpdhrtghpthhtoheprghlvgigrghnughrrgdrfigrnhhgrdho shhssehgmhgrihhlrdgtohhmpdhrtghpthhtohepmhgrrhhkrdguihhlghgvrhesvghnth gvrhhprhhishgvuggsrdgtohhmpdhrtghpthhtohepmhgrthhhvghushhsshhilhhvleej sehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghnughrvgifseguuhhnshhlrghnvgdrnh gvthdprhgtphhtthhopehglhhukhhhohhvrdhnrdgrsehgmhgrihhlrdgtohhmpdhrtghp thhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhgpdhrtg hpthhtohepuggrvhhiugesjhhushhtrghthhgvohhrhidrtghomhdprhgtphhtthhopehj ihgrnhdruhhnihhvvghrshgrlhhithihsehgmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 20 Mar 2025 10:18:08 -0400 (EDT) Message-ID: <74e042f1-ea7b-4cd2-9ba0-87984e3bb947@eisentraut.org> Date: Thu, 20 Mar 2025 15:18:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: SQL:2023 JSON simplified accessor support To: Alexandra Wang , Mark Dilger Cc: Matheus Alcantara , Andrew Dunstan , Nikita Glukhov , PostgreSQL Hackers , "David E. Wheeler" , jian he References: <21fa36b4-6d56-4556-b524-9e3955b922c8@eisentraut.org> Content-Language: en-US From: Peter Eisentraut In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This patch set has expanded significantly in scope recently, which is probably the right thing, but that means there won't be enough time to review and finish it for PG18. So I'm moving this to the next commitfest now. On 13.03.25 15:02, Alexandra Wang wrote: > Hi Mark, > > Thank you so much for reviewing! I have attached the new patches. > > On Tue, Mar 4, 2025 at 8:05 AM Mark Dilger > wrote: > > > On Mon, Mar 3, 2025 at 12:23 PM Alexandra Wang > > > wrote: > >  I've attached v10, which addresses your feedback. > > > Hi Alex!  Thanks for the patches. > > In src/test/regress/sql/jsonb.sql, the section marked with "-- > slices are not supported" should be relabeled.  That comment > predates these patches, and is now misleading. > > A bit further down in expected/jsonb.out, there is an expected > failure, but no SQL comment to indicate that it is expected: > > +SELECT (t.jb).* FROM test_jsonb_dot_notation; > +ERROR:  missing FROM-clause entry for table "t" > +LINE 1: SELECT (t.jb).* FROM test_jsonb_dot_notation; > > Perhaps a "-- fails" comment would clarify?  Then, further down, > > > Fixed. > > +SELECT (jb).a.**.x FROM test_jsonb_dot_notation; -- not supported > +ERROR:  syntax error at or near "**" > +LINE 1: SELECT (jb).a.**.x FROM test_jsonb_dot_notation; > > I wonder if it would be better to have the parser handle this case > and raise a ERRCODE_FEATURE_NOT_SUPPORTED instead? > > > In 0008 I added a new token named "DOUBLE_ASTERISK" to the lexers to > represent "**". Hope this helps! > > I got curious about the support for this new dot notation in the > plpgsql parser and tried: > > +DO $$ > +DECLARE > +  a jsonb := '[1,2,3,4,5,6,7]'::jsonb; > +BEGIN > +  WHILE a IS NOT NULL > +  LOOP > +    RAISE NOTICE '%', a; > +    a := a[2:]; > +  END LOOP; > +END > +$$ LANGUAGE plpgsql; > +NOTICE:  [1, 2, 3, 4, 5, 6, 7] > +NOTICE:  [3, 4, 5, 6, 7] > +NOTICE:  [5, 6, 7] > +NOTICE:  7 > > which looks good!  But then I tried: > > +DO $$ > +DECLARE > +  a jsonb := '{"": 6, "NU": [{"": [[3]]}, [6], [2], "bCi"], "aaf": > [-6, -8]}'::jsonb; > +BEGIN > +  WHILE a IS NOT NULL > +  LOOP > +    RAISE NOTICE '%', a; > +    a := COALESCE(a."NU", a[2]); > +  END LOOP; > +END > +$$ LANGUAGE plpgsql; > +NOTICE:  {"": 6, "NU": [{"": [[3]]}, [6], [2], "bCi"], "aaf": [-6, -8]} > +ERROR:  missing FROM-clause entry for table "a" > +LINE 1: a := COALESCE(a."NU", a[2]) > +                      ^ > +QUERY:  a := COALESCE(a."NU", a[2]) > +CONTEXT:  PL/pgSQL function inline_code_block line 8 at assignment > > which suggests the plpgsql parser does not recognize a."NU" as we'd > expect.  Any thoughts on this? > > > Thanks for the tests! I added them to the "jsonb" regress test. > > I notice there are no changes in src/interfaces/ecpg/test, which > concerns me.  The sqljson.pgc and sqljson_jsontable.pgc files are > already testing json handling in ecpg; perhaps just extend those a bit? > > Thanks for bringing this up! I have added new tests in src/interfaces/ > ecpg/test/sql/sqljson.pgc. > > > Best, > Alex