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 1qX4qM-0054Xh-EF for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Aug 2023 19:09:10 +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 1qX4qK-00DIBZ-Ch for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Aug 2023 19:09:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qX4qK-00DIBK-25 for pgsql-hackers@lists.postgresql.org; Fri, 18 Aug 2023 19:09:08 +0000 Received: from anastigmatix.net ([68.171.216.17]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qX4qD-000uaK-Bs for pgsql-hackers@postgresql.org; Fri, 18 Aug 2023 19:09:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: Message-ID:References:In-Reply-To:Subject:Cc:To:From:Date:MIME-Version:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FAvCb8Zp6FUXCnylLIRrG26tDRE+0kCa49lnXGHHku8=; b=J8+UpIez5g5hiBsf6cutFF1Dkx d9ZGgGLPOVHbt7ZS8/pyhm5yh7Mz2LIgbRuuVJdNF+3UszdNr4HBru8S/Z4JkKUoIIvFgNrL36kx7 tmiMlNXMFLojJgNE9aXddZVzTkOMx1O7nGvPxzNqWSPxLrLECBPN9+3OTHdtn5dl+UHIbiWz7przM OA68yZE0yVsagGf/xxVF/8h3ayyqtK8hnlVKPmOfO7euBFfIiBQJyRJPvopulorsXsB5Ip0mhCXbU qyXZWBxj+MIuTVeC7yMaHV5x5hGr9aQkMBIPDsl8slyt5ALeQ/y9o2e2zIhkWDzkNalc2JgP0SJD8 BU/Bgi0A==; Received: from [::1] (port=58252 helo=adam.ace-host.net) by adam.ace-host.net with esmtpa (Exim 4.96) (envelope-from ) id 1qX4q9-001AiD-1p; Fri, 18 Aug 2023 15:08:58 -0400 MIME-Version: 1.0 Date: Fri, 18 Aug 2023 15:08:57 -0400 From: Chapman Flack To: Andy Fan Cc: jian he , Pavel Stehule , Tom Lane , pgsql-hackers Subject: Re: Extract numeric filed in JSONB more effectively In-Reply-To: <111272f2dc112c7becdd35ad89f6b935@anastigmatix.net> References: <3507485.1691090027@sss.pgh.pa.us> <900892914fdc3f477b101d699efb40e0@anastigmatix.net> <903341.1692022214@sss.pgh.pa.us> <4b97f1a1dd9b6e45443d24870d3be698@anastigmatix.net> <111272f2dc112c7becdd35ad89f6b935@anastigmatix.net> User-Agent: Roundcube Webmail/1.6.0 Message-ID: X-Sender: chap@anastigmatix.net Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - adam.ace-host.net X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: adam.ace-host.net: authenticated_id: chap@anastigmatix.net X-Authenticated-Sender: adam.ace-host.net: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-08-18 14:50, Chapman Flack wrote: > Now, my guess is EXPLAIN is complaining when it sees the Const > of type internal, and doesn't know how to show that value. > Perhaps makeRelabelType is the answer there, too: what if the > Const has Oid type, so EXPLAIN can show it, and what's inserted > as the function argument is a relabel node saying it's internal? Simply changing the Const to be of type Oid makes EXPLAIN happy, and nothing ever says "hey, why are you passing this oid for an arg that wants internal?". This is without adding any relabel nodes anywhere. Seq Scan on pg_temp.test_jsonb Output: pg_catalog.jsonb_array_element_type('23'::oid, test_json, 0), (test_json -> 0) Filter: (test_jsonb.json_type = 'scalarint'::text) Nothing in that EXPLAIN output to make you think anything weird was going on, unless you went and looked up jsonb_array_element_type and saw that its arg0 isn't oid and its return type isn't int4. But I don't know that adding relabel nodes wouldn't still be the civilized thing to do. Regards, -Chap