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 1tFagc-00E5gR-Lp for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Nov 2024 15:07:38 +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 1tFaga-00Fh96-FD for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Nov 2024 15:07:36 +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 1tFaga-00Fh8x-21 for pgsql-bugs@lists.postgresql.org; Mon, 25 Nov 2024 15:07:36 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tFagX-003i6q-B9 for pgsql-bugs@lists.postgresql.org; Mon, 25 Nov 2024 15:07:34 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 4APF7VvD1341820; Mon, 25 Nov 2024 10:07:31 -0500 From: Tom Lane To: Dean Rasheed cc: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18722: Processing arrays with plpgsql raises errors In-reply-to: References: <18722-fd9e645448cc78b4@postgresql.org> <940942.1732412520@sss.pgh.pa.us> <1211277.1732488552@sss.pgh.pa.us> Comments: In-reply-to Dean Rasheed message dated "Mon, 25 Nov 2024 10:30:23 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1341818.1732547251.1@sss.pgh.pa.us> Date: Mon, 25 Nov 2024 10:07:31 -0500 Message-ID: <1341819.1732547251@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dean Rasheed writes: > On Sun, 24 Nov 2024 at 22:49, Tom Lane wrote: >> Here's a fleshed-out patch with a test case and JIT support. This >> is about the first time I've messed with LLVM, so I wouldn't mind >> some review of what I did in llvmjit_expr.c. In particular, do I >> correctly understand that "l_funcvalue(b, v_fcinfo, 0)" produces >> a reference to a copy of the initial value of args[0].value? > I don't know about that, but I wonder if this bug could be fixed by > having ExecInitExprRec() insert a EEOP_MAKE_READONLY step. Then it > wouldn't be necessary to make any changes to the expression evaluation > code. That would entirely destroy one of the primary performance benefits of the expanded-object infrastructure. The idea is that if you have fconsumer(fproducer(...), ...) and fproducer returns a read-write pointer to an object it's built, then fconsumer should be able to take ownership of the object and use it as a local variable (possibly modifying it) without incurring any object-copying overhead. This works in any context where an intermediate expression value has a single consumer, which is most. If there are multiple consumers then we need to insert MAKE_READONLY steps for all (or all but one) of them. I overlooked EEOP_NULLIF as such a case, but I don't think there are so many more cases as to justify throwing away the concept altogether. regards, tom lane