pgsql: Rework internal command generation of pg_rewind

2022-02-28 Thread Michael Paquier
Rework internal command generation of pg_rewind pg_rewind generates and executes internally up to two commands to work on the target cluster, depending on the options given by its caller: - postgres -C to retrieve the value of restore_command, when using -c/--restore-target-wal. - postgres --singl

pgsql: Reconsider pg_stat_subscription_workers view.

2022-02-28 Thread Amit Kapila
Reconsider pg_stat_subscription_workers view. It was decided (refer to the Discussion link below) that the stats collector is not an appropriate place to store the error information of subscription workers. This patch changes the pg_stat_subscription_workers view (introduced by commit 8d74fc96db)

pgsql: Handle integer overflow in interval justification functions.

2022-02-28 Thread Tom Lane
Handle integer overflow in interval justification functions. justify_interval, justify_hours, and justify_days didn't check for overflow when promoting hours to days or days to months; but that's possible when the upper field's value is already large. Detect and report any such overflow. Also, w

pgsql: Allow root-owned SSL private keys in libpq, not only the backend

2022-02-28 Thread Tom Lane
Allow root-owned SSL private keys in libpq, not only the backend. This change makes libpq apply the same private-key-file ownership and permissions checks that we have used in the backend since commit 9a83564c5. Namely, that the private key can be owned by either the current user or root (with di

pgsql: Don't use static storage for SaveTransactionCharacteristics().

2022-02-28 Thread Tom Lane
Don't use static storage for SaveTransactionCharacteristics(). This is pretty queasy-making on general principles, and the more so once you notice that CommitTransactionCommand() is actually stomping on the values saved by _SPI_commit(). It's okay as long as the active values didn't change during

pgsql: Fix SPI's handling of errors during transaction commit.

2022-02-28 Thread Tom Lane
Fix SPI's handling of errors during transaction commit. SPI_commit previously left it up to the caller to recover from any error occurring during commit. Since that's complicated and requires use of low-level xact.c facilities, it's not too surprising that no caller got it right. Let's move the

pgsql: Adjust interaction of libpq pipeline mode with errorMessage rese

2022-02-28 Thread Tom Lane
Adjust interaction of libpq pipeline mode with errorMessage resets. Since commit ffa2e4670, libpq resets conn->errorMessage only when starting a new query. However, the later introduction of pipelining requires a further refinement: the "start of query" isn't necessarily when it's submitted to PQ

pgsql: Improve some psql test code

2022-02-28 Thread Peter Eisentraut
Improve some psql test code Split psql_like() into two functions psql_like() and psql_fails_like() and make them mirror the existing command_like() and command_fails_like() more closely. In particular, follow the universal convention that the test name is the last argument. Discussion: https://