pgstat: add pgstat_prep_pending() for entry ref pending setup

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pgstat: add pgstat_prep_pending() for entry ref pending setup
Date: 2026-07-15 20:50:19
Message-ID: CAA5RZ0sV+TsLejUMhAM=PJoOm8u-t8ru7B67KvyLCy=19sM87g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

pgstat_prep_pending_entry() bundles three operations in a single call:
lookup, entry creation, and pending data setup. This is convenient for
the common case, but some callers need to do some other things in
between these steps. For example, looking at what needs to be done
for moving pg_stat_statements [1] to the cumulative statistics collector,
it needs to:

1. Look up the entry (pgstat_get_entry_ref with create=false)
2. If not found, check capacity and possibly evict before creating
3. Create the entry (pgstat_get_entry_ref with create=true)
4. Attach pending data

Steps 1-3 are already possible with pgstat_get_entry_ref(), but step 4
has no API.

The attached adds pgstat_prep_pending() which exposes step 4 as a
function. Together with pgstat_get_entry_ref(), callers can now perform
the same work as pgstat_prep_pending_entry() in individual steps.
pgstat_prep_pending_entry() itself is refactored to use the new
function internally.

[1] https://www.postgresql.org/message-id/flat/CAA5RZ0vZwR_dSK6fo0P2-EnskUVN0NjLHnGnJMFDPC8-kEW3sQ%40mail.gmail.com

--
Sami Imseih
Amazon Web Services (AWS)

Attachment Content-Type Size
v1-0001-pgstat-add-pgstat_prep_pending-for-entry-ref-pend.patch application/octet-stream 3.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul A Jungwirth 2026-07-15 21:02:10 Re: Fix RLS checks for UPDATE/DELETE FOR PORTION OF leftover rows
Previous Message Tristan Partin 2026-07-15 20:49:28 Re: meson: avoid PATH bloat from NLS .mo targets in tmp_install test setup