pgsql: Coordinate emit_log_hook and all log destinations to share the s

2024-04-03 Thread Michael Paquier
Coordinate emit_log_hook and all log destinations to share the same timeval This would cause the timestamp values used by emit_log_hook and all the other log destinations to differ, because the timestamps are reset before sending the logs to the server and after calling the hook. This change

pgsql: Preliminary refactor of heap scanning functions

2024-04-03 Thread David Rowley
Preliminary refactor of heap scanning functions To allow the use of the read stream API added in b5a9b18cd for sequential scans on heap tables, here we make some adjustments to make that change less invasive and perhaps make the code easier to follow in the process. Here heapgetpage() gets

pgsql: pg_regress: Save errno in emit_tap_output_v() and switch to %m

2024-04-03 Thread Michael Paquier
pg_regress: Save errno in emit_tap_output_v() and switch to %m emit_tap_output_v() includes some fprintf() calls for some output related to the TAP protocol, that may clobber errno and break %m. This commit makes the logging of pg_regress smarter by saving errno before restoring it in vfprintf()

pgsql: CREATE INDEX: do not update stats during binary upgrade.

2024-04-03 Thread Jeff Davis
CREATE INDEX: do not update stats during binary upgrade. During binary upgrade, indexes are created before the data is moved into place, so it will always be zero. This is not currently a major problem, but will be when we try to preserve statistics during upgrade. Author: Corey Huinker

pgsql: Invent SERIALIZE option for EXPLAIN.

2024-04-03 Thread Tom Lane
Invent SERIALIZE option for EXPLAIN. EXPLAIN (ANALYZE, SERIALIZE) allows collection of statistics about the volume of data emitted by a query, as well as the time taken to convert the data to the on-the-wire format. Previously there was no way to investigate this without actually sending the

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: Fix the parameters order for TableAmRoutine.relation_copy_for_cl

2024-04-03 Thread Alexander Korotkov
Fix the parameters order for TableAmRoutine.relation_copy_for_cluster() Specify OldTable first, NewTable second as used by table_relation_copy_for_cluster() and as implemented in heapam_relation_copy_for_cluster(). Backpatch to PostgreSQL 12, where TableAmRoutine was introduced. Discussion:

pgsql: docs: Demote "Monitoring Disk Usage" from chapter to section.

2024-04-03 Thread Robert Haas
docs: Demote "Monitoring Disk Usage" from chapter to section. This chapter is very short, and the immediately preceding chapter is called "Monitoring Database Activity". So, instead of having a separate chapter for this, make it the last section of the preceding chapter instead. Discussion:

pgsql: Split XLogCtl->LogwrtResult into separate struct members

2024-04-03 Thread Alvaro Herrera
Split XLogCtl->LogwrtResult into separate struct members After this change we have XLogCtl->logWriteResult and ->logFlushResult. There's no functional change, other than the fact that the assignment from shared memory to local is no longer done via struct assignment, but instead using a macro

pgsql: Inline pg_popcount() for small buffers.

2024-04-03 Thread Nathan Bossart
Inline pg_popcount() for small buffers. If there aren't many bytes to process, the function call overhead of the optimized implementation isn't worth taking, so instead we inline a loop that consults pg_number_of_ones in that case. If there are many bytes to process, we accept the function call

pgsql: Combine freezing and pruning steps in VACUUM

2024-04-03 Thread Heikki Linnakangas
Combine freezing and pruning steps in VACUUM Execute both freezing and pruning of tuples in the same heap_page_prune() function, now called heap_page_prune_and_freeze(), and emit a single WAL record containing all changes. That reduces the overall amount of WAL generated. This moves the freezing

pgsql: Refactor how heap_prune_chain() updates prunable_xid

2024-04-03 Thread Heikki Linnakangas
Refactor how heap_prune_chain() updates prunable_xid In preparation of freezing and counting tuples which are not candidates for pruning, split heap_prune_record_unchanged() into multiple functions, depending the kind of line pointer. That's not too interesting right now, but makes the next

pgsql: Fix zeroing of pg_serial page without SLRU bank lock

2024-04-03 Thread Alvaro Herrera
Fix zeroing of pg_serial page without SLRU bank lock Bug in commit 53c2a97a9266: we failed to acquire the correct SLRU bank lock when iterating to zero-out intermediate pages in predicate.c. Rewrite the code block so that we follow the locking protocol correctly. Also update an outdated comment

pgsql: Use the pairing heap instead of a flat array for LSN replay wait

2024-04-03 Thread Alexander Korotkov
Use the pairing heap instead of a flat array for LSN replay waiters 06c418e163 introduced pg_wal_replay_wait() procedure allowing to wait for the particular LSN to be replayed on standby. The waiters were stored in the flat array. Even though scanning small arrays is fast, that might be a

Re: pgsql: Allow SIGINT to cancel psql database reconnections.

2024-04-03 Thread Robert Haas
On Tue, Apr 2, 2024 at 5:40 PM Alexander Korotkov wrote: > This appears to have missing pgindent. > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=koel=2024-04-02%2021%3A19%3A02 Argh, sorry. I think someone else fixed this. -- Robert Haas EDB: http://www.enterprisedb.com

pgsql: Drop global objects after completed test

2024-04-03 Thread Daniel Gustafsson
Drop global objects after completed test Project policy is to not leave global objects behind after a regress test run. This was found as a result of the development of a patch to make pg_regress detect such leftovers automatically, which in the end was withdrawn due to issues with parallel

Re: pgsql: Fix indentation from cafe1056558f

2024-04-03 Thread Andrew Dunstan
On 2024-04-03 We 03:49, Daniel Gustafsson wrote: Fix indentation from cafe1056558f Per buildfarm animal koel Thanks, you beat me to it. cheers andrew -- Andrew Dunstan EDB: https://www.enterprisedb.com

pgsql: Ensure that the sync slots reach a consistent state after promot

2024-04-03 Thread Amit Kapila
Ensure that the sync slots reach a consistent state after promotion without losing data. We were directly copying the LSN locations while syncing the slots on the standby. Now, it is possible that at some particular restart_lsn there are some running xacts, which means if we start reading the

pgsql: Minor improvements for waitlsn.c

2024-04-03 Thread Alexander Korotkov
Minor improvements for waitlsn.c * Remove extra includes * Fill 'cur' in addLSNWaiter() before taking the spinlock * Initialize 'endtime' with zero in WaitForLSN() to avoid compiler warning Reported-by: Alvaro Herrera, Masahiko Sawada, Daniel Gustafsson Discussion:

pgsql: Add error codes to some PANIC/FATAL errors reports

2024-04-03 Thread Daniel Gustafsson
Add error codes to some PANIC/FATAL errors reports This adds errcodes to a set of PANIC and FATAL errors in xlog.c and relcache.c, which previously had no errcode at all set, in order to make fleetwide analysis of errorlogs easier. There are many more ereport/elogs left which could benefit from

pgsql: Fix indentation from cafe1056558f

2024-04-03 Thread Daniel Gustafsson
Fix indentation from cafe1056558f Per buildfarm animal koel Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/9301308bd196f614696e0e9492cf0c52f7857f83 Modified Files -- src/bin/psql/command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

Re: pgsql: Implement pg_wal_replay_wait() stored procedure

2024-04-03 Thread Masahiko Sawada
Hi, On Wed, Apr 3, 2024 at 4:58 AM Alexander Korotkov wrote: > > Implement pg_wal_replay_wait() stored procedure > > pg_wal_replay_wait() is to be used on standby and specifies waiting for > the specific WAL location to be replayed before starting the transaction. > This option is useful when