Re: [BUG] temporary file usage report with extended protocol and unnamed portals

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>, Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Benoit Lobréau <benoit(dot)lobreau(at)dalibo(dot)com>, Guillaume Lelarge <guillaume(dot)lelarge(at)dalibo(dot)com>, Pierrick Chovelon <pierrick(dot)chovelon(at)dalibo(dot)com>
Subject: Re: [BUG] temporary file usage report with extended protocol and unnamed portals
Date: 2025-09-18 16:06:31
Message-ID: CAA5RZ0vB-h2pFimPSi72ObWfpRwKR5kaN9XWW17TOkLntC9svA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Now, if I apply patch v11-0002 that only adds the tests but not
> v11-0001, the tests pass.

Ok. It looks like my regexp was wrong. v12-0002 fixes this by looking
for the correct STATEMENT: after the temp file logging.
I also realized that the initial tests we've been working with included:

```
+log_statement = all
+log_min_duration_statement = 0
```

which caused additional noise and did not isolate the temp logging,
and that could mislead the tests. So, I removed these settings.
So now, applied independently, the tests in 0002 will not pass.

I also went back to think about the concern by Tom early in the thread [0]
that "The portal's query string is potentially shorter-lived than the portal."

I don't think this is a concern since the query string passed to the Portal
will outlive the portal, per this comment right before PortalDefineQuery:

```
/*
* We don't have to copy anything into the portal, because everything
* we are passing here is in MessageContext or the
* per_parsetree_context, and so will outlive the portal anyway.
*/
```

The "everything" also includes the query_text.

So, v12-0001 now sets debug_query_string before PortalDrop ( inside
drop_unnamed_portal). We will now with only log_temp_files set to "on",
see the "LOG: temporary file:" followed by the correctly blamed query
in the " STATEMENT: ".

[0] https://www.postgresql.org/message-id/23969.1745083695%40sss.pgh.pa.us

--
Sami

Attachment Content-Type Size
v12-0001-Fix-temp-file-logging-blame-in-extended-query-pr.patch application/octet-stream 3.7 KB
v12-0002-Add-tests-for-temp-file-logging.patch application/octet-stream 4.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan S. Katz 2025-09-18 16:08:49 Re: PG 18 relnotes and RC1
Previous Message Corey Huinker 2025-09-18 16:04:16 Re: someone else to do the list of acknowledgments