pgsql: pg_dump: Remove some dead code

2023-02-21 Thread Peter Eisentraut
pg_dump: Remove some dead code Client-side tracking of atttypmod has been unused since 64f3524, when server-side format_type() started being used exclusively. So remove this dead code. Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/flat/144be239-c893-9361-704f-ac85b5b9

pgsql: Fix small memory leak in psql's \bind command

2023-02-21 Thread Michael Paquier
Fix small memory leak in psql's \bind command psql_scan_slash_option() returns a malloc()'d result through a PQExpBuffer, and exec_command_bind() was doing an extra allocation of this option for no effect. Introduced in 5b66de3. Author: Kyotaro Horiguchi Reviewed-by: Corey Huinker Discussion: h

pgsql: doc: Add missing values for meson options -Dcassert and -Db_cove

2023-02-21 Thread Michael Paquier
doc: Add missing values for meson options -Dcassert and -Db_coverage The -Dcassert and -Db_coverage that can be specified to a meson command require values after an equal sign but the documentation did not properly reflect that. All the other options specify the argument values they expect, so cl

pgsql: Fix corruption of templates after CREATE DATABASE .. STRATEGY WA

2023-02-21 Thread Michael Paquier
Fix corruption of templates after CREATE DATABASE .. STRATEGY WAL_LOG WAL_LOG does a scan of the template's pg_class to determine the set of relations that need to be copied from a template database to the new one. However, as coded in 9c08aea, this copy strategy would load the pages of pg_class

pgsql: Fix corruption of templates after CREATE DATABASE .. STRATEGY WA

2023-02-21 Thread Michael Paquier
Fix corruption of templates after CREATE DATABASE .. STRATEGY WAL_LOG WAL_LOG does a scan of the template's pg_class to determine the set of relations that need to be copied from a template database to the new one. However, as coded in 9c08aea, this copy strategy would load the pages of pg_class

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Fix erroneous Valgrind markings in AllocSetRealloc.

2023-02-21 Thread Tom Lane
Fix erroneous Valgrind markings in AllocSetRealloc. If asked to decrease the size of a large (>8K) palloc chunk, AllocSetRealloc could improperly change the Valgrind state of memory beyond the new end of the chunk: it would mark data UNDEFINED as far as the old end of the chunk after having done t

pgsql: Remove obsolete coding for early macOS.

2023-02-21 Thread Thomas Munro
Remove obsolete coding for early macOS. Commits 04cad8f7 and 0c088568 supported old macOS systems that didn't define O_CLOEXEC or O_DSYNC yet, but those arrived in macOS releases 10.7 and 10.6 (respectively), which themselves reached EOL around a decade ago. We've already made use of other POSIX

Re: pgsql: Add assert checking to pg_leftmost_one_pos32() and friends

2023-02-21 Thread John Naylor
On Tue, Feb 21, 2023 at 11:59 AM John Naylor wrote: > > On Mon, Feb 20, 2023 at 10:17 PM Tom Lane wrote: > > > > John Naylor writes: > > > Add assert checking to pg_leftmost_one_pos32() and friends > > > > I can see that this was worth writing for testing purposes, but > > is it really worth car

pgsql: Fix handling of escape sequences in postgres_fdw.application_nam

2023-02-21 Thread Michael Paquier
Fix handling of escape sequences in postgres_fdw.application_name postgres_fdw.application_name relies on MyProcPort to define the data that should be added to escape sequences %u (user name) or %d (database name). However this code could be run in processes that lack a MyProcPort, like an autova

pgsql: Fix handling of escape sequences in postgres_fdw.application_nam

2023-02-21 Thread Michael Paquier
Fix handling of escape sequences in postgres_fdw.application_name postgres_fdw.application_name relies on MyProcPort to define the data that should be added to escape sequences %u (user name) or %d (database name). However this code could be run in processes that lack a MyProcPort, like an autova

pgsql: pgbench: Prepare commands in pipelines in advance

2023-02-21 Thread Alvaro Herrera
pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot,

pgsql: pgbench: Prepare commands in pipelines in advance

2023-02-21 Thread Alvaro Herrera
pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot,

pgsql: pgbench: Prepare commands in pipelines in advance

2023-02-21 Thread Alvaro Herrera
pgbench: Prepare commands in pipelines in advance Failing to do so results in an error when a pgbench script tries to start a serializable transaction inside a pipeline, because by the time BEGIN ISOLATION LEVEL SERIALIZABLE is executed, we're already in a transaction that has acquired a snapshot,