pgsql: Use the AddFile function consistently in MSVC build scripts

2021-07-28 Thread David Rowley
Use the AddFile function consistently in MSVC build scripts

We seem to be using a mix of manually adding to the 'files' hash and
calling the Addfile() method.  Let's just consistently use AddFile().

Reviewed-by: Dagfinn Ilmari Mannsåker
Discussion: 
https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=l...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/ed1884a2fedeffd2e6902451a9d41f4b3f6e859f

Modified Files
--
src/tools/msvc/Project.pm | 10 +-
1 file changed, 5 insertions(+), 5 deletions(-)



pgsql: Disallow negative strides in date_bin()

2021-07-28 Thread John Naylor
Disallow negative strides in date_bin()

It's not clear what the semantics of negative strides would be, so throw
an error instead.

Per report from Bauyrzhan Sakhariyev

Reviewed-by: Tom Lane, Michael Paquier
Discussion: 
https://www.postgresql.org/message-id/CAKpL73vZmLuFVuwF26FJ%2BNk11PVHhAnQRoREFcA03x7znRoFvA%40mail.gmail.com
Backpatch to v14

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/fc0d9b8c224ff6b84113cefdca1ba9dde879d863

Modified Files
--
doc/src/sgml/func.sgml| 8 ++--
src/backend/utils/adt/timestamp.c | 8 
src/test/regress/expected/timestamp.out   | 5 -
src/test/regress/expected/timestamptz.out | 5 -
src/test/regress/sql/timestamp.sql| 3 +++
src/test/regress/sql/timestamptz.sql  | 3 +++
6 files changed, 20 insertions(+), 12 deletions(-)



pgsql: Disallow negative strides in date_bin()

2021-07-28 Thread John Naylor
Disallow negative strides in date_bin()

It's not clear what the semantics of negative strides would be, so throw
an error instead.

Per report from Bauyrzhan Sakhariyev

Reviewed-by: Tom Lane, Michael Paquier
Discussion: 
https://www.postgresql.org/message-id/CAKpL73vZmLuFVuwF26FJ%2BNk11PVHhAnQRoREFcA03x7znRoFvA%40mail.gmail.com
Backpatch to v14

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/3ba70d4e152372fd8ab90ed0887ee08d505ef306

Modified Files
--
doc/src/sgml/func.sgml| 8 ++--
src/backend/utils/adt/timestamp.c | 8 
src/test/regress/expected/timestamp.out   | 5 -
src/test/regress/expected/timestamptz.out | 5 -
src/test/regress/sql/timestamp.sql| 3 +++
src/test/regress/sql/timestamptz.sql  | 3 +++
6 files changed, 20 insertions(+), 12 deletions(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/a00c138b78521b9bc68b480490a8d601ecdeb816

Modified Files
--
src/backend/access/transam/xact.c | 11 ++-
1 file changed, 10 insertions(+), 1 deletion(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/f2a3d7404e5d4aa17dbdf7299b1f0d548fe59b9d

Modified Files
--
src/backend/access/transam/xact.c | 11 ++-
1 file changed, 10 insertions(+), 1 deletion(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/a66b05b422d74111f2a6407108f4ba7bdddbb6a0

Modified Files
--
src/backend/access/transam/xact.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/d7ded08e6e0e565adf6fea7c55bfcf2845e5f8cc

Modified Files
--
src/backend/access/transam/xact.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/02ef4d1e24b5868e4dd3110cd258aa2ca08527f2

Modified Files
--
src/backend/access/transam/xact.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/25fe5b2bb5fa35dfa05cb159216f3059540ba928

Modified Files
--
src/backend/access/transam/xact.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)



pgsql: Update minimum recovery point on truncation during WAL replay of

2021-07-28 Thread Fujii Masao
Update minimum recovery point on truncation during WAL replay of abort record.

If a file is truncated, we must update minRecoveryPoint. Once a file is
truncated, there's no going back; it would not be safe to stop recovery
at a point earlier than that anymore.

Commit 7bffc9b7bf changed xact_redo_commit() so that it updates
minRecoveryPoint on truncation, but forgot to change xact_redo_abort().

Back-patch to all supported versions.

Reported-by: [email protected]
Author: Fujii Masao
Reviewed-by: Heikki Linnakangas
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/32d182dd0da9628a4bc1515b69694d6e361a8de4

Modified Files
--
src/backend/access/transam/xact.c | 18 ++
1 file changed, 14 insertions(+), 4 deletions(-)



pgsql: Make the includes field an array in MSVC build scripts

2021-07-28 Thread David Rowley
Make the includes field an array in MSVC build scripts

Previously the 'includes' field was a string.  It's slightly nicer to
manage this when it's defined as an array instead. This allows us to
more easily detect and eliminate duplicates.

Reviewed-by: Álvaro Herrera, Andrew Dunstan, Dagfinn Ilmari Mannsåker
Discussion: 
https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=l...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/33d74c5d00e45248df66fa1bcd9222e0713ea5b1

Modified Files
--
src/tools/msvc/MSBuildProject.pm |  7 ++-
src/tools/msvc/Mkvcbuild.pm  |  4 ++--
src/tools/msvc/Project.pm| 12 +++-
3 files changed, 11 insertions(+), 12 deletions(-)



pgsql: Don't duplicate references and libraries in MSVC scripts

2021-07-28 Thread David Rowley
Don't duplicate references and libraries in MSVC scripts

In order not to duplicate references and libraries in the Visual Studio
project files produced by the MSVC build scripts, have them check if a
particular reference or library already exists before adding the same one
again.

Reviewed-by: Álvaro Herrera, Andrew Dunstan, Dagfinn Ilmari Mannsåker
Discussion: 
https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=l...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/15f16ec6511cf50374b09876e39c6939f2da0f08

Modified Files
--
src/tools/msvc/Project.pm | 11 +--
1 file changed, 9 insertions(+), 2 deletions(-)



pgsql: Adjust MSVC build scripts to parse Makefiles for defines

2021-07-28 Thread David Rowley
Adjust MSVC build scripts to parse Makefiles for defines

This adjusts the MSVC build scripts to look at the compile flags mentioned
in the Makefile to look for -D arguments in order to determine which
constants should be defined in Visual Studio builds.

One small anomaly that appeared as a result of this change is that the
Makefile for the ltree contrib module defined LOWER_NODE, but this was
not properly defined in the MSVC build scripts.  This meant that MSVC
builds would differ in case sensitivity in the ltree module when
compared to builds using a make build environment.  To maintain the same
behavior here we remove the -DLOWER_NODE from the Makefile and just always
define it in ltree.h for non-MSVC builds.  We need to maintain the old
behavior here as this affects the on-disk compatibility of GiST indexes
when using the ltree type.

The only other resulting change here is that REFINT_VERBOSE is now defined
for the autoinc, insert_username and moddatetime contrib modules.
Previously on MSVC, this was only defined for the refint module.  This
aligns the behavior to build environments using make as all 4 of these
modules share the same Makefile.

Reviewed-by: Tom Lane
Discussion: 
https://postgr.es/m/CAApHDvpo6g5csCTjc_0C7DMvgFPomVb0Rh-AcW5afd=Ya=l...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/245de48455daaf51f2f3e8b198d87b5dd9fd4516

Modified Files
--
contrib/ltree/Makefile  |  1 -
contrib/ltree/crc32.c   |  1 +
contrib/ltree/ltree.h   | 13 +
src/tools/msvc/Mkvcbuild.pm | 21 -
4 files changed, 34 insertions(+), 2 deletions(-)



pgsql: Add missing exit() in pg_verifybackup when failing to find pg_wa

2021-07-28 Thread Michael Paquier
Add missing exit() in pg_verifybackup when failing to find pg_waldump

pg_verifybackup needs by default pg_waldump to check after a range of
WAL segments required for a backup, except if --no-parse-wal is
specified.  The code checked for the presence of the binary pg_waldump
in an installation and reported an error, but it forgot to properly
exit().  This could lead to confusing errors reported.

Reviewed-by: Robert Haas, Fabien Coelho
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/2ad98fdf53edf1a90123e3b189cc6f0a31986891

Modified Files
--
src/bin/pg_verifybackup/pg_verifybackup.c | 1 +
1 file changed, 1 insertion(+)



pgsql: Add missing exit() in pg_verifybackup when failing to find pg_wa

2021-07-28 Thread Michael Paquier
Add missing exit() in pg_verifybackup when failing to find pg_waldump

pg_verifybackup needs by default pg_waldump to check after a range of
WAL segments required for a backup, except if --no-parse-wal is
specified.  The code checked for the presence of the binary pg_waldump
in an installation and reported an error, but it forgot to properly
exit().  This could lead to confusing errors reported.

Reviewed-by: Robert Haas, Fabien Coelho
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/efe169c90090684d2a4ffb0810a0cf2c9b72e19d

Modified Files
--
src/bin/pg_verifybackup/pg_verifybackup.c | 1 +
1 file changed, 1 insertion(+)



pgsql: Add missing exit() in pg_verifybackup when failing to find pg_wa

2021-07-28 Thread Michael Paquier
Add missing exit() in pg_verifybackup when failing to find pg_waldump

pg_verifybackup needs by default pg_waldump to check after a range of
WAL segments required for a backup, except if --no-parse-wal is
specified.  The code checked for the presence of the binary pg_waldump
in an installation and reported an error, but it forgot to properly
exit().  This could lead to confusing errors reported.

Reviewed-by: Robert Haas, Fabien Coelho
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 13

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/67445deb7eca32d25721dffb228b009bfbe415d5

Modified Files
--
src/bin/pg_verifybackup/pg_verifybackup.c | 1 +
1 file changed, 1 insertion(+)



pgsql: Add some missing exit() calls in error paths for various binarie

2021-07-28 Thread Michael Paquier
Add some missing exit() calls in error paths for various binaries

The following changes are done:
- In pg_archivecleanup, the cleanup of older WAL segments would never
fail immediately.
- In pgbench, the initialization of a thread barrier would not fail
hard.
- In pg_recvlogical, a stat() failure never got the call.
- In pg_basebackup, two chmod() reported a failure without exit()'ing
when unpacking some tar data freshly received.  It may be possible to
continue writing some data even after this failure, but that could be
confusing to the user at the end.

These are arguably bugs, but they would happen for code paths where a
failure is unlikely going to happen, so no backpatch is done.

Reviewed-by: Robert Haas, Fabien Coelho
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/856de3b39cf6041338b286a99257c324ce647f4e

Modified Files
--
src/bin/pg_archivecleanup/pg_archivecleanup.c | 11 ++-
src/bin/pg_basebackup/pg_basebackup.c |  6 ++
src/bin/pg_basebackup/pg_recvlogical.c|  3 +++
src/bin/pgbench/pgbench.c |  3 +++
4 files changed, 22 insertions(+), 1 deletion(-)



pgsql: Fix typo in tab-complete.c

2021-07-28 Thread Michael Paquier
Fix typo in tab-complete.c

Introduced in b048326.

Reported-by: Jeff Davis
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/15c6ede04577f856f702bf0a032297de667f382a

Modified Files
--
src/bin/psql/tab-complete.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)