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 1tSeM5-000VWj-Sb for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Dec 2024 15:40:26 +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 1tSeM4-003JY5-Pn for pgsql-hackers@arkaria.postgresql.org; Tue, 31 Dec 2024 15:40:24 +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 1tSeM4-003JXx-9Z for pgsql-hackers@lists.postgresql.org; Tue, 31 Dec 2024 15:40:24 +0000 Received: from mail-yb1-xb34.google.com ([2607:f8b0:4864:20::b34]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tSeM2-001QV3-2K for pgsql-hackers@lists.postgresql.org; Tue, 31 Dec 2024 15:40:23 +0000 Received: by mail-yb1-xb34.google.com with SMTP id 3f1490d57ef6-e3978c00a5aso12321961276.1 for ; Tue, 31 Dec 2024 07:40:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735659622; x=1736264422; 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=Bm1B54EU6WjhwehsDC8hbPk0Xq2FlO/Xa7af8KjBMhw=; b=XaaTQnnVBUuPouX4DyO7XE6FdU+/DePMu2sSNuwQ65eDi+bbfwyPXDnwE9Z0TqTOYx mRvv5UlvAa3NK0nf1ceep+KGMdRM8zTm1Sla0Ic/NQ+3pvLBLeWkLqsdQCl48TxLcfKo +VQe98qikJb6CRsOShWtcrvGkfishMCG5fTEv/Ow9l9x+T+AI3ilOSOP5GKl/GtarTcE EMsIbCccFVwrtrNTDuZ0vK1P6gD+IJ7egcZCq7HEKT+X45bObP9QlEnqJ3iJRBqHCOSR tqAGNYG+s6SOXWCvE9tP6a5nsO/Gton3dHm4tjT7hi7Z2cH0aMneRTWx73WUwrDdyw40 90Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735659622; x=1736264422; 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=Bm1B54EU6WjhwehsDC8hbPk0Xq2FlO/Xa7af8KjBMhw=; b=mGmnOLoQ0R5cwQx3J2mqvbSlr/Fcip+m/ZKtCaXi1DCcD8fyDOaDef7rX5XzCnj0AQ /oP9AB5dmVh3MkDFheTCpyRQeIijMmIw7W8ZJTCF0Arzy4QnJdLHyN6DW+veOhb+qN42 19tofsBidIMdASjcsD70pB6g6Dr8SkHORkORfbVEVazL6DeM/OmF+hH4Mly5TaAU9qsT Zml066IbKMK73u5NY0RuRPlHcx1UpJI29RuDqSIUNV7HeClrFuYPlJpc/B8ZlVRJ3C/v guGZ+5gUyZkBJqregAIYy4/M1IsD4TXv055zOAtnpqpasB6u9KDMABV3t3tKSkKDW109 5b7Q== X-Forwarded-Encrypted: i=1; AJvYcCWdkYzjsLOAEwCt29fC82tpHW1AyJkHAJJAiYPP6Wl8sxaGvghxnnY20WLJbKmp0aCZBhdxrPIEVuUqu8Hu@lists.postgresql.org X-Gm-Message-State: AOJu0Ywl7j7MUYEgwqHbaMVJaam/IUmD3wDS9UuXspsqtWk5xjpbPz5S Dy8gkmPkTv1fno4kf2g+3Wj8lpFtvPH/POspYnV5ceCSFSY9+Q3i8iHqS96YPr3DhMctV9LnyuQ 2QmrDXIdFq2gkqStIKxjUR8EHq6U= X-Gm-Gg: ASbGnctGoF++svWjz5neFwCU8zKhFKgCcpOF1rPdyPw7VHbstf9xxF3bXTPv53vUXBI 8lvKhr73G9TyF5M0aucK0xwcs3VmuRNyHSHM/bePRrTIZEAdYqPZMutotM4e5mO3G/6jmHbg= X-Google-Smtp-Source: AGHT+IHXHgfHa1K33pvUl9+YEg9pNy6eUsPgZ1eAytvFXhCxjaYNIO+g4AqmyoQW7M01aQY5EfJCSCEt0tvK5QgKiT8= X-Received: by 2002:a05:690c:6e0c:b0:6ef:6b56:fb46 with SMTP id 00721157ae682-6f3f824cb08mr293518797b3.40.1735659621904; Tue, 31 Dec 2024 07:40:21 -0800 (PST) MIME-Version: 1.0 References: <8216639.NyiUUSuA9g@aivenlaptop> <3084885.1675783797@sss.pgh.pa.us> <758251661a3e8760ff52dd5c672a7505@postgrespro.ru> In-Reply-To: <758251661a3e8760ff52dd5c672a7505@postgrespro.ru> From: Pavel Stehule Date: Tue, 31 Dec 2024 16:39:45 +0100 Message-ID: Subject: Re: SQLFunctionCache and generic plans To: Alexander Pyhalov Cc: Alexander Korotkov , pgsql-hackers@lists.postgresql.org, Ronan Dunklau , Tom Lane Content-Type: multipart/alternative; boundary="00000000000036f9e9062a92bf1e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000036f9e9062a92bf1e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi =C3=BAt 31. 12. 2024 v 16:36 odes=C3=ADlatel Alexander Pyhalov < a.pyhalov@postgrespro.ru> napsal: > Hi. > > >> What should we do with "pre-parsed" SQL functions (when prosrc is > >> empty)? How should we create cached plans when we don't have raw > >> parsetrees? > >> Currently we can create cached plans without raw parsetrees, but this > >> means that plan revalidation doesn't work, choose_custom_plan() > >> always returns false and we get generic plan. Perhaps, we need some > >> form > >> of GetCachedPlan(), which ignores raw_parse_tree? > > > > I don't think you need a new form of GetCachedPlan(). Instead, it > > seems that StmtPlanRequiresRevalidation() should be revised. As I got > > from comments and the d8b2fcc9d4 commit message, the primary goal was > > to skip revalidation of utility statements. Skipping revalidation was > > a positive side effect, as long as we didn't support custom plans for > > them anyway. But as you're going to change this, > > StmtPlanRequiresRevalidation() needs to be revised. > > > > Thanks for feedback. > > I've modifed StmtPlanRequiresRevalidation() so that it looks on queries > command type. > Not sure if it's enough or I have to recreate something more similar to > stmt_requires_parse_analysis() > logic. I was wondering if this can lead to triggering plan revalidation > in RevalidateCachedQuery(). > I suppose not - as we plan in executor (so shouldn't catch userid change > or see some changes in > related objects. Revalidation would kill our plan, destroying > resultDesc. > > Also while looking at this, fixed processing of instead of rules (which > would lead to NULL execution_state). > -- > there are lot of fails found by tester Please, can you check it? regards Pavel > Best regards, > Alexander Pyhalov, > Postgres Professional --00000000000036f9e9062a92bf1e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

=C3=BAt 31. 12. 2024 v=C2= =A016:36 odes=C3=ADlatel Alexander Pyhalov <a.pyhalov@postgrespro.ru> napsal:
Hi.

>> What should we do with "pre-parsed" SQL functions (when = prosrc is
>> empty)? How should we create cached plans when we don't have r= aw
>> parsetrees?
>> Currently we can create cached plans without raw parsetrees, but t= his
>> means that plan revalidation doesn't work, choose_custom_plan(= )
>> always returns false and we get generic plan. Perhaps, we need som= e
>> form
>> of GetCachedPlan(), which ignores raw_parse_tree?
>
> I don't think you need a new form of GetCachedPlan().=C2=A0 Instea= d, it
> seems that StmtPlanRequiresRevalidation() should be revised.=C2=A0 As = I got
> from comments and the d8b2fcc9d4 commit message, the primary goal was<= br> > to skip revalidation of utility statements.=C2=A0 Skipping revalidatio= n was
> a positive side effect, as long as we didn't support custom plans = for
> them anyway.=C2=A0 But as you're going to change this,
> StmtPlanRequiresRevalidation() needs to be revised.
>

Thanks for feedback.

I've modifed StmtPlanRequiresRevalidation() so that it looks on queries=
command type.
Not sure if it's enough or I have to recreate something more similar to=
stmt_requires_parse_analysis()
logic. I was wondering if this can lead to triggering plan revalidation in RevalidateCachedQuery().
I suppose not - as we plan in executor (so shouldn't catch userid chang= e
or see some changes in
related objects. Revalidation would kill our plan, destroying
resultDesc.

Also while looking at this, fixed processing of instead of rules (which would lead to NULL execution_state).
--

there are lot of fails found by tes= ter

Please, can you check it?

=
regards

Pavel
Best regards,
Alexander Pyhalov,
Postgres Professional
--00000000000036f9e9062a92bf1e--