pgsql: Adjust pg_dump tag for relation stats.

2025-02-27 Thread Jeff Davis
Adjust pg_dump tag for relation stats. Do not use fmtId(), just use dobj->name directly, like for table data. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/424ededc580b03e1bcf8aff18a735e519c80061f Modified Files -- src/bin/pg_dump/pg_dump.c | 7 +-

pgsql: Invent pgstat_fetch_stat_backend_by_pid()

2025-02-27 Thread Michael Paquier
Invent pgstat_fetch_stat_backend_by_pid() This code is extracted from pg_stat_get_backend_io() in pgstatfuncs.c, so as it can be shared with other areas that need backend pgstats entries while having the benefits of the various sanity checks refactored here. As per its name, this retrieves backen

pgsql: pg_upgrade: Fix inconsistency in memory freeing

2025-02-27 Thread Michael Paquier
pg_upgrade: Fix inconsistency in memory freeing The function in charge of freeing the memory from a result created by PQescapeIdentifier() has to be PQfreemem(), to ensure that both allocation and free come from libpq. One spot in pg_upgrade was not respecting that for pg_database's datlocale (da

pgsql: pg_upgrade: Fix inconsistency in memory freeing

2025-02-27 Thread Michael Paquier
pg_upgrade: Fix inconsistency in memory freeing The function in charge of freeing the memory from a result created by PQescapeIdentifier() has to be PQfreemem(), to ensure that both allocation and free come from libpq. One spot in pg_upgrade was not respecting that for pg_database's datlocale (da

pgsql: Refactor COPY TO to use format callback functions.

2025-02-27 Thread Masahiko Sawada
Refactor COPY TO to use format callback functions. This commit introduces a new CopyToRoutine struct, which is a set of callback routines to copy tuples in a specific format. It also makes the existing formats (text, CSV, and binary) utilize these format callbacks. This change is a preliminary st

Re: pgsql: Generalize hash and ordering support in amapi

2025-02-27 Thread Mark Dilger
On Thu, Feb 27, 2025 at 8:27 AM Tom Lane wrote: > Peter Eisentraut writes: > > Generalize hash and ordering support in amapi > > Stop comparing access method OID values against HASH_AM_OID and > > BTREE_AM_OID, and instead check the IndexAmRoutine for an index to see > > if it advertises its abi

pgsql: Generalize hash and ordering support in amapi

2025-02-27 Thread Peter Eisentraut
Generalize hash and ordering support in amapi Stop comparing access method OID values against HASH_AM_OID and BTREE_AM_OID, and instead check the IndexAmRoutine for an index to see if it advertises its ability to perform the necessary ordering, hashing, or cross-type comparing functionality. A fi

pgsql: Create explain_dr.c and move DestReceiver-related code there.

2025-02-27 Thread Robert Haas
Create explain_dr.c and move DestReceiver-related code there. explain.c has grown rather large, and the code that deals with the DestReceiver that supports the SERIALIZE option is pretty easily severable from the rest of explain.c; hence, move it to a separate file. Reviewed-by: Peter Geoghegan

pgsql: Create explain_format.c and move relevant code there.

2025-02-27 Thread Robert Haas
Create explain_format.c and move relevant code there. explain.c has grown rather large, so move various functions that are principally concerned with output generation to a new source file, explain_format.c, instead of lumping them in with everything else that is part of explain.c Reviewed-by: Pe

pgsql: EXPLAIN: Always use two fractional digits for row counts.

2025-02-27 Thread Robert Haas
EXPLAIN: Always use two fractional digits for row counts. Commit ddb17e387aa28d61521227377b00f997756b8a27 attempted to avoid confusing users by displaying digits after the decimal point only when nloops > 1, since it's impossible to have a fraction row count after a single iteration. However, this

Re: pgsql: Generalize hash and ordering support in amapi

2025-02-27 Thread Tom Lane
Peter Eisentraut writes: > Generalize hash and ordering support in amapi > Stop comparing access method OID values against HASH_AM_OID and > BTREE_AM_OID, and instead check the IndexAmRoutine for an index to see > if it advertises its ability to perform the necessary ordering, > hashing, or cross-

pgsql: Avoid unnecessary computation of pgbench's script line number.

2025-02-27 Thread Tom Lane
Avoid unnecessary computation of pgbench's script line number. ParseScript only needs the lineno for meta-commands, so let's not bother computing it otherwise. While this doesn't save much given the previous patch, there's no point in doing unnecessary work. While we're at it, avoid calling psql_

pgsql: Get rid of O(N^2) script-parsing overhead in pgbench.

2025-02-27 Thread Tom Lane
Get rid of O(N^2) script-parsing overhead in pgbench. pgbench wants to record the starting line number of each command in its scripts. It was computing that by scanning from the script start and counting newlines, so that O(N^2) work had to be done for an N-command script. In a script with 50K l

pgsql: Get rid of ojrelid local variable in remove_rel_from_query()

2025-02-27 Thread Alexander Korotkov
Get rid of ojrelid local variable in remove_rel_from_query() As spotted by Coverity, the calculation of ojrelid mixes signed and unsigned types causes possible overflow and undefined behavior. Instead of trying to fix the expression, this commit eliminates the relied local variable. The explicit