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 1teuqL-00GM5H-AQ for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 11:42: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 1teuqK-00CiTe-DQ for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Feb 2025 11:42:20 +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 1teuqK-00CiTW-4E for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 11:42:20 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1teuqH-0031fP-1q for pgsql-hackers@lists.postgresql.org; Mon, 03 Feb 2025 11:42:19 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5d90a5581fcso7718850a12.1 for ; Mon, 03 Feb 2025 03:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738582936; x=1739187736; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8oxQOHFzzKYTzpU3/H/GDRTpxGRks7EqbH1Gi/AHz7Y=; b=i8TdKlwGWjcTIRMSH4LGgWDOaSw9pocHg/gpdSSlBSLDzyxrhu8Tp20P8BCxPY9GzA zAttQNakXNmH8hXmh5vKSmGzyIaJJUP/ROu6yGKUZk1H+gRp7tvKFnP1QBXdABFw3B0e Z5DKDAdI9/tgPg8a7UJRCz15s/gM+jXeqoASIdBGcDSZQhYJgWDsCO+0DxSP98BuOJ+3 SqAVTZo/xNOR9tnG+z6c9InefaSJ1sWcf7spKQfPhVvPYD78msIzOwlQKcfgEy81WGWn t2xnaUPxvy11PefNSQtui8mP9eO4qt5TKKhgelQRVwravuGB7CB4196YuOEArUXgEyDS fidg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738582936; x=1739187736; h=content-transfer-encoding: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=8oxQOHFzzKYTzpU3/H/GDRTpxGRks7EqbH1Gi/AHz7Y=; b=VIG2ihrTFl5S9/IzI3BewkFIjfyY4Dk9amypZqTOntjfMydFqSQp57aCWLF4B8/+Qo M0acLQToobMGEklYXCOSTAOFp7bjZ3rUpM81e7zq92VLDvPCBoxzfytKT3z2McGw2cGz T8WxwYchO823WG+TcDdDGIaBfWN9BGXXfA4ZXp2plvUbcYt9XbVqGqBR94sQCLv8EKkA 2ZvxgHdr01p1Ozh0KGe7OGq8AjglDCm67LzBEALZqVzVjtpNPwuU40n+cVDwocvelZll 5IH3hsp/okiSiKzkMqleTHltaKYeZ21lGicYHtbMX57+uzhHWDtvqkbvbYYprHToFM6m K9DQ== X-Forwarded-Encrypted: i=1; AJvYcCWc6BDr+8Q2zXQ7dhiEn9f+lHOfgGXX4HIOGPIraDlFvsBOsVLRB6Mb6cDE7pOEHTq0l+drAGSl3TnkfmoN@lists.postgresql.org X-Gm-Message-State: AOJu0YwXiO4RjKeYhYCJpe4JHP22zSo3vpUOSxKCq9wFLLr9UDQRZF1X 7WEkwXfLxlHGMzctx7r/0cSl/4SwiAHXfLYW0IZjDXEogsuKZ28g1zYUTwkX3Y/FLA5wsQxIJ2z m5/0r5tDZla2ygUuk3GAzV+jPByQ= X-Gm-Gg: ASbGncscr8Hj8Qv4NFS8+lCj52l7YISaYscr7ICtpa+vWV0Vw78qzqTAUIr9mwEzTvS RYxK3g7n+gQObcz9Rt3/DNLgh3ucPSgdxZEsZ0WWvZWINjcu8xpTHeTjXFJLo94g/E/c8uQamy8 8= X-Google-Smtp-Source: AGHT+IEOqsyelC59wt6QR+xQ4bfjQKb8IB0LCZeuk8hkZqda2GTHqBxeBn6yAuVmBJoUeGDcxZMYWVODVuCuYml1Xt8= X-Received: by 2002:a05:6402:e06:b0:5dc:91c6:8089 with SMTP id 4fb4d7f45d1cf-5dc91c682abmr10661301a12.29.1738582936028; Mon, 03 Feb 2025 03:42:16 -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> <3682021.1738288421@sss.pgh.pa.us> <256915.1738533419@sss.pgh.pa.us> In-Reply-To: From: Pavel Borisov Date: Mon, 3 Feb 2025 15:42:04 +0400 X-Gm-Features: AWEUYZmUzVxcTgo2JD2mvq1CheOzrEASIdMC_ffphYw7DOr8y3--KF19lOrPv-k Message-ID: Subject: Re: Using Expanded Objects other than Arrays from plpgsql To: Michel Pelletier Cc: Tom Lane , Andrey Borodin , Pavel Stehule , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Tom On Mon, 3 Feb 2025 at 07:02, Michel Pelletier wrote: > > On Sun, Feb 2, 2025 at 1:57=E2=80=AFPM Tom Lane wrote= : >> >> I wrote: >> > Hmm, it seemed to still apply for me. But anyway, I needed to make >> > the other changes, so here's v4. >> >> PFA v5. The new 0001 patch refactors the free_xxx infrastructure >> to create plpgsql_statement_tree_walker(), and then in what's now >> 0003 we can use that instead of writing a lot of duplicate code. > > > Thanks Tom! These patches apply for me and all my tests and benchmarks a= re still good. I've looked at the patches v4 and v5. v5 logic of patch 0003 is much more understandable with refactoring free_* functions to a walker. So I think it's much better than v4 even regarding the principle have not changed. Using support functions in 0005 complicates things. But I think it's justified by extensibility and benchmarks demonstrated by Michel above in the thread. Overall patch to me looks well-structured, beneficial for performance and extensibility and it looks good to me. Minor notes on the patches: If dump_* functions could use the newly added walker, the code would look better. I suppose the main complication is that dump_* functions contain a lot of per-statement prints/formatting. So maybe a way to implement this is to put these statements into the existing tree walker i.e. plpgsql_statement_tree_walker_impl() and add an argument bool dump_debug into it. So in effect called with dump_debug=3Dfalse plpgsql_statement_tree_walker_impl() would walk silent, and with dump_debug=3Dfalse it would walk and print what is supposed to be printed currently in dump_* functions. Maybe there are other problems besides this? For exec_check_rw_parameter(): I think renaming expr->expr_simple_expr to sexpr saves few bytes but doesn't makes anything simpler, so if possible I'd prefer using just expr->expr_simple_expr with necessary casts. Furtermore in this function mostly we use cast results fexpr, opexpr and sbsref of expr->expr_simple_expr that already has separate names. Transferring target param as int paramid looks completely ok. But we have unconditional checking Assert(paramid =3D=3D expr->target_param + 1), so it looks as a redundant split as of now. Do we plan a true split and removal of this assert in the future? Thanks for creating and working on this patch! Regards, Pavel Borisov Supabase