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 1u64sz-00ArC6-7O for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Apr 2025 09:53:21 +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 1u64sv-00BOMm-0Y for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Apr 2025 09:53:17 +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 1u64su-00BOMd-Md for pgsql-hackers@lists.postgresql.org; Sat, 19 Apr 2025 09:53:17 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u64ss-000tAE-0x for pgsql-hackers@postgresql.org; Sat, 19 Apr 2025 09:53:17 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-39ee651e419so1434409f8f.3 for ; Sat, 19 Apr 2025 02:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745056393; x=1745661193; darn=postgresql.org; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=Xi6gZeXafSeXdNsQOuFOFfs1UpfAdJI72PZinKWa+1M=; b=Y0gWaC18hasSF0be0NTIDhD1EJK+kraKUVUGFnyym1kzBt6AM58rBOtEE91+J5qeLI IgsPvBzaMU2JHI3jutoAb4v63psyPQCqN7r2a5hkz59kQD81pBO7eLwATpZIFKT6jNR5 6VSRcvyYpS4B6iOHbouT6wquIj2sMmxrxUVsXQ8mAmQRWaJMcQ6ujz9RLVF7xYcEV0fm 1IkBMxwjkBKFpa+vIh0PJZ6Wko43o0L1J1hh9Denuf8UU7A5ot/9cjvRdBcCIgHA7Do8 mtQ13jayJ7K4tV1WlQ1wwV0YS5hYVZh1UJfa8fsFqj0ls0aGQGlgpIuew4vyCMTiNcy+ +IQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745056393; x=1745661193; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Xi6gZeXafSeXdNsQOuFOFfs1UpfAdJI72PZinKWa+1M=; b=L1qOK9Fl+r4mUGlK5tUdPOqvTnt1XHziv2b3Px9mxK9ObFZUO2ALEj5kE4OV1CSpDA cgnwIrpMe3qhU7+6i6IBsYhKeArP7g1NaZH8t2P2GP/LPH5Am6Q9/9W0al3uvh1zXNde rQAwxvLdoih2g9v3yomOjJLt8R0YWUC0XdS6VOG9JBJ4ny6KxdOE6wVGN4BbKPoMyGev wCi4rCw7BTPzvYmP6YE0fO2V2s87hXJHnskTHnc/Ckhs/cuqoEuLtwT8QAOPgrcb20Sc AJen4+Wkuox7R35GVlHA/mzV79TPvqQb/N8luKu2M4dC7UG5c9sN7/44WOuKpYl+sjhD tRpQ== X-Gm-Message-State: AOJu0YxU+bcYhSK+39QR8cXAvZzEqfc8tqdfcntKUxfKdN0tpFXLO6BD hPjsjA7tR9hnnOAzoDv+lWWyBq5GM7R0qpzisYByycIh5nIPpRRZ X-Gm-Gg: ASbGnctEdrv58354h596LjScByaMRTiHxVNFreDawmJZzWwRHY88TSxKFrtbz9t0co+ 7FEE8khsRrfXfkw99nhcjVO/kLjha8wp90ZuNIxxYqyRF6zrVhStaaLlCuSvyGxD5uAZQGKuwsW aAnKBxiE9v9CV3PPfSmY0zWw0lCGjXbCGOiDOFtHs7zZ7QCHFVqL2/cdlBTbZbkQHsvHDIWuJSB /ACqW0rmmEfcDawQhfga3ukMowmWcrnZ9ZgFL5CmHSgeKuDjFtoHLVNb3xL/YhASAy/Tt0NOGfS ZdYvxxik6V30tBsvUMCDu58oB3fnHVrm4KaxXhdC8ESaFcBIUAlh4b0DJ43GIqvknN9Lfi3uB6J /rG1ho0rj41CRnKr3 X-Google-Smtp-Source: AGHT+IFlOAEkSTWn/cWxUIXYR2nFgq1KVnBGx4A2sZ1ddr5WFbGM2i6/3AgDxg4z3/MN4TjN+RpO/Q== X-Received: by 2002:a5d:584e:0:b0:391:39fb:59c8 with SMTP id ffacd0b85a97d-39efba5f83dmr4462970f8f.25.1745056393282; Sat, 19 Apr 2025 02:53:13 -0700 (PDT) Received: from smtpclient.apple ([2a02:85f:e845:ccdd:7860:9d8c:6403:64a6]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4406d6db10csm53757755e9.27.2025.04.19.02.53.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Apr 2025 02:53:12 -0700 (PDT) From: Florents Tselai Message-Id: <8ACA6321-D78B-4FBB-9685-8F51BF635115@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_AF2997B5-44ED-4553-A813-977C20329C4A" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.500.181.1.5\)) Subject: Re: SQL function to access to `creating_extension` Date: Sat, 19 Apr 2025 12:52:40 +0300 In-Reply-To: Cc: PostgreSQL-development To: Yurii Rashkovskii References: X-Mailer: Apple Mail (2.3826.500.181.1.5) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_AF2997B5-44ED-4553-A813-977C20329C4A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 19 Apr 2025, at 4:18=E2=80=AFAM, Yurii Rashkovskii = wrote: >=20 > Hi, >=20 > I propose to introduce `pg_creating_extension()` function that would = return the OID of the extension being currently created (or `null` if = none is). >=20 > The core motivation for it is to be able to establish data provenance = in tables created by extensions to be used in `pg_extension_config_dump` = configuration. This way, even if a secondary extension inserts data, it = can still be excluded from the dump by tracking data provenance in a = column with a default. Something like >=20 > ``` > create table my_config ( > --- ... > extension_provenance oid default pg_creating_extension() > ) > ``` >=20 > This would allow for a generalized exclusion in = pg_extension_config_dump. >=20 > I've attached a draft patch for this simple function. I am happy to = finalize it with tests and documentation if there is a consensus on the = shape. >=20 > -- > Founder at Omnigres > https://omnigres.com = Hi Yurii, =20 +1 from me. =20 I can see this being helpful, especially when dealing with shared tables = or managing extension-specific data in configuration dumps. --Apple-Mail=_AF2997B5-44ED-4553-A813-977C20329C4A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On 19 Apr 2025, at 4:18=E2=80=AFAM, Yurii Rashkovskii = <yrashk@omnigres.com> wrote:

Hi,

I = propose to introduce `pg_creating_extension()` function that would = return the OID of the extension being currently created (or `null` if = none is).

The core motivation for it is to be able to establish = data provenance in tables created by extensions to be used in = `pg_extension_config_dump` configuration. This way, even if a secondary = extension inserts data, it can still be excluded from the dump by = tracking data provenance in a column with a default. Something = like

```
create table my_config = (
   --- ...
  =  extension_provenance oid default = pg_creating_extension()
)
```

This would = allow for a generalized exclusion in = pg_extension_config_dump.

I've attached a draft patch for this = simple function. I am happy to finalize it with tests and documentation = if there is a consensus on the shape.

--
Founder at = Omnigres
https://omnigres.com
<v1-0001-pg_creating_extension-to-inspect-if-an-= extension-is-.patch>


=
Hi Yurii,  

+1 from me. =  

I can see this being helpful, especially = when dealing with shared tables or managing extension-specific data in = configuration dumps.

= --Apple-Mail=_AF2997B5-44ED-4553-A813-977C20329C4A--