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.96) (envelope-from ) id 1wAdnQ-000AnX-3C for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 01:03:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAdnP-002u1F-0x for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2026 01:03:00 +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.96) (envelope-from ) id 1wAdnP-002u0z-05 for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2026 01:02:59 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAdnN-000000005yc-39Wy for pgsql-hackers@postgresql.org; Thu, 09 Apr 2026 01:02:59 +0000 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-7d86eb7c854so201828a34.3 for ; Wed, 08 Apr 2026 18:02:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775696576; x=1776301376; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CHNriuHuS842xQm2AzLa7hQ4fyCjBBd22J4j+z632yA=; b=pTs3D5STaE00ehWSFXLzsm/r15ufdNAKEC8fhKqUrhZKZ1jJmr0WT9mjbbp8od/KgH h5aKKreF2D/lVMkvsz3SHs9uAfzoztCMdyW29oxu5hcs5RMHQMh8VhlYTZ6k28Ff5408 Ls40FRauRyvVL/ih8dggNoBkFhDZxJ0MYDd2cWBccCidv+qRd1/nnUlrgKr9zcdnpchd UKiRAj23vU3IHcE7GBDUhJTsDD+YEQOo6nmMJemhrASicrkIh7UBHuJa3vYkQfDfCxce 4SxtsGFsOtzipYzYZ/WbvJZbTlLFKh113STsEk/kUIugckCRCbOTa3uZOh+q7ycfPtqd mwIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775696576; x=1776301376; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CHNriuHuS842xQm2AzLa7hQ4fyCjBBd22J4j+z632yA=; b=R6DnnXfNMybKPgB73UmPX6XoYKveZpOCSRVMbzWWNzM9dPL7d37bf1ZUc3i9p4fM1V 9sjtP7DCNE4A5zSGNlJM2sl+Ii6nfp3lMm3r9oitigtz1Lmf2m1v7P/pjBPpYfQmGWNT x2Eqt9Qa18D2NgArHc8nKMhTxZacWsRBsqWMGC2fkcb4dFzENY8HuluQlmm3Pij7eGuw +82fyuyy6uGmyleKcDEdVQDVlfbGZfz0ycjr0MVapj3yGFwP6x0X0ppPKEtmTUxuJmzK tAGQj5LowATgaROW19urmPh+2AAVEYGPJJ9vmT+iejXDLOh9z0a4HYH9ZzLUhikztkaa MOyw== X-Forwarded-Encrypted: i=1; AJvYcCWk0CiXdNZvofJlIwWQaSpEzEXgrXyMq58n6OPOPW0kkqkSRgeZ8x/VizTdx28bvRwMFQcwkY6xfkdHzpZx@postgresql.org X-Gm-Message-State: AOJu0Ywz8tBi6TkoCXB47+doCxjQ5tMIU8dHnSrcg6wNkd4qxijGo6vM 3k/jeMtYwH5BeFnS3LRF/Z+kZYF6MfqViNaDbvvThjodlRdgTtrYVUFP X-Gm-Gg: AeBDieth8hi/3J6D0FVxb23w/n6GlZlh8KODmCHXj+GesQtkdRRkjbIyCEpljPK/MlL L7j6oQDfFkeAt7rxprHUdeajKJr/2J5w11B2Hm7k6HSwKvgVGqoVAhSWiA8At/vpdhm/xF4ekfi 77qfOgOPTBGoCbpe8y2m/XrPx1Se1lozFU0BxjNinEAXkAnTfxfGJJYFyzoOVSUtGUXB6BIDNjl THuWxXAU99acOJuG9oXMdVrOzoNu0q0AUnr+ZcItj5OFOcVCLQVng0x8+6NHod68rQ/RXVfnl7+ WJ7cneeuWnaZJEKe4lrnMNc5GJGyi7gxCY5mKjAtNo66fMwAzivp4lhgAUpxVJ8MedbkReTBpQM MbRhK01ckn2sK6pC0t9a8ENil2p5dmC3R9Qm6XMOhGB1LfljiOINhzeMDDvVUm3e7cWRQHAVPv2 P6fyUnBpschCyGvIxeyyT4BuhcYcPZs30xdvZm6ToRR8opJIwZQ3J+AIE5pAfXwf52FyegIG5dp Z9LB5MY8H3JpirTCtGNhg== X-Received: by 2002:a05:6830:4409:b0:7d7:e245:d5ad with SMTP id 46e09a7af769-7dc16f5806dmr1313483a34.16.1775696576196; Wed, 08 Apr 2026 18:02:56 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7dbb5c96485sm12968754a34.22.2026.04.08.18.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 18:02:55 -0700 (PDT) Date: Wed, 8 Apr 2026 20:02:53 -0500 From: Nathan Bossart To: Sami Imseih Cc: Andres Freund , Tom Lane , Alexander Lakhin , Bharath Rupireddy , Robert Treat , satyanarlapuram@gmail.com, pgsql-hackers , tndrwang@gmail.com Subject: Re: Add pg_stat_autovacuum_priority Message-ID: References: <3077290.1775668665@sss.pgh.pa.us> <3097984.1775674400@sss.pgh.pa.us> <3101163.1775676098@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 08, 2026 at 06:51:59PM -0500, Sami Imseih wrote: > I went ahead and implemented Andres's idea of will_free. Callers of > pgstat_fetch_entry can either pass a NULL to a will_free parameter, > or a bool. Callers that pass the bool can check if will_free is true and > can choose to free the entry. Yeah, I think this is the right thing to do. IMHO "may_free" is slightly more accurate here, since we're telling the caller that they can explicitly pfree() the result instead of letting the pgstat machinery or their own memory context take care of it. + /* + * When pgstat_fetch_consistency is PGSTAT_FETCH_CONSISTENCY_NONE, callers + * will be responsible for freeing the entry. + */ + if (will_free) + *will_free = (pgstat_fetch_consistency == PGSTAT_FETCH_CONSISTENCY_NONE); I don't know if this is a strict project guideline, but when I add these sorts of function parameters I usually just require the caller to provide a non-NULL pointer. But... what you have here seems fine, too. -- nathan