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 1qiBCg-005OZT-1i for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Sep 2023 10:10:06 +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 1qiBCc-00GZNi-Rr for pgsql-hackers@arkaria.postgresql.org; Mon, 18 Sep 2023 10:10:02 +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 1qiBCc-00GZNV-EB for pgsql-hackers@lists.postgresql.org; Mon, 18 Sep 2023 10:10:02 +0000 Received: from ewsoutbound.kpnmail.nl ([195.121.94.186]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qiBCY-005EKl-AO for pgsql-hackers@postgresql.org; Mon, 18 Sep 2023 10:10:01 +0000 X-KPN-MessageId: 81d61fe3-560b-11ee-bf57-00505699b430 Received: from smtp.kpnmail.nl (unknown [10.31.155.5]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 81d61fe3-560b-11ee-bf57-00505699b430; Mon, 18 Sep 2023 12:09:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=yrnoso8ehoBTzgzyQBa3GsfPLkL9fhnmdG0oNt0+4GU=; b=DU8lQGbpf/CM3v7CD8Bq6LdHpYgwVLvw+rH43YwWtHDQuCWb5bC6yovjEBiqJdWpPhMBugjxoGAfZ bNY9Lvtz2XhO+uJRZ2tKuedlQH52yInYYnSvOJfHs19gt910ryJUNx0L1svFH9ISnr/fl/0aFJpJ1V skooinkwPISF1Bs1rDaBf2zhN/FhShe/I9BRU3vzEOHDDoUgE1Sa50cgcOUq6HlsLb91i0N8RxZUhE Sl/qwJ+t+RxvRSoHWbWuJhtm35+14fvQPceqpG3q+Ab0EzjvWa+5C+sNH4e7opUqsglbWgMbgPsB1+ gg7xWgtNRNQUipP8zc7aWKoFlA7j8kA== X-KPN-MID: 33|pEHhYSFE56ms/iAkWcwVAqiFg1A2fPn4AG8v/+PpnoZDfgWMILlTkPYgavsI0mn k8/CdmIb3UZQNSQepbevPPP8kk7g8428duryUquRVK74= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|i/oTsMuAYMBaN95dAxNEh3d5j+hMmOE92dRPfcv448ImJG7WjCSU7v25CsULfnp vL9MFIBwH0xPNaLZxWELaGA== X-Originating-IP: 45.83.234.25 Received: from [192.168.178.31] (unknown [45.83.234.25]) by smtp.xs4all.nl (Halon) with ESMTPSA id 80a1f422-560b-11ee-ac77-00505699b758; Mon, 18 Sep 2023 12:09:54 +0200 (CEST) Message-ID: Date: Mon, 18 Sep 2023 12:12:25 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: remaining sql/json patches To: Amit Langote Cc: Alvaro Herrera , jian he , Andrew Dunstan , PostgreSQL-development References: <202309061501.xcwpfa2jjj5n@alvherre.pgsql> <6e99a906-e363-6e2e-719d-0971c2acad10@xs4all.nl> Content-Language: en-US From: Erik Rijkers 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 Op 9/18/23 om 05:15 schreef Amit Langote: > On Sun, Sep 17, 2023 at 3:34 PM Erik Rijkers wrote: >> Op 9/14/23 om 10:14 schreef Amit Langote: >>> >>> >> >> Hi Amit, >> >> Just now I built a v14-patched server and I found this crash: >> >> select json_query(jsonb ' >> { >> "arr": [ >> {"arr": [2,3]} >> , {"arr": [4,5]} >> ] >> }' >> , '$.arr[*].arr ? (@ <= 3)' returning anyarray WITH WRAPPER) --crash >> ; >> server closed the connection unexpectedly >> This probably means the server terminated abnormally >> before or while processing the request. >> connection to server was lost > > Thanks for the report. > > Attached updated version fixes the crash, but you get an error as is > to be expected: > > select json_query(jsonb ' > { > "arr": [ > {"arr": [2,3]} > , {"arr": [4,5]} > ] > }' > , '$.arr[*].arr ? (@ <= 3)' returning anyarray WITH WRAPPER); > ERROR: cannot accept a value of type anyarray > > unlike when using int[]: > > select json_query(jsonb ' > { > "arr": [ > {"arr": [2,3]} > , {"arr": [4,5]} > ] > }' > , '$.arr[*].arr ? (@ <= 3)' returning int[] WITH WRAPPER); > json_query > ------------ > {2,3} > (1 row) > Thanks, Amit. Alas, there are more: for 'anyarray' I thought I'd substitute 'interval', 'int4range', 'int8range', and sure enough they all give similar crashes. Patched with v15: psql -qX -e << SQL select json_query(jsonb'{"a":[{"a":[2,3]},{"a":[4,5]}]}', '$.a[*].a?(@<=3)'returning int[] with wrapper --ok ); select json_query(jsonb'{"a": [{"a": [2,3]}, {"a": [4,5]}]}', '$.a[*].a?(@<=3)'returning interval with wrapper --crash --'$.a[*].a?(@<=3)'returning int4range with wrapper --crash --'$.a[*].a?(@<=3)'returning int8range with wrapper --crash --'$.a[*].a?(@<=3)'returning numeric[] with wrapper --{2,3} =ok --'$.a[*].a?(@<=3)'returning anyarray with wrapper --fixed --'$.a[*].a?(@<=3)'returning anyarray --null =ok --'$.a[*].a?(@<=3)'returning int --null =ok --'$.a[*].a?(@<=3)'returning int with wrapper --error =ok --'$.a[*].a?(@<=3)'returning int[] with wrapper -- {2,3} =ok ); SQL => server closed the connection unexpectedly, etc Because those first three tries gave a crash (*all three*), I'm a bit worried there may be many more. I am sorry to be bothering you with these somewhat idiotic SQL statements but I suppose somehow it needs to be made more solid. Thanks! Erik