Re: Preserve index stats during ALTER TABLE ... TYPE ...

2025-10-19 Thread Michael Paquier
On Mon, Oct 20, 2025 at 06:22:00AM +, Bertrand Drouvot wrote: > On Mon, Oct 20, 2025 at 10:53:37AM +0900, Michael Paquier wrote: >> It may be time to do a clean split, even if the current state of >> business in pgstat.h is a kind of historical thing. > > Yeah, but maybe it would make more sen

Re: Import Statistics in postgres_fdw before resorting to sampling.

2025-10-19 Thread Michael Paquier
On Sat, Oct 18, 2025 at 08:32:24PM -0400, Corey Huinker wrote: > Rebased again. Hearing an opinion from Fujita-san would be interesting here, so I am adding him in CC. I have been looking a little bit at this patch. + ImportStatistics_function ImportStatistics; All FDW callbacks are docum

Re: using index to speedup add not null constraints to a table

2025-10-19 Thread jian he
On Fri, Oct 17, 2025 at 3:57 AM Álvaro Herrera wrote: > Can you please rebase this? It stopped applying a week ago. > hi. rebase and minor polishment. From 5a404c03556897b655359adef8057acd35246a1e Mon Sep 17 00:00:00 2001 From: jian he Date: Mon, 20 Oct 2025 13:29:32 +0800 Subject: [PATCH v7 1

Re: Preserve index stats during ALTER TABLE ... TYPE ...

2025-10-19 Thread Bertrand Drouvot
Hi, On Mon, Oct 20, 2025 at 10:53:37AM +0900, Michael Paquier wrote: > On Thu, Oct 16, 2025 at 03:39:59PM -0500, Sami Imseih wrote: > > This sounds like a good enhancement. This will also take care of the > > index stats being preserved on a table in the case an index is dropped. > > > > But that

Re: Question about InvalidatePossiblyObsoleteSlot()

2025-10-19 Thread Bertrand Drouvot
Hi, On Fri, Oct 17, 2025 at 03:08:07PM -0700, Masahiko Sawada wrote: > On Fri, Oct 17, 2025 at 12:18 AM Bertrand Drouvot > wrote: > > do you think that's also safe to not > > invalidate the slots for effective_xmin and catalog_effective_xmin if they > > advance far enough? > > I find the same i

Re: Optimize LISTEN/NOTIFY

2025-10-19 Thread Joel Jacobson
On Mon, Oct 20, 2025, at 00:10, Joel Jacobson wrote: > Attachments: > * 0001-optimize_listen_notify-v20.patch > * 0002-optimize_listen_notify-v20.patch > * 0002-optimize_listen_notify-v20-alt1.txt > * 0002-optimize_listen_notify-v20-alt3.txt > * 0002-optimize_listen_notify-v20-alt2.txt Attaching a

Use CompactAttribute more often, when possible

2025-10-19 Thread David Rowley
5983a4cff added CompactAttribute to TupleDesc to allow commonly accessed fields from the FormData_pg_attribute array to be accessed more quickly by having to load fewer cachelines from memory. That commit also went around and changed many locations to use CompactAttribute, but not all locations. T

Question on ThrowErrorData

2025-10-19 Thread 正华吕
Hi all, reading the source code of ThrowErrorData, it try to copy an ErrorData object into the correct memory context: newedata = &errordata[errordata_stack_depth]; recursion_depth++; oldcontext = MemoryContextSwitchTo(newedata->assoc_context); /* Copy the supplied fields

Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls

2025-10-19 Thread Shinya Kato
On Mon, Oct 20, 2025 at 10:17 AM Fujii Masao wrote: > > On Sun, Oct 19, 2025 at 2:04 AM Shinya Kato wrote: > > Thank you for the patch. I have one comment. > > > > + if (lag_tracker->overflowed[head].lsn > lsn) > > + return now - lag_tracker->overflowed[head].time; > > > > Could t

Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE

2025-10-19 Thread Michael Paquier
On Mon, Oct 20, 2025 at 01:01:31PM +1100, Peter Smith wrote: > Some comments for the latest v8 patch. The comments of Peter apply to comments and parameters. I am not going down to these details in this message, these can be infinitely tuned. The injection point integration looks correct. You a

Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options

2025-10-19 Thread Tatsuo Ishii
> A very trivial commit: > > ``` > + else > + > + /* > + * For other cases we have no idea what position of row callers > would > + * fetch next time. Also for relpos < 0 case (we go backward), > we > + * cannot set mark either. For those ca

Re: misleading error message in ProcessUtilitySlow T_CreateStatsStmt

2025-10-19 Thread jian he
On Fri, Oct 17, 2025 at 8:13 PM Álvaro Herrera wrote: > > Yeah, this looks good. But I think we can go a little further. Because > CreateStatistics() now calls transformStatsStmt(), we don't need to do > the same in ATPostAlterTypeParse(), which allows us to simplify the code > there. In turn t

Re: Optimize SnapBuildPurgeOlderTxn: use in-place compaction instead of temporary array

2025-10-19 Thread Kirill Reshke
On Mon, 20 Oct 2025 at 08:08, Xuneng Zhou wrote: > > Hi, thanks for looking into this. > > On Sat, Oct 18, 2025 at 4:59 PM Kirill Reshke wrote: > > > > On Sat, 18 Oct 2025 at 12:50, Xuneng Zhou wrote: > > > > > > Hi Hackers, > > > > Hi! > > > > > The SnapBuildPurgeOlderTxn function previously us

Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options

2025-10-19 Thread Chao Li
> On Oct 19, 2025, at 17:53, Tatsuo Ishii wrote: > > > If there's no objection, I am going to commit in a few days. > -- > Tatsuo Ishii > SRA OSS K.K. > English: http://www.sraoss.co.jp/index_en/ > Japanese:http://www.sraoss.co.jp > A very trivial commit: ``` + else + +

Re: Logical Replication of sequences

2025-10-19 Thread Chao Li
> On Oct 17, 2025, at 17:34, Chao Li wrote: > > I may find some time to review 0002 and 0003 next week. I just reviewed 0002 and 0003. Got some comments for 0002, and no comment for 0003. 1 - 0002 - commit comment ``` Sequences have 3 states: - INIT (needs [re]synchronizing) - READY

Re: pg_restore --no-policies should not restore policies' comment

2025-10-19 Thread Fujii Masao
On Fri, Oct 17, 2025 at 7:23 PM Fujii Masao wrote: > > On Thu, Oct 16, 2025 at 11:23 PM jian he wrote: > > > As for the unnecessary code for security labels on extensions > > > you mentioned earlier, I've created a patch to remove it. Patch attached. > > > > looks good to me. > > Thanks for the r

Re: IO in wrong state on riscv64

2025-10-19 Thread Thomas Munro
Updating the list with some progress: Alexander narrowed it down to pgaio_io_wait() being inlined into pgaio_io_was_recycled(). It seems to have some instructions in the wrong order, and that can be reproduced standalone, so I've asked about it here: https://github.com/llvm/llvm-project/issues/1

Re: [PROPOSAL] Termination of Background Workers for ALTER/DROP DATABASE

2025-10-19 Thread Peter Smith
Hi Iwata-San, Some comments for the latest v8 patch. == src/backend/postmaster/bgworker.c TerminateBgWorkersByBbOid: 1. +void +TerminateBgWorkersByDbOid(Oid oid) Now the function name is more explicit, but that is not a good reason to make the parameter name more vague. IMO the parameter

Re: Preserve index stats during ALTER TABLE ... TYPE ...

2025-10-19 Thread Michael Paquier
On Thu, Oct 16, 2025 at 03:39:59PM -0500, Sami Imseih wrote: > This sounds like a good enhancement. This will also take care of the > index stats being preserved on a table in the case an index is dropped. > > But that means we will need some new fields to aggregate index access > in PgStat_StatTa

Re: get rid of RM_HEAP2_ID

2025-10-19 Thread Michael Paquier
On Wed, Oct 15, 2025 at 05:39:38PM +0300, Heikki Linnakangas wrote: > We could store xl_crc unaligned. IIRC all the structs that follow that are > already stored unaligned. If we do just that, would there be any downside in moving xl_crc to be just after xl_prev? That would keep the record assemb

Re: [PATCH] Fix POSIX compliance in pgwin32_unsetenv()

2025-10-19 Thread Bryan Green
On 10/19/25 20:02, Michael Paquier wrote: On Sat, Oct 18, 2025 at 01:26:40PM -0500, Bryan Green wrote: I noticed that pgwin32_unsetenv() in src/port/win32env.c lacks the input validation that its sibling function pgwin32_setenv() has (lines 126-132). Without these checks, the function will cras

Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls

2025-10-19 Thread Fujii Masao
On Mon, Oct 20, 2025 at 10:12 AM Fujii Masao wrote: > > On Sat, Oct 18, 2025 at 9:16 AM Chao Li wrote: > > I think I put all concentration on the big picture yesterday, so I ignored > > this implementation detail: > > > > ``` > > + if (lag_tracker->overflowed[head].lsn > lsn) > > +

Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls

2025-10-19 Thread Fujii Masao
On Sun, Oct 19, 2025 at 2:04 AM Shinya Kato wrote: > Thank you for the patch. I have one comment. > > + if (lag_tracker->overflowed[head].lsn > lsn) > + return now - lag_tracker->overflowed[head].time; > > Could this return a negative value if the clock somehow went > backwards? Th

Re: Fix lag columns in pg_stat_replication not advancing when replay LSN stalls

2025-10-19 Thread Fujii Masao
On Sat, Oct 18, 2025 at 9:16 AM Chao Li wrote: > I think I put all concentration on the big picture yesterday, so I ignored > this implementation detail: > > ``` > + if (lag_tracker->overflowed[head].lsn > lsn) > + return now - lag_tracker->overflowed[head].tim

Re: [PATCH] Fix POSIX compliance in pgwin32_unsetenv()

2025-10-19 Thread Michael Paquier
On Sat, Oct 18, 2025 at 01:26:40PM -0500, Bryan Green wrote: > I noticed that pgwin32_unsetenv() in src/port/win32env.c lacks the input > validation that its sibling function pgwin32_setenv() has (lines 126-132). > > Without these checks, the function will crash on NULL input via > strlen(NULL), a

Re: Executing pg_createsubscriber with a non-compatible control file

2025-10-19 Thread Michael Paquier
On Sat, Oct 18, 2025 at 08:55:35AM +0900, Michael Paquier wrote: > With the addition of the version check in the binary, there is no > downside in documenting this requirement. Okay, I have added a note about that in the docs, then applied your patch on HEAD. Thanks! If others would like to appl

Re: isolation tester limitation in case of multiple injection points in a single command

2025-10-19 Thread Michael Paquier
On Sun, Oct 19, 2025 at 03:41:00PM +0200, Mihail Nikalayeu wrote: > Hello, everyone! > > While stabilizing tests for [0] I realized I have no idea how to set > up a pretty simple scenario using an isolation tester. > > It looks like this: > * session S1 start long running query (CREATE INDEX CONC

Re: Optimize LISTEN/NOTIFY

2025-10-19 Thread Joel Jacobson
On Mon, Oct 20, 2025, at 00:06, Joel Jacobson wrote: > Attachments: > * 0001-optimize_listen_notify-v20.patch > * 0002-optimize_listen_notify-v20-alt1.txt > * 0002-optimize_listen_notify-v20-alt3.txt > * 0002-optimize_listen_notify-v20-alt2.txt My apologies, I forgot to attach 0002-optimize_listen

Re: Optimize LISTEN/NOTIFY

2025-10-19 Thread Joel Jacobson
On Thu, Oct 16, 2025, at 22:16, Tom Lane wrote: > "Joel Jacobson" writes: >> On Thu, Oct 16, 2025, at 20:16, Joel Jacobson wrote: >>> Building pendingNotifyChannels is O(N^2) yes, but how large N is >>> realistic here? > >> I agree this looks like a real problem, since I guess it's not >> complete

Re: abi-compliance-check failure due to recent changes to pg_{clear,restore}_{attribute,relation}_stats()

2025-10-19 Thread David E. Wheeler
On Oct 18, 2025, at 22:48, Mankirat Singh wrote: > I've implemented the support for .abi-compliance-history file. If the file is > present in a STABLE branch, it will be used by default; otherwise, the latest > tag will be used. You can view the changes here[1]. I’ve now deployed this change (

Re: [PATCH] Add pg_get_trigger_ddl() to retrieve the CREATE TRIGGER statement

2025-10-19 Thread Philip Alger
Hi Marcos, > In a multi tenant world this feature will be cool for clone or sync ddl of > two schemas. So, if I’m creating a new schema the way you did works but if > both exists and I want to update some ddls of a schema, sometimes I have to > DROP and CREATE or returned command should have CREAT

Re: [PATCH] random_normal function

2025-10-19 Thread David E. Wheeler
On Oct 6, 2025, at 06:30, Michael Paquier wrote: > IMO, the main docs would benefit greatly from the addition of > PG_ABS_BUILDDIR, PG_ABS_BUILDDIR, PG_LIBDIR and PG_DLSUFFIX, which are > still missing. These are available to extension developers through > installcheck, and are a great way to wr

Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?

2025-10-19 Thread Álvaro Herrera
On 2025-Jul-27, Lukas Fittl wrote: > See attached v11 (and moved to the PG19-2 commitfest), split into a new set > of patches: I rebased (but not reviewed) this patchset now that Michael committed part of 0001, as seen in another thread. Quickly looking at 0003, I wonder if adding a separate --f

Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue

2025-10-19 Thread Joel Jacobson
On Fri, Oct 17, 2025, at 15:51, Álvaro Herrera wrote: > I have the impression that this thread has lost focus on the idea of > producing a backpatchable bugfix. The last proposed patch has a lot of > new mechanism that doesn't seem suitable for backpatch. I could be > wrong of course. I've tried

Re: gzgetc() is hazardous to your health

2025-10-19 Thread Tom Lane
I wrote: > What I think we ought to do about this is get rid of our one usage > of gzgetc(), replacing it with a one-byte gzread() operation. > That's not lovely from a speed perspective, but I don't think that > reading a pg_dump TOC file is really speed-critical. In the light of morning I had a

[PROPOSAL] Platform-native resource usage stats for Windows

2025-10-19 Thread Bryan Green
Hello, I'd like to propose an enhancement to how PostgreSQL reports resource usage statistics on Windows, building on a 2017 discussion initiated by Justin Pryzby [1]. I've been spending some time reviewing windows specific code in the postgresql codebase. I've notice several "opportunitie

isolation tester limitation in case of multiple injection points in a single command

2025-10-19 Thread Mihail Nikalayeu
Hello, everyone! While stabilizing tests for [0] I realized I have no idea how to set up a pretty simple scenario using an isolation tester. It looks like this: * session S1 start long running query (CREATE INDEX CONCURRENTLY) and traps into injection point X * session S2 executes some command *

Re: Suggestion to add --continue-client-on-abort option to pgbench

2025-10-19 Thread Rintaro Ikeda
Hi, On 2025/10/02 1:22, Fujii Masao wrote: > Regarding 0002: > > - if (canRetryError(st->estatus)) > + if (continue_on_error || canRetryError(st->estatus)) > { > if (verbose_errors) > commandError(st, PQresultErrorMessage(res)); > goto error; > > With this change, even non-SQL errors (e.

Re: Accessing an invalid pointer in BufferManagerRelation structure

2025-10-19 Thread Álvaro Herrera
On 2025-Apr-14, Daniil Davydov wrote: > On Wed, Mar 26, 2025 at 2:14 PM Stepan Neretin wrote: > > The first thing we both noticed is that the macro calls a function > > that won't be available without an additional header. This seems a > > bit inconvenient. I think this is a fact of life. We d

Re: FSM doesn't recover after zeroing damaged page.

2025-10-19 Thread Álvaro Herrera
On 2025-Mar-24, Anton A. Melnikov wrote: > That said, the fix initially proposed seems incorrect and overly crude to me, > as this behavior does not occur with every FSM page but only under specific > conditions. > E. g., the error will not recur if it was the last incomplete FSM page. > I think

Re: Add RESPECT/IGNORE NULLS and FROM FIRST/LAST options

2025-10-19 Thread Tatsuo Ishii
>>> 2. AFAICS there is only one notnull_info array, which amounts to >>> assuming that the window function will have only one argument position >>> that it calls WinGetFuncArgInFrame or WinGetFuncArgInPartition for. >>> That may be true for the built-in functions but it seems mighty >>> restrictive

Re: BRIN: Prevent the heapblk overflow during index summarization on very large tables resulting in an infinite loop

2025-10-19 Thread David Rowley
On Sun, 19 Oct 2025 at 19:03, sunil s wrote: > Previously, heapBlk was defined as an unsigned 32-bit integer. When > incremented > by pagesPerRange on very large tables, it could wrap around, causing the > condition > heapBlk < nblocks to remain true indefinitely — resulting in an infinite loop.