pgsql: Rename functions to avoid future conflicts

2022-01-10 Thread Peter Eisentraut
Rename functions to avoid future conflicts

Rename range_serialize/range_deserialize to
brin_range_serialize/brin_range_deserialize, since there are already
public range_serialize/range_deserialize in rangetypes.h.

Author: Paul A. Jungwirth 
Discussion: 
https://www.postgresql.org/message-id/ca+renyx0ipvy6a_juoheb1q9ml4beyfaz5fbb7g7juo5byk...@mail.gmail.com

Branch
--
master

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

Modified Files
--
src/backend/access/brin/brin_minmax_multi.c | 28 ++--
1 file changed, 14 insertions(+), 14 deletions(-)



pgsql: Make EXEC_BACKEND more convenient on Linux and FreeBSD.

2022-01-10 Thread Thomas Munro
Make EXEC_BACKEND more convenient on Linux and FreeBSD.

Try to disable ASLR when building in EXEC_BACKEND mode, to avoid random
memory mapping failures while testing.  For developer use only, no
effect on regular builds.

Suggested-by: Andres Freund 
Tested-by: Bossart, Nathan 
Discussion: 
https://postgr.es/m/20210806032944.m4tz7j2w47mant26%40alap3.anarazel.de

Branch
--
master

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

Modified Files
--
configure |  2 +-
configure.ac  |  1 +
src/bin/pg_ctl/pg_ctl.c   |  4 
src/common/exec.c | 33 +
src/include/pg_config.h.in|  3 +++
src/include/port.h|  5 +
src/test/regress/pg_regress.c |  4 
src/tools/msvc/Solution.pm|  1 +
8 files changed, 52 insertions(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/1cd46f168fda4d819e315eacf3d4f3d5aa84859c

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
REL_13_STABLE

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

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/03c545b66f748b9318d13bbc90f05f136a465484

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/90657b42bfd592d906989023886ff2875ff2ae95

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
REL_10_STABLE

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

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Avoid warning about uninitialized value in MSVC python3 tests

2022-01-10 Thread Andrew Dunstan
Avoid warning about uninitialized value in MSVC python3 tests

Juan José Santamaría Flecha

Backpatch to all live branches

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/5b2cb9c29e09419bcce2e1be47a78a7e3d0a1156

Modified Files
--
src/tools/msvc/vcregress.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/790d6edf639a8c6cb12eb9f81069349c28767976

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/9a8b1b6777178c76c48043c3d7bfbe911d2ee577

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/850c704c72a2e86c682948a36c65c1bd6618829f

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/05cdda68f8f6e63cb87bc1776236d7619cd89fb7

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/2180833ba90e9657a7e622b419194763890c8a6d

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Doc: fix bogus example about ambiguous timestamps.

2022-01-10 Thread Tom Lane
Doc: fix bogus example about ambiguous timestamps.

I had a brain fade in commit d32899157, and used 2:30AM as the
example timestamp for both spring-forward and fall-back cases.
But it's not actually ambiguous at all in the fall-back case,
because that transition is from 2AM to 1AM under USA rules.
Fix the example to use 1:30AM, which *is* ambiguous.

Noted while answering a question from Aleksander Alekseev.
Back-patch to all supported branches.

Discussion: https://postgr.es/m/2191355.1641828...@sss.pgh.pa.us

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/9ef2c68bb1ec20c4f87850d9322420e35acb

Modified Files
--
doc/src/sgml/datetime.sgml | 20 +---
1 file changed, 9 insertions(+), 11 deletions(-)



pgsql: Improve error handling of cryptohash computations

2022-01-10 Thread Michael Paquier
Improve error handling of cryptohash computations

The existing cryptohash facility was causing problems in some code paths
related to MD5 (frontend and backend) that relied on the fact that the
only type of error that could happen would be an OOM, as the MD5
implementation used in PostgreSQL ~13 (the in-core implementation is
used when compiling with or without OpenSSL in those older versions),
could fail only under this circumstance.

The new cryptohash facilities can fail for reasons other than OOMs, like
attempting MD5 when FIPS is enabled (upstream OpenSSL allows that up to
1.0.2, Fedora and Photon patch OpenSSL 1.1.1 to allow that), so this
would cause incorrect reports to show up.

This commit extends the cryptohash APIs so as callers of those routines
can fetch more context when an error happens, by using a new routine
called pg_cryptohash_error().  The error states are stored within each
implementation's internal context data, so as it is possible to extend
the logic depending on what's suited for an implementation.  The default
implementation requires few error states, but OpenSSL could report
various issues depending on its internal state so more is needed in
cryptohash_openssl.c, and the code is shaped so as we are always able to
grab the necessary information.

The core code is changed to adapt to the new error routine, painting
more "const" across the call stack where the static errors are stored,
particularly in authentication code paths on variables that provide
log details.  This way, any future changes would warn if attempting to
free these strings.  The MD5 authentication code was also a bit blurry
about the handling of "logdetail" (LOG sent to the postmaster), so
improve the comments related that, while on it.

The origin of the problem is 87ae969, that introduced the centralized
cryptohash facility.  Extra changes are done for pgcrypto in v14 for the
non-OpenSSL code path to cope with the improvements done by this
commit.

Reported-by: Michael Mühlbeyer
Author: Michael Paquier
Reviewed-by: Tom Lane
Discussion: 
https://postgr.es/m/89b7f072-5bbe-4c92-903e-d83e865d9...@trivadis.com
Backpatch-through: 14

Branch
--
REL_14_STABLE

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

Modified Files
--
contrib/passwordcheck/passwordcheck.c |  2 +-
contrib/pgcrypto/internal-sha2.c  |  9 ++-
contrib/pgcrypto/internal.c   | 18 --
contrib/uuid-ossp/uuid-ossp.c | 18 --
src/backend/commands/user.c   |  4 +-
src/backend/libpq/auth-scram.c|  2 +-
src/backend/libpq/auth.c  | 36 +++-
src/backend/libpq/crypt.c | 38 ++---
src/backend/replication/backup_manifest.c |  9 ++-
src/backend/utils/adt/cryptohashfuncs.c   | 25 ++---
src/common/cryptohash.c   | 57 ++-
src/common/cryptohash_openssl.c   | 93 +++
src/common/md5_common.c   | 20 +--
src/include/common/cryptohash.h   |  1 +
src/include/common/md5.h  |  9 ++-
src/include/libpq/crypt.h |  7 ++-
src/include/libpq/scram.h |  3 +-
src/interfaces/libpq/fe-auth.c| 22 ++--
src/tools/pgindent/typedefs.list  |  1 +
19 files changed, 290 insertions(+), 84 deletions(-)



pgsql: Improve error handling of cryptohash computations

2022-01-10 Thread Michael Paquier
Improve error handling of cryptohash computations

The existing cryptohash facility was causing problems in some code paths
related to MD5 (frontend and backend) that relied on the fact that the
only type of error that could happen would be an OOM, as the MD5
implementation used in PostgreSQL ~13 (the in-core implementation is
used when compiling with or without OpenSSL in those older versions),
could fail only under this circumstance.

The new cryptohash facilities can fail for reasons other than OOMs, like
attempting MD5 when FIPS is enabled (upstream OpenSSL allows that up to
1.0.2, Fedora and Photon patch OpenSSL 1.1.1 to allow that), so this
would cause incorrect reports to show up.

This commit extends the cryptohash APIs so as callers of those routines
can fetch more context when an error happens, by using a new routine
called pg_cryptohash_error().  The error states are stored within each
implementation's internal context data, so as it is possible to extend
the logic depending on what's suited for an implementation.  The default
implementation requires few error states, but OpenSSL could report
various issues depending on its internal state so more is needed in
cryptohash_openssl.c, and the code is shaped so as we are always able to
grab the necessary information.

The core code is changed to adapt to the new error routine, painting
more "const" across the call stack where the static errors are stored,
particularly in authentication code paths on variables that provide
log details.  This way, any future changes would warn if attempting to
free these strings.  The MD5 authentication code was also a bit blurry
about the handling of "logdetail" (LOG sent to the postmaster), so
improve the comments related that, while on it.

The origin of the problem is 87ae969, that introduced the centralized
cryptohash facility.  Extra changes are done for pgcrypto in v14 for the
non-OpenSSL code path to cope with the improvements done by this
commit.

Reported-by: Michael Mühlbeyer
Author: Michael Paquier
Reviewed-by: Tom Lane
Discussion: 
https://postgr.es/m/89b7f072-5bbe-4c92-903e-d83e865d9...@trivadis.com
Backpatch-through: 14

Branch
--
master

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

Modified Files
--
contrib/passwordcheck/passwordcheck.c |  2 +-
contrib/uuid-ossp/uuid-ossp.c | 18 --
src/backend/commands/user.c   |  4 +-
src/backend/libpq/auth-sasl.c |  2 +-
src/backend/libpq/auth-scram.c|  5 +-
src/backend/libpq/auth.c  | 33 ++-
src/backend/libpq/crypt.c | 38 ++---
src/backend/replication/backup_manifest.c | 11 ++--
src/backend/utils/adt/cryptohashfuncs.c   | 25 ++---
src/common/cryptohash.c   | 57 ++-
src/common/cryptohash_openssl.c   | 93 +++
src/common/md5_common.c   | 20 +--
src/include/common/cryptohash.h   |  1 +
src/include/common/md5.h  |  9 ++-
src/include/libpq/crypt.h |  7 ++-
src/include/libpq/sasl.h  |  4 +-
src/interfaces/libpq/fe-auth.c| 22 ++--
src/tools/pgindent/typedefs.list  |  1 +
18 files changed, 275 insertions(+), 77 deletions(-)



Re: pgsql: Create foreign key triggers in partitioned tables too

2022-01-10 Thread Amit Langote
On Thu, Jan 6, 2022 at 7:46 AM Tom Lane  wrote:
> Alvaro Herrera  writes:
> > This also changes what tgisinternal means in some cases.  Currently,
> > it means either that the trigger is an internal implementation object
> > of a foreign key constraint, or a "child" trigger on a partition
> > cloned from the trigger on the parent.  This commit changes it to
> > only mean the former to avoid confusion.
>
> Hmm, perhaps the column's description in catalogs.sgml deserves
> an update?

tginternal's description in catalogs.sgml is this:

 
  
   tgisinternal bool
  
  
   True if trigger is internally generated (usually, to enforce
   the constraint identified by tgconstraint)
  
 

which matches what the commit restores tgisinternal's meaning to.  I
guess we forgot in 86f575948c77 to update this to mention
tgisinternal's relation to partitioning?

-- 
Amit Langote
EDB: http://www.enterprisedb.com




pgsql: Fix typo in rewriteheap.c.

2022-01-10 Thread Amit Kapila
Fix typo in rewriteheap.c.

Author: Bharath Rupireddy
Discussion: 
https://postgr.es/m/calj2acw7svffw8r2ukh6oqm1knpt8aqmg61ksbpk0s2phhf...@mail.gmail.com

Branch
--
master

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

Modified Files
--
src/backend/access/heap/rewriteheap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Update docs of logical replication for commit 8d74fc96db.

2022-01-10 Thread Amit Kapila
Update docs of logical replication for commit 8d74fc96db.

After commit 8d74fc96db, the details of logical replication conflicts can
be found in pg_stat_subscription_workers view.

Author: Masahiko Sawada
Reviewed-by: Amit Kapila
Discussion: 
https://postgr.es/m/cad21aoc+zm5tgn8x88ajzycx0g_eieuu5xdrksnmser3xzw...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/85c61ba8920ba73500e1518c63795982ee455d14

Modified Files
--
doc/src/sgml/logical-replication.sgml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)