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 1reXKG-00BuOv-Hg for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Feb 2024 09:31:09 +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 1reXKD-00CPFM-QA for pgsql-bugs@arkaria.postgresql.org; Mon, 26 Feb 2024 09:31:06 +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 1reXKD-00CPEo-DN for pgsql-bugs@lists.postgresql.org; Mon, 26 Feb 2024 09:31:06 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1reXK6-0017M1-Vn for pgsql-bugs@lists.postgresql.org; Mon, 26 Feb 2024 09:31:04 +0000 Received: from [172.30.8.38] (unknown [172.30.8.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id E3B14E20E3A; Mon, 26 Feb 2024 12:30:55 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1708939857; bh=9VumgGwgFMfZfyQiAvUrAC+Xn2X2Jcgc98Q3etAdaWU=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=yTKzW/qMqBVeeYKPB/zskI3+l/fO9cRvrUtyixMbf8le0OVhc2d7abBI3/cDHsfp2 4tul52q2R0WRn/VEpcE8WJr/JW2CsoZSIWYQtDiKBA7tmVsbo8TN5PlvGNOoYsPZ6u raEOXpSwFhSGndPjrCdMW+qEPrAUZBrsAOVFecQ6iEkt1PrKke5EUBmP2AmJPY841y mYMixM5wbAsm1pmBa+uPNnlIoPGdRI36SYYlQT3aQJgf7EI/PR0hCsf1f/pPJpeTQo HWkAwmWsRaJQX7mz927EU+htLnVEXeiRxFbwVLk7A+Ojz6gIeQTUSGe6+Qq1XT7zG/ 4ydnlDdeEDpBw== Message-ID: <00f65092-0b44-4b3b-9b66-6ebee90def3a@postgrespro.ru> Date: Mon, 26 Feb 2024 16:30:50 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: "type with xxxx does not exist" when doing ExecMemoize() Content-Language: en-US To: Tender Wang Cc: pgsql-bugs@lists.postgresql.org References: From: Andrei Lepikhov Organization: Postgres Professional 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 On 26/2/2024 15:14, Tender Wang wrote: > > > Andrei Lepikhov > 于2024年2月26日周一 10:57写道: > > On 25/2/2024 20:32, Tender Wang wrote: > > I think in prepare_probe_slot(), should called datumCopy as the > attached > > patch does. > > > > Any thoughts? Thanks. > Thanks for the report. > I think it is better to invent a Runtime Memory Context; likewise, > it is > already designed in IndexScan and derivatives. Here, you just allocate > the value in some upper memory context. > > Also, I'm curious why such a trivial error hasn't been found for a > long time > >   I analyze this issue again. I found that the forms of qual in > Memoize.sql(regress) are all like this: > >   table1.c0 OP table2.c0 > If table2.c0 is the param value, the probeslot->tts_values[i] just store > the pointer.  The memorycontext of this pointer is > ExecutorContext not ExprContext, Reset ExprContext doesn't change the > data of probeslot->tts_values[i]. > So such a trivial error hasn't been found before. I'm not happy with using table context for the probeslot values. As I see, in the case of a new entry, the cache_lookup copies data from this slot. If a match is detected, the allocated probeslot memory piece will not be freed up to hash table reset. Taking this into account, should we invent some new runtime context? -- regards, Andrei Lepikhov Postgres Professional