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 1tdbD3-008NtW-2U for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Jan 2025 20:32:21 +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 1tdbD2-00D75H-1N for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Jan 2025 20:32:20 +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 1tdbD1-00D74m-OM for pgsql-hackers@lists.postgresql.org; Thu, 30 Jan 2025 20:32:19 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tdbCz-002LfL-21 for pgsql-hackers@lists.postgresql.org; Thu, 30 Jan 2025 20:32:18 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-aaeec07b705so210812866b.2 for ; Thu, 30 Jan 2025 12:32:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738269135; x=1738873935; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Cp5UJG597aMgJO/f2Vwslor5bRsoU75rrelM0JIh/Lw=; b=JnH8gKBsI8cSQQDQ1+1CuExqua+5ps+KChBxvQM8GTl0J9bA321n/2D+Ulq0IrscNp ptmAdFHGxqON6QU4bFDsjeLmiZoMzFMGkgMc92682Enryb3hmjesWGCHCLNtJJmaa1mz BAZp+aSQTHHFugmK8fyUNgbzDKuFN8i/63sGvfcDvUR5mIRH9FTryVmMrKumK0nlAv6I g3P2dcGEyKA1ZlFASmnPFobbIGuVOMbhQKpZEVBpn0pHjyCyysitzHdL+nG5JmWeAstt DmgJonuQrUGG0aSCXBqufWTFZBaDClOgXge46srH/YcR+3RsR3I4Gs0HdR8fyiJWkAjo 9OHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738269135; x=1738873935; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Cp5UJG597aMgJO/f2Vwslor5bRsoU75rrelM0JIh/Lw=; b=kZ2K3RjgToKPM3lOYJGcdHLLD/qgK905HCS/zffOHdCaIz9EZ/sxAZ+hZe3YFGT1ug UulWAmtA5Fx1b041i3awgkAcKG3QemS5kanASrYEbQJHKjesgVAMI5+i5tAWmwRvFYeM OWaF+s/io1YH+iNavOidYqtsr2spTwaZsLkSCQFZcJcqOmtrdsUlCRHcYNFfqXu833io bnzPl/YkIpBMOJPF2JYCb2PglZygICAd5ED2FPRS5Ci3XFBdtY5ec+IJ3tegF3HMobbi f9BkYoMHx+2LClIuTxtXm7o/XCRMECSfQSnruEx8TARZbQT2Yso24uEfN93gbHB3uOI2 2shQ== X-Forwarded-Encrypted: i=1; AJvYcCURgcR3agzhwrab7R5HoNCAUdCWcGbssitjb8w0v9IlciPNgvPZNmIP/+n2JO0Zc+d0bb/52V+UiaRr7D9F@lists.postgresql.org X-Gm-Message-State: AOJu0YzME1sQJFivMaoTqiXdvdXDs1paog5sX2LXTld7rkj7QSCOlFCr 83/Jdwqp002Yne1edfwCoaaUCrExshVCSHPb/Es8rMw8jJ2pB/KEjmkwdWNv6NdcRwDlfSyZFSi E5R4ago2dPcrjrlFUJ7k4NOFObME= X-Gm-Gg: ASbGncub+Zd+riCVZKUDRMz/LyI8XjUMgjRMKvHOapcFPVLvMfi2pyxy94x0pKbAmV0 hU20OKpSEya4d0b8KeuI3i65NK0cOPFjvY9QSQs8lM/cPRLm6LwVOEugCtkqG2j1lzDVbpEG3Vi 0= X-Google-Smtp-Source: AGHT+IHG1e5PvujIMcBHT+qWFZT1XjJIZf+0qpvv6mrmk2SlFz/sgTHR5HbzdSiDSkJPhWD6C9OhI/ZpPkx3yGWygQw= X-Received: by 2002:a17:907:9714:b0:aa6:79fa:b47d with SMTP id a640c23a62f3a-ab6cfcb3a23mr815569966b.1.1738269135145; Thu, 30 Jan 2025 12:32:15 -0800 (PST) MIME-Version: 1.0 References: <1342498.1729444411@sss.pgh.pa.us> <1445998.1729482404@sss.pgh.pa.us> <2062830.1729625620@sss.pgh.pa.us> <2265411.1729699470@sss.pgh.pa.us> <2354718.1729737539@sss.pgh.pa.us> <2581216.1729794746@sss.pgh.pa.us> <1948345.1730500073@sss.pgh.pa.us> <3797606.1732045516@sss.pgh.pa.us> <1417389.1736964543@sss.pgh.pa.us> <3363452.1737483125@sss.pgh.pa.us> <0AC229FA-A3F1-43FD-B0DC-A46A73FEAFF7@yandex-team.ru> <931398.1737905825@sss.pgh.pa.us> <38A31221-C1C4-4846-9709-D66ACD76E87A@yandex-team.ru> <46876.1737918281@sss.pgh.pa.us> In-Reply-To: <46876.1737918281@sss.pgh.pa.us> From: Pavel Borisov Date: Fri, 31 Jan 2025 00:32:03 +0400 X-Gm-Features: AWEUYZlXpebXp6g5yHglae25LXWtXgTEkzfbV3X9-VwrMkk4zqggOVO8TELBeC4 Message-ID: Subject: Re: Using Expanded Objects other than Arrays from plpgsql To: Tom Lane Cc: Andrey Borodin , Michel Pelletier , Pavel Stehule , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Michel and Tom! On Sun, 26 Jan 2025 at 23:04, Tom Lane wrote: > > Andrey Borodin writes: > > On 26 Jan 2025, at 20:37, Tom Lane wrote: > >> Maybe we should recast it as an action. What do you think of > >> "mark_expr_as_assignment_source"? > > > Sounds better to me. I found no examples of similar functions nether in pl_gram.y, nor in gram.y, so IMO mark_expr_as_assignment_source() is the best candidate. > > WFM, I'll make it so in next version. > > > Got it, many thanks for the explanation. > > I'll see about incorporating more of that in the comments, too. > > > I wonder if you plan similar optimizations for array_cat(), array_remove() etc? > > + a := a || a; -- not optimizable > > Why is it not optimizable? Because there is no support function, because array_cat() has no support function, or something else? > > plpgsql won't attempt to optimize it because "a" is referenced twice > and there is no support function that might say it's safe anyway. > > array_cat doesn't currently have any special smarts about expanded > arrays, so it's all moot because the arrays would get flattened > on the way into it. If we did improve it to be able to cope with > expanded arrays, I'm not real sure that it could safely manage an > in-place update where the two inputs are the same array --- at > the least, some extreme care would be needed to get the right > answers. > > I'm not real excited about optimizing additional array operations > anyway. Maybe some more will get done at some point, but I don't > see that as part of this work. > > regards, tom lane I started looking at the patchset. Recently it got conflicts with changes to yyparse (473a575e05979b4db). Could you rebase it and also do naming changes proposed by Andrew Borodin, which I definitely agree with? Regards, Pavel Borisov