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 1tlBpU-009yiZ-UM for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 19:03:25 +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 1tlBpT-00Biht-5F for pgsql-hackers@arkaria.postgresql.org; Thu, 20 Feb 2025 19:03:23 +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 1tlBpS-00Bihe-Kh for pgsql-hackers@lists.postgresql.org; Thu, 20 Feb 2025 19:03:23 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tlBpQ-0020oA-0n for pgsql-hackers@postgresql.org; Thu, 20 Feb 2025 19:03:22 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-220bfdfb3f4so28501295ad.2 for ; Thu, 20 Feb 2025 11:03:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1740078198; x=1740682998; darn=postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=lsrd7sP67026DijKxAHfQT+0sKkMmxlUCXTZmp18sKU=; b=afMagbYXAZOkPk6DASd6J49Fdc2+a0wpgALpGwnsqH4pH447oWmpPOOKyo7G8WCM2k KVwzc3jqPT6ivU172VMaOhRr+dSd43ctrXIv7qqLqYGumTI8j1zL1WHtMHuIw52E9fuN J3oIMqDFbURSRa3FHY8ar0GwJ2tH9UG13LUHY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740078198; x=1740682998; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lsrd7sP67026DijKxAHfQT+0sKkMmxlUCXTZmp18sKU=; b=KEhbn5rdS61pOCjpgzI9zYApTGgVGZDb+1olUHABAYZQKO3+xMviU2GY2LbQx5bmq9 yTeF1ORpduJZC7PEmetcOurR8ZyvCFelLgIQURsQ1VwFtAoy3Zqerx3ptl5GUqBCDH6O 16rpOvp9kFcdGlaiXV+JZQBhxpPL0tswL8MF1cm5JsF/m5MyFAfIwfdfTb0PCCy/2/dw Y7fdIJ3ZHLBUe1QK2s6BA5R8+Q2a1Lz2E7tsTQlJ/m3MLuHu7Hqjk8wrtiWe6sQWDN+O OJ6RsPzSg4SVaOdjv19U1qGlj+QAPerdv0WiiDz0lpuzC8yn7r+n5LZlv/mR/2lD3khy Cuhg== X-Forwarded-Encrypted: i=1; AJvYcCXhQC8TBAeZDWWQb8RFnpy7yVnZc0ATNH8QmzVbRvfsiW/aQVLqEyP/RlcVP83V3D1kyLgABEPrVxS0qHH9@postgresql.org X-Gm-Message-State: AOJu0Yzkq0KdWPxUSjLXgnS5zSe3BfwyLX1tjlv7LnOi9C5AnlBlUiTy wixUSKb3gRdYsGldQUBel5cbMUfzOSJwhJolMHZklpO/HEt2HLSsQZqSBv9cWA== X-Gm-Gg: ASbGncuIG2APsIVABwtp+Q2MM860XDYjSAgWyeoG8qldH0qXw7GXhQRSxNvAuzG+jlU Aobts7qzg2FOMw8Q+8SJec1pStuTTJPbK4ni7qu50wAJ42XHaoftBlPnIS1EOCRCNIYcK93p7Qb qwIXKspH9/0jfanCR1HIFySvd63i6slfQhEA99R7Pd5lS+mSEjT2vq7XfBAxVyqE2+W2/BlJ2Mj nzUqnqbg4BvS0kwaWclvNO+eXET1Gtj1Fk24E08n63eQyBLVpT5IRRTvl35ruMaGQReJSKVARiA nmjt56dQ6Q== X-Google-Smtp-Source: AGHT+IEk7oJmOagjyTcyPpQahr4oyzQeW2z5dn+/EKiPYKIrJc5u8DQ3cj9Z3nY/T/4sZlCvOWwKcQ== X-Received: by 2002:a05:6a00:84a:b0:732:623d:beee with SMTP id d2e1a72fcca58-73426c8434cmr22434b3a.2.1740078198384; Thu, 20 Feb 2025 11:03:18 -0800 (PST) Received: from google.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73274399467sm9142613b3a.140.2025.02.20.11.03.17 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Feb 2025 11:03:17 -0800 (PST) Date: Thu, 20 Feb 2025 11:03:15 -0800 From: Noah Misch To: Andres Freund Cc: Thomas Munro , Andy Fan , pgsql-hackers@postgresql.org, Michael Paquier Subject: Re: GetRelationPath() vs critical sections Message-ID: <20250220190315.ad.nmisch@google.com> References: <874j5plwdk.fsf@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Feb 20, 2025 at 12:40:57PM -0500, Andres Freund wrote: > On 2025-02-20 14:00:10 +1300, Thomas Munro wrote: > > On Wed, Feb 19, 2025 at 3:35 PM Andres Freund wrote: > > > After thinking about this for an embarassingly long time, I think there's > > > actually a considerably better answer for a case like this: A function that > > > returns a fixed-length string by value: > > > > > > - Compilers can fairly easily warn about on-stack values that goes out of > > > scope > > > > > > - Because we don't need to free the memory anymore, some code that that > > > previously needed to explicitly free the memory doesn't need to anymore > > > (c.f. AbortBufferIO()). > > > > > > - The max lenght isn't that long, so it's actually reasonably efficient, > > > likely commonly cheaper than psprintf. > > > > I like it! Works for me. > Unfortunately I had to exclude "relpath" as there are just too many > independent hits, due to the python function of the same name. For > relpathperm(), relpathbackend(), GetRelationPath() there looks to be just > fincore. PGXN has few hits, and some of these are false positives or otherwise irrelevant: $ grep -re '[^.]\(relpath[a-z]*\|GetRelationPath\)(' | sed 's/-[^:]*/:/'|sort -u db2_fdw::extern char *GetRelationPath(Oid dbNode, Oid spcNode, Oid relNode, jsoncdc:: pub fn GetRelationPath(dbNode: Oid, spcNode: Oid, relNode: Oid, openbarter:: path = relpath(frame.f_code.co_filename, refdir) # relative to refdir pg_bulkload::#define relpath(rnode, forknum) relpath((rnode)) pg_bulkload:: fname = relpath(bknode, MAIN_FORKNUM); pg_bulkload:: fname = relpath(rnode, MAIN_FORKNUM); pg_repack::#define relpath(rnode, forknum) relpath((rnode)) plv8:: def _to_relpath(self, abspath, _): plv8:: def _to_relpath(self, abspath, test_root): plv8:: yield self._to_relpath(abspath, test_root) tblsize_nolock:: relationpath = relpath(*rfn); > Which makes me think it's not worth having a backward compatible interface? Agreed. Even if 100% of those matches had to change, that's below standard level of breakage for a major release.