pgsql: Fix issues in pg_rewind with --no-ensure-shutdown/--write-recove

2019-10-04 Thread Michael Paquier
Fix issues in pg_rewind with --no-ensure-shutdown/--write-recovery-conf This fixes two issues with recent features added in pg_rewind: - --dry-run should do nothing on the target directory, but 927474c forgot to consider that for --write-recovery-conf. - --no-ensure-shutdown was not actually worki

pgsql: Remove AtSubStart_Notify.

2019-10-04 Thread Robert Haas
Remove AtSubStart_Notify. Allocate notify-related state lazily instead. This makes trivial subtransactions noticeably faster. Patch by me, reviewed and tested by Dilip Kumar, Kyotaro Horiguchi, and Jeevan Ladhe. Discussion: https://postgr.es/m/CA+TgmobE1J22S1eC-6N-je9LgrcwZypkwp+zH6JXo9mc=4n...

pgsql: Use Size instead of int64 to track allocated memory

2019-10-04 Thread Tomas Vondra
Use Size instead of int64 to track allocated memory Commit 5dd7fc1519 added block-level memory accounting, but used int64 variable to track the amount of allocated memory. That is incorrect, because we have Size for exactly these purposes, but it was mostly harmless until c477f3e449 which chang

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Fix bitshiftright()'s zero-padding some more.

2019-10-04 Thread Tom Lane
Fix bitshiftright()'s zero-padding some more. Commit 5ac0d9360 failed to entirely fix bitshiftright's habit of leaving one-bits in the pad space that should be all zeroes, because in a moment of sheer brain fade I'd concluded that only the code path used for not-a-multiple-of-8 shift distances nee

pgsql: Rename some toasting functions based on whether they are heap-sp

2019-10-04 Thread Robert Haas
Rename some toasting functions based on whether they are heap-specific. The old names for the attribute-detoasting functions names included the word "heap," which seems outdated now that the heap is only one of potentially many table access methods. On the other hand, toast_insert_or_update and t

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Handle spaces in OpenSSL install location for MSVC

2019-10-04 Thread Andrew Dunstan
Handle spaces in OpenSSL install location for MSVC First, make sure that the .exe name is quoted when trying to get the version number. Also, don't quote the lib name for using in the project files if it's already been quoted. This second change applies to all libraries, not just OpenSSL. This ha

pgsql: Use a fd opened for read/write when syncing slots during startup

2019-10-04 Thread Andres Freund
Use a fd opened for read/write when syncing slots during startup, take 2. Cribbing from dfbaed45975: Some operating systems, including the reporter's windows, return EBADFD or similar when fsync() is invoked on a O_RDONLY file descriptor. Unfortunately RestoreSlotFromDisk() does exactl

pgsql: Use a fd opened for read/write when syncing slots during startup

2019-10-04 Thread Andres Freund
Use a fd opened for read/write when syncing slots during startup, take 2. Cribbing from dfbaed45975: Some operating systems, including the reporter's windows, return EBADFD or similar when fsync() is invoked on a O_RDONLY file descriptor. Unfortunately RestoreSlotFromDisk() does exactl

pgsql: Add isolation tests for the combination of EPQ and triggers.

2019-10-04 Thread Andres Freund
Add isolation tests for the combination of EPQ and triggers. As evidenced by bug #16036 this area is woefully under-tested. Add fairly extensive tests for the combination. Backpatch back to 9.6 - before that isolationtester was not capable enough. While we don't backpatch tests all the time, futu

pgsql: Add isolation tests for the combination of EPQ and triggers.

2019-10-04 Thread Andres Freund
Add isolation tests for the combination of EPQ and triggers. As evidenced by bug #16036 this area is woefully under-tested. Add fairly extensive tests for the combination. Backpatch back to 9.6 - before that isolationtester was not capable enough. While we don't backpatch tests all the time, futu

pgsql: Add isolation tests for the combination of EPQ and triggers.

2019-10-04 Thread Andres Freund
Add isolation tests for the combination of EPQ and triggers. As evidenced by bug #16036 this area is woefully under-tested. Add fairly extensive tests for the combination. Backpatch back to 9.6 - before that isolationtester was not capable enough. While we don't backpatch tests all the time, futu

pgsql: Add isolation tests for the combination of EPQ and triggers.

2019-10-04 Thread Andres Freund
Add isolation tests for the combination of EPQ and triggers. As evidenced by bug #16036 this area is woefully under-tested. Add fairly extensive tests for the combination. Backpatch back to 9.6 - before that isolationtester was not capable enough. While we don't backpatch tests all the time, futu

pgsql: Fix crash caused by EPQ happening with a before update trigger p

2019-10-04 Thread Andres Freund
Fix crash caused by EPQ happening with a before update trigger present. When ExecBRUpdateTriggers()'s GetTupleForTrigger() follows an EPQ chain the former needs to run the result tuple through the junkfilter again, and update the slot containing the new version of the tuple to contain that new ver

pgsql: Add isolation tests for the combination of EPQ and triggers.

2019-10-04 Thread Andres Freund
Add isolation tests for the combination of EPQ and triggers. As evidenced by bug #16036 this area is woefully under-tested. Add fairly extensive tests for the combination. Backpatch back to 9.6 - before that isolationtester was not capable enough. While we don't backpatch tests all the time, futu

pgsql: Fix crash caused by EPQ happening with a before update trigger p

2019-10-04 Thread Andres Freund
Fix crash caused by EPQ happening with a before update trigger present. When ExecBRUpdateTriggers()'s GetTupleForTrigger() follows an EPQ chain the former needs to run the result tuple through the junkfilter again, and update the slot containing the new version of the tuple to contain that new ver

pgsql: Disable one set of tests from c8841199509.

2019-10-04 Thread Andres Freund
Disable one set of tests from c8841199509. One of the upsert related tests is unstable (sometimes even hanging until isolationtester's step timeout is reached). Based on preliminary analysis that might be a problem outside of just that test, but not really related to EPQ and triggers. Disable for

pgsql: Disable one set of tests from c8841199509.

2019-10-04 Thread Andres Freund
Disable one set of tests from c8841199509. One of the upsert related tests is unstable (sometimes even hanging until isolationtester's step timeout is reached). Based on preliminary analysis that might be a problem outside of just that test, but not really related to EPQ and triggers. Disable for

pgsql: Disable one set of tests from c8841199509.

2019-10-04 Thread Andres Freund
Disable one set of tests from c8841199509. One of the upsert related tests is unstable (sometimes even hanging until isolationtester's step timeout is reached). Based on preliminary analysis that might be a problem outside of just that test, but not really related to EPQ and triggers. Disable for

pgsql: Disable one set of tests from c8841199509.

2019-10-04 Thread Andres Freund
Disable one set of tests from c8841199509. One of the upsert related tests is unstable (sometimes even hanging until isolationtester's step timeout is reached). Based on preliminary analysis that might be a problem outside of just that test, but not really related to EPQ and triggers. Disable for

pgsql: Disable one set of tests from c8841199509.

2019-10-04 Thread Andres Freund
Disable one set of tests from c8841199509. One of the upsert related tests is unstable (sometimes even hanging until isolationtester's step timeout is reached). Based on preliminary analysis that might be a problem outside of just that test, but not really related to EPQ and triggers. Disable for