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.96) (envelope-from ) id 1wpfzY-001mRG-1I for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2026 05:41:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wpfzX-00EbSI-17 for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Jul 2026 05:41:07 +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.96) (envelope-from ) id 1wpfzW-00EbSA-1Y for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2026 05:41:07 +0000 Received: from fhigh-a7-smtp.messagingengine.com ([103.168.172.158]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wpfzU-00000001Big-0xev for pgsql-bugs@lists.postgresql.org; Fri, 31 Jul 2026 05:41:05 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id C347B140010D; Fri, 31 Jul 2026 01:41:02 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-05.internal (MEProxy); Fri, 31 Jul 2026 01:41:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=partin.io; 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=1785476462; x=1785562862; bh=NMA4NqeoFbuGlbjI+ILq+9i1ntVWUkoN08GjJ0qfaws=; b= K1EDH9B79yJx0Coo7i8yLz75yh4usp6M4kF8fM2/ohaLRY4HZSp6LSYEEunNqEOt korjEs5RTQqI3owEzsb7IRrjBTQ2+O9fp+llXZJd8J1iaGWqPonyRufWU2YjzMtN 7+BNA89S3UkaZD9GTw2jxzQ0bh1oWR1fo2VJdzx8X6PpTHIJqLvtlI5E1e8poEWf e1JvedSxZqO2z/zxM5ztdA431ziY0jxiBnml+O1Xvr/eGat9q5KZdz2QF2+HS5FR VpPIECQB5U4tzjwYWtUltY94SvWEvq1NstTZF1Kpv6hW5mAsTsqtOJzgS4ZpF7zv r07jX+f20ulzFwJfU9QyhQ== 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=fm2; t=1785476462; x= 1785562862; bh=NMA4NqeoFbuGlbjI+ILq+9i1ntVWUkoN08GjJ0qfaws=; b=S RxK/9l0yLBbmFlupWaLV1mWBsAc477cCEskeYVIPO7mbPix4MAFpgrlFxfHGpn2J JFrpE/hO2ggEPqaDwwUXYNm+GAtVTh/DybZhMshDSgQ/9u+2tU6I0pKK0gRpWXp7 3UPFWTRhDUOaX6oQ0ygsyWbhKXuNee+fTLT9/ehEBbaShG1E/m10Ufxkxsu/oqDP BYmlQLX0Q3vAiihCpXR8bPyjSIC76DBl7kxdiN5jtsg1HXzZsvt08ydDVeLFq1rn xLnGplnx6D3+fejjaNqNyIV47P+0coFrIh9XN6BmHASrMfrSTqp0Rf2s9yYZ2bi5 +AmrW3uUOc+sc5YON3IZQ== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTG1AmkRUOIX++BQemrH5i/lLQFruRQJTI2p0VhxE78QaaBXpXgCHylVDLXNk+usZr sJBYKZDriQgd3I4ZvZ02arwWawGgM698ZRSYOU3brNBv1I+NLElzeJ/CVevyrvCWziJno3 WNpnTDEWGjaDrQeYSjxv71SdFNEG5ULvhxXsUZhj/hRClJdSLavOQdQ5CwUcNMqIROyVy/ vAcrRsEZJndKVUeIHeIFIv85Z74trlBd/W5SgwjAMcTWLIYAf7yR2OS36ZKMlkOmeWY1NV BVBqAk8Gzyq46B8G6WYHpf9Jgim90Vc6fmHlRDMIikioqrRNPq0Jvt7jh8Y2/EbYl9IoBs 4Iu3rkgKV/a+VOXfjtQnUwNmeGFUmpWYVA0ciVVyWgxjQx2C696OO+nR0yWuvR5wZVv7Vo dYCbyfzCg7I4CnfVb7PNvaWxkohOyOEtLW9eoKweiG5OZCedwfL6zZyeiQA/wpfKcCKXnJ HURvNI1+9N0Wukd6pyDR8bhoSAis4xm78Dk7238iMCt3udl6mH5BiU4z627Nx9r9nLarlW KBh9awi21fd7SqKuzKQfFjUnr0Q+F2RdeF211Ew1tNXTZpgv9TdCcjXuTkqbKvxvwOXiQT QW9J/0GQtxLkLbOVbpu6WEhyPxjqE/fir25BczOXqUs+CcHEKVh47pqQKAsw X-ME-Proxy: Feedback-ID: idd01497b:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 920FE780070; Fri, 31 Jul 2026 01:41:02 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 31 Jul 2026 05:41:01 +0000 Message-Id: Cc: Subject: Re: BUG #19589: JSON_QUERY rejects domain-over-bytea input when using FORMAT JSON ENCODING UTF8. To: From: "Tristan Partin" X-Mailer: aerc 0.22.0 References: <19589-edd0b3b861601fef@postgresql.org> In-Reply-To: <19589-edd0b3b861601fef@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu Jul 30, 2026 at 1:40 PM CDT, PG Bug reporting form wrote: > The following bug has been logged on the website: > > Bug reference: 19589 > Logged by: Yuxiao Guo > Email address: dllggyx@outlook.com > PostgreSQL version: 18.4 > Operating system: Ubuntu 20.04 x86-64, docker image postgres:18.4 > Description: =20 > > Query A and Query B are equivalent, but while JSON_QUERY(... FORMAT JSON > ENCODING UTF8 ...) accepts a direct bytea input, it incorrectly rejects a > domain-over-bytea input with the error JSON ENCODING clause is only allow= ed > for bytea input type. > > PoC: > > ```sql > CREATE DOMAIN d_json_bytea AS bytea; > > -- Query A > SELECT JSON_QUERY(convert_to(txt, 'utf8') FORMAT JSON ENCODING UTF8, '$')= AS > j > FROM (VALUES ('[1,2]')) AS src(txt); > > -- Query B > SELECT JSON_QUERY(b FORMAT JSON ENCODING UTF8, '$') AS j > FROM ( > SELECT convert_to(txt, 'utf8')::d_json_bytea AS b > FROM ( > SELECT txt > FROM ( > SELECT '[1,2]'::text AS txt > UNION ALL > SELECT '[9,9]'::text WHERE false > ) AS u > WHERE txt LIKE '[%' > ) AS filtered > ) AS typed; > > ``` > > Result of Query A: > j > -------- > [1, 2] > (1 row) > > Result of Query B: > ERROR: JSON ENCODING clause is only allowed for bytea input type > LINE 1: SELECT JSON_QUERY(b FORMAT JSON ENCODING UTF8, '$') AS j Thanks for the report. I am currently taking a look at this. I have=20 reproduced the issue and am working on a fix. --=20 Tristan Partin PostgreSQL Contributors Team AWS (https://aws.amazon.com)