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 1v6Eeo-001PUh-Ck for pgsql-general@arkaria.postgresql.org; Tue, 07 Oct 2025 20:51: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 1v6Eej-003TIB-NO for pgsql-general@arkaria.postgresql.org; Tue, 07 Oct 2025 20:51:34 +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 1v6Eej-003THK-9F for pgsql-general@lists.postgresql.org; Tue, 07 Oct 2025 20:51:34 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6Eeh-000YOo-0u for pgsql-general@lists.postgresql.org; Tue, 07 Oct 2025 20:51:33 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-36a6a3974fdso69793241fa.0 for ; Tue, 07 Oct 2025 13:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759870288; x=1760475088; 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=t60abRUCsL/QEbnIaClc4wQPRMnQkEvPC2uL5j7m/gY=; b=MsaVxot4yeE/u4AL/5blVDQP1Osbj9B4Z55QBSjXZ+hyH9vsSGYAD2xn/aTLuK9TVn MLthW1BZP39v/FZKGkhjGa9Q68K1fZigCSdFSYiwOCsmyVCcAmIOuBGY+nXZL4IaYRyB GBSFV8WOZe0TA21nwj3gRcCpPiXwt74NabWNjgAJvIHgPYdUO4iUiZatD6wobgr9YIre 5Uaq564iuNcd5VjYid74ZgS4HIwk0TMPmZXiu2Unb5vIUaeQEm3pk38PiIrXgkSoOHTO oe46L0gJDtjfkSUNXeSgYKl5+RoP0oqclDo34erov+HZhru6qUk8bzvNuy+NX7ykXC9l wx1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759870288; x=1760475088; 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=t60abRUCsL/QEbnIaClc4wQPRMnQkEvPC2uL5j7m/gY=; b=CbF3ha3ZqwkZU1pAJe8onRybzZP9Ar5RzIv6rR2fHlk0PpLn/GZyQdRdcPv6Wkj9S8 VUhRJZf+zMaSdUTAi8fAuywAeWlTP5CIUO+OUs6UaJSQXfexxHLTaMnTrCVL0behQSsf k211GU/lF51yC69cuznG+KZ6C/d3HthhjRNROh0HpQoDN9P4/Ds+yvnEnaqM4dh4JbQX IzeawVALXLt9mmFCxR2wjgce0Tx2k+4uXifUlRDnchtX9D9+LgLnpWuXXaKUSajOfxUc dmrVjyFonvaVXwrl5nEPJnNAYN7VpLpjlYHM9aRXvldFJI8ish6MVT6LRA7HQUDsEgXz h/4Q== X-Gm-Message-State: AOJu0YzAw2k+MHX4yePKDq2voGwoP92hISspU2aU/Cm6hIt+M8oyJVem P8OehWUYHzfpZRYPQofhsL5SWvtOA9hIfvMxK0b7iBnwV7k2+8CcyO1pUqk3RF059f4aA1nxqJa FIlf4QMKp0WHVadP7OUNCMillcW3Dk4RsHaq8JHs= X-Gm-Gg: ASbGncvYqjZLTH86mxgf5c8i4X/RIilDKYIDG4THZohjpJxPJk5LLxLE92TtxYnngFt rr6T/ip53sc+l1OHJmq3F15ewVoc1JbMBiFEmzsqiX7mfmTIpP/sJPseZH2Zmvv/I929o2dNm0Z 2K+MtwY/T7ClNTq+b1sNdcRGngCMN71GEG0yrS2YXjJfS0L5qJlkaIfR5vKDW0n1ap69bxpIrij 927KNaPOY+XTDRFzlfU8gpdmfjgDbHBakPW3gPn2pxy5xM2smLjh7tbNOcz1fb4WObfScEYK1zW 6sfdkzxkdbQVxI9TrWDU X-Google-Smtp-Source: AGHT+IG13tZROYP0FwmjFz8Ro345+vkfnmy+nYPauxk39WRs+TFRMX8QCPZ9dYoTbVAXY3TGOV/F5NJ6Iqb/Ma+WJFY= X-Received: by 2002:a2e:be1b:0:b0:36c:f394:2ad6 with SMTP id 38308e7fff4ca-37609ce62bcmr2041901fa.6.1759870288254; Tue, 07 Oct 2025 13:51:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Merlin Moncure Date: Tue, 7 Oct 2025 14:51:12 -0600 X-Gm-Features: AS18NWDNsRfW4gfpyO5ZsfqKWqniWzdTwqOTjwde1G-F0_esgowCc9t4HgKToCw Message-ID: Subject: Re: Are SQL-language function lock ordering deadlocks solved in PostgreSQL 18? To: Bernice Southey Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000061da56064097bbf5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000061da56064097bbf5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Oct 6, 2025 at 10:54=E2=80=AFAM Bernice Southey wrote: > Hi pgsql-general community, > > I tried the simple test from the original mail [1] and indeed got > deadlocks in version 17, but not 18. Yet absence of evidence is not > proof of no race conditions. > > This might be my favourite change in 18 [2], if I'm understanding it > right. I much prefer the install-time checking of SQL-language > functions, and the elegance of pure SQL. But I've been convinced the > performance benefit of plan caching gave PL/pgSQL the edge. Now I'm > not so sure. > It sure seems like the intent of the change was to modify exactly that behavior. If you look at the major built-in sql-esque languages, sql(old), sql(new), PSM (new standard syntax) and pl/pgsql, I guess psm style and pure SQL might be overlapped with PSM style functions, especially if PSM functions can be inlined (I haven't looked yet)-- inlining of functions such as 'SELECT $1 + $2' being the only reason I write sql functions these days. I have always found the strict compile time checking to be highly obnoxious except in the immutable/inlinable cases that come up now and then. Plan caching is not so important IMO, since execution time tends to greatly exceed plan time in my experience and the real performance bugaboo is bad, not uncached plans. FIxing bad plans typically involves dipping into the pl/pgsql toolbox, using variable temp tables, planner directives, and other forbidden tools in PSM. In simple terms, I also used to restrict server side coding views and pure sql functions for abstraction, but have long since given up, and mainly write procedures :-). I really wish PSM functions could do what pl/pgsql functions do, since I like the creation syntax vs the 'string is body of code',but, alas. merlin --00000000000061da56064097bbf5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Oct 6, 2025 at 10:54=E2=80=AFAM B= ernice Southey <bernice.sou= they@gmail.com> wrote:
Hi pgsql-general= community,

I tried the simple test from the original mail [1] and indeed got
deadlocks in version 17, but not 18. Yet absence of evidence is not
proof of no race conditions.

This might be my favourite change in 18 [2], if I'm understanding it right. I much prefer the install-time checking of SQL-language
functions, and the elegance of pure SQL. But I've been convinced the performance benefit of plan caching gave PL/pgSQL the edge. Now I'm
not so sure.

It sure seems like the int= ent of the change was to modify exactly that behavior.=C2=A0

=
If you look at the major built-in sql-esque languages, sql(old),= sql(new), PSM (new standard syntax) and pl/pgsql, I guess psm style and pu= re SQL might=C2=A0be overlapped with PSM style functions, especially=C2=A0i= f PSM functions can be inlined (I haven't looked yet)-- inlining of fun= ctions=C2=A0such as 'SELECT $1=C2=A0+ $2' being the only reason I w= rite sql functions=C2=A0these days.=C2=A0 =C2=A0I have always found the str= ict compile time checking to be highly obnoxious except in the immutable/in= linable cases that come up now and then.=C2=A0

Pla= n caching is not so important IMO, since execution time tends to greatly ex= ceed plan time in my experience and the real performance bugaboo is bad, no= t uncached plans.=C2=A0 =C2=A0FIxing bad plans typically involves dipping i= nto the pl/pgsql toolbox, using variable temp tables, planner directives, a= nd other forbidden tools in PSM.=C2=A0 In simple terms, I also used to rest= rict server side coding=C2=A0 views and pure sql functions for abstraction,= but have long since given up, and mainly write procedures :-).
<= br>
I really wish PSM functions could do what pl/pgsql functions = do, since I like the creation syntax vs the 'string is body of code'= ;,but, alas.

merlin
--00000000000061da56064097bbf5--