pgsql: Fix nextXid tracking bug on standbys (9.5-11 only).

2020-03-11 Thread Thomas Munro
Fix nextXid tracking bug on standbys (9.5-11 only). RecordKnownAssignedTransactionIds() should never move nextXid backwards. Before this commit, that could happen if some other code path had advanced it without advancing latestObservedXid. One consequence is that a well timed XLOG_CHECKPOINT_ONL

pgsql: Fix nextXid tracking bug on standbys (9.5-11 only).

2020-03-11 Thread Thomas Munro
Fix nextXid tracking bug on standbys (9.5-11 only). RecordKnownAssignedTransactionIds() should never move nextXid backwards. Before this commit, that could happen if some other code path had advanced it without advancing latestObservedXid. One consequence is that a well timed XLOG_CHECKPOINT_ONL

pgsql: Fix nextXid tracking bug on standbys (9.5-11 only).

2020-03-11 Thread Thomas Munro
Fix nextXid tracking bug on standbys (9.5-11 only). RecordKnownAssignedTransactionIds() should never move nextXid backwards. Before this commit, that could happen if some other code path had advanced it without advancing latestObservedXid. One consequence is that a well timed XLOG_CHECKPOINT_ONL

pgsql: Fix nextXid tracking bug on standbys (9.5-11 only).

2020-03-11 Thread Thomas Munro
Fix nextXid tracking bug on standbys (9.5-11 only). RecordKnownAssignedTransactionIds() should never move nextXid backwards. Before this commit, that could happen if some other code path had advanced it without advancing latestObservedXid. One consequence is that a well timed XLOG_CHECKPOINT_ONL

pgsql: Fix test case instability introduced in 085b6b667.

2020-03-11 Thread Tom Lane
Fix test case instability introduced in 085b6b667. I forgot that the WAL directory might hold other files besides WAL segments, notably including new segments still being filled. That means a blind test for the first file's size being 16MB can fail. Restrict based on file name length to make it m

pgsql: Fix test case instability introduced in 085b6b667.

2020-03-11 Thread Tom Lane
Fix test case instability introduced in 085b6b667. I forgot that the WAL directory might hold other files besides WAL segments, notably including new segments still being filled. That means a blind test for the first file's size being 16MB can fail. Restrict based on file name length to make it m

pgsql: Fix test case instability introduced in 085b6b667.

2020-03-11 Thread Tom Lane
Fix test case instability introduced in 085b6b667. I forgot that the WAL directory might hold other files besides WAL segments, notably including new segments still being filled. That means a blind test for the first file's size being 16MB can fail. Restrict based on file name length to make it m

pgsql: Fix test case instability introduced in 085b6b667.

2020-03-11 Thread Tom Lane
Fix test case instability introduced in 085b6b667. I forgot that the WAL directory might hold other files besides WAL segments, notably including new segments still being filled. That means a blind test for the first file's size being 16MB can fail. Restrict based on file name length to make it m

pgsql: Paper over bt_metap() oldest_xact bug in backbranches.

2020-03-11 Thread Peter Geoghegan
Paper over bt_metap() oldest_xact bug in backbranches. The data types that contrib/pageinspect's bt_metap() function were declared to return as OUT arguments were wrong in some cases. In particular, the oldest_xact column (a TransactionId/xid field) was declared integer/int4 within the pageinspec

pgsql: Paper over bt_metap() oldest_xact bug in backbranches.

2020-03-11 Thread Peter Geoghegan
Paper over bt_metap() oldest_xact bug in backbranches. The data types that contrib/pageinspect's bt_metap() function were declared to return as OUT arguments were wrong in some cases. In particular, the oldest_xact column (a TransactionId/xid field) was declared integer/int4 within the pageinspec

pgsql: Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Add pg_dump support for ALTER obj DEPENDS ON EXTENSION pg_dump is oblivious to this kind of dependency, so they're lost on dump/restores (and pg_upgrade). Have pg_dump emit ALTER lines so that they're preserved. Add some pg_dump tests for the whole thing, also. Reviewed-by: Tom Lane (offlist) R

pgsql: Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Add pg_dump support for ALTER obj DEPENDS ON EXTENSION pg_dump is oblivious to this kind of dependency, so they're lost on dump/restores (and pg_upgrade). Have pg_dump emit ALTER lines so that they're preserved. Add some pg_dump tests for the whole thing, also. Reviewed-by: Tom Lane (offlist) R

pgsql: Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Add pg_dump support for ALTER obj DEPENDS ON EXTENSION pg_dump is oblivious to this kind of dependency, so they're lost on dump/restores (and pg_upgrade). Have pg_dump emit ALTER lines so that they're preserved. Add some pg_dump tests for the whole thing, also. Reviewed-by: Tom Lane (offlist) R

pgsql: Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Add pg_dump support for ALTER obj DEPENDS ON EXTENSION pg_dump is oblivious to this kind of dependency, so they're lost on dump/restores (and pg_upgrade). Have pg_dump emit ALTER lines so that they're preserved. Add some pg_dump tests for the whole thing, also. Reviewed-by: Tom Lane (offlist) R

pgsql: Add pg_dump support for ALTER obj DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Add pg_dump support for ALTER obj DEPENDS ON EXTENSION pg_dump is oblivious to this kind of dependency, so they're lost on dump/restores (and pg_upgrade). Have pg_dump emit ALTER lines so that they're preserved. Add some pg_dump tests for the whole thing, also. Reviewed-by: Tom Lane (offlist) R

pgsql: Avoid holding a directory FD open across pg_ls_dir_files() calls

2020-03-11 Thread Tom Lane
Avoid holding a directory FD open across pg_ls_dir_files() calls. This coding technique is undesirable because (a) it leaks the FD for the rest of the transaction if the SRF is not run to completion, and (b) allocated FDs are a scarce resource, but multiple interleaved uses of the relevant functio

pgsql: Avoid holding a directory FD open across pg_ls_dir_files() calls

2020-03-11 Thread Tom Lane
Avoid holding a directory FD open across pg_ls_dir_files() calls. This coding technique is undesirable because (a) it leaks the FD for the rest of the transaction if the SRF is not run to completion, and (b) allocated FDs are a scarce resource, but multiple interleaved uses of the relevant functio

pgsql: Avoid holding a directory FD open across pg_ls_dir_files() calls

2020-03-11 Thread Tom Lane
Avoid holding a directory FD open across pg_ls_dir_files() calls. This coding technique is undesirable because (a) it leaks the FD for the rest of the transaction if the SRF is not run to completion, and (b) allocated FDs are a scarce resource, but multiple interleaved uses of the relevant functio

pgsql: Avoid holding a directory FD open across pg_ls_dir_files() calls

2020-03-11 Thread Tom Lane
Avoid holding a directory FD open across pg_ls_dir_files() calls. This coding technique is undesirable because (a) it leaks the FD for the rest of the transaction if the SRF is not run to completion, and (b) allocated FDs are a scarce resource, but multiple interleaved uses of the relevant functio

pgsql: Refactor ps_status.c API

2020-03-11 Thread Peter Eisentraut
Refactor ps_status.c API The init_ps_display() arguments were mostly lies by now, so to match typical usage, just use one argument and let the caller assemble it from multiple sources if necessary. The only user of the additional arguments is BackendInitialize(), which was already doing string as

Re: pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
On 2020-Mar-11, Alvaro Herrera wrote: > Avoid duplicates in ALTER ... DEPENDS ON EXTENSION > Reviewed-by: Ibrar Ahmed, Tom Lane (offlist) I failed to credit Ahsan Hadi as a reviewer here. Apologies. -- Álvaro Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Sup

pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record

pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record

pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record

pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record

pgsql: Avoid duplicates in ALTER ... DEPENDS ON EXTENSION

2020-03-11 Thread Alvaro Herrera
Avoid duplicates in ALTER ... DEPENDS ON EXTENSION If the command is attempted for an extension that the object already depends on, silently do nothing. In particular, this means that if a database containing multiple such entries is dumped, the restore will silently do the right thing and record

pgsql: Clean up order in miscinit.c a bit

2020-03-11 Thread Peter Eisentraut
Clean up order in miscinit.c a bit The code around InitPostmasterChild() from commit 31c453165b5 somehow ended up in the middle of a block of code related to "User ID state". Move it into its own block instead. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/1c91838

pgsql: Remove HAVE_WORKING_LINK

2020-03-11 Thread Peter Eisentraut
Remove HAVE_WORKING_LINK Previously, hard links were not used on Windows and Cygwin, but they support them just fine in currently supported OS versions, so we can use them there as well. Since all supported platforms now support hard links, we can remove the alternative code paths. Rename durabl

pgsql: Improve checking of child pages in contrib/amcheck.

2020-03-11 Thread Alexander Korotkov
Improve checking of child pages in contrib/amcheck. This commit eliminates lossiness in check for missing parent downlinks in B-tree. Instead of collecting lossy bitmap, we check for missing downlinks while visiting child pages referenced by downlinks of target level. We traverse from previous c