pgsql: Fix underspecified sort order in inherit.sql

2023-04-07 Thread Andres Freund
Fix underspecified sort order in inherit.sql

Introduced in e056c557aef4.

Per buildfarm member prion.

Branch
--
master

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

Modified Files
--
src/test/regress/expected/inherit.out | 9 ++---
src/test/regress/sql/inherit.sql  | 9 ++---
2 files changed, 12 insertions(+), 6 deletions(-)



pgsql: Prevent use of invalidated logical slot in CreateDecodingContext

2023-04-07 Thread Andres Freund
Prevent use of invalidated logical slot in CreateDecodingContext()

Previously we had checks for this in multiple places. Support for logical
decoding on standbys will add other forms of invalidation, making it worth
while to centralize the checks.

This slightly changes the error message for both the walsender and SQL
interface. Particularly the SQL interface error was inaccurate, as the "This
slot has never previously reserved WAL" portion was unreachable.

Reviewed-by: "Drouvot, Bertrand" 
Reviewed-by: Melanie Plageman 
Discussion: 
https://postgr.es/m/20230407075009.igg7be27ha2ht...@awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4397abd0a2af955326c0608d63f3716ce5901004

Modified Files
--
src/backend/replication/logical/logical.c  | 16 
src/backend/replication/logical/logicalfuncs.c | 13 -
src/backend/replication/walsender.c|  7 ---
3 files changed, 16 insertions(+), 20 deletions(-)



pgsql: Replace replication slot's invalidated_at LSN with an enum

2023-04-07 Thread Andres Freund
Replace replication slot's invalidated_at LSN with an enum

This is mainly useful because the upcoming logical-decoding-on-standby feature
adds further reasons for invalidating slots, and we don't want to end up with
multiple invalidated_* fields, or check different attributes.

Eventually we should consider not resetting restart_lsn when invalidating a
slot due to max_slot_wal_keep_size. But that's a user visible change, so left
for later.

Increases SLOT_VERSION, due to the changed field (with a different alignment,
no less).

Reviewed-by: "Drouvot, Bertrand" 
Reviewed-by: Alvaro Herrera 
Reviewed-by: Melanie Plageman 
Discussion: 
https://postgr.es/m/20230407075009.igg7be27ha2ht...@awork3.anarazel.de

Branch
--
master

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

Modified Files
--
src/backend/replication/slot.c  | 28 
src/backend/replication/slotfuncs.c |  8 +++-
src/include/replication/slot.h  | 15 +--
src/tools/pgindent/typedefs.list|  1 +
4 files changed, 41 insertions(+), 11 deletions(-)



pgsql: Introduce PG_IO_ALIGN_SIZE and align all I/O buffers.

2023-04-07 Thread Thomas Munro
Introduce PG_IO_ALIGN_SIZE and align all I/O buffers.

In order to have the option to use O_DIRECT/FILE_FLAG_NO_BUFFERING in a
later commit, we need the addresses of user space buffers to be well
aligned.  The exact requirements vary by OS and file system (typically
sectors and/or memory pages).  The address alignment size is set to
4096, which is enough for currently known systems: it matches modern
sectors and common memory page size.  There is no standard governing
O_DIRECT's requirements so we might eventually have to reconsider this
with more information from the field or future systems.

Aligning I/O buffers on memory pages is also known to improve regular
buffered I/O performance.

Three classes of I/O buffers for regular data pages are adjusted:
(1) Heap buffers are now allocated with the new palloc_aligned() or
MemoryContextAllocAligned() functions introduced by commit 439f6175.
(2) Stack buffers now use a new struct PGIOAlignedBlock to respect
PG_IO_ALIGN_SIZE, if possible with this compiler.  (3) The buffer
pool is also aligned in shared memory.

WAL buffers were already aligned on XLOG_BLCKSZ.  It's possible for
XLOG_BLCKSZ to be configured smaller than PG_IO_ALIGNED_SIZE and thus
for O_DIRECT WAL writes to fail to be well aligned, but that's a
pre-existing condition and will be addressed by a later commit.

BufFiles are not yet addressed (there's no current plan to use O_DIRECT
for those, but they could potentially get some incidental speedup even
in plain buffered I/O operations through better alignment).

If we can't align stack objects suitably using the compiler extensions
we know about, we disable the use of O_DIRECT by setting PG_O_DIRECT to
0.  This avoids the need to consider systems that have O_DIRECT but
can't align stack objects the way we want; such systems could in theory
be supported with more work but we don't currently know of any such
machines, so it's easier to pretend there is no O_DIRECT support
instead.  That's an existing and tested class of system.

Add assertions that all buffers passed into smgrread(), smgrwrite() and
smgrextend() are correctly aligned, unless PG_O_DIRECT is 0 (= stack
alignment tricks may be unavailable) or the block size has been set too
small to allow arrays of buffers to be all aligned.

Author: Thomas Munro 
Author: Andres Freund 
Reviewed-by: Justin Pryzby 
Discussion: 
https://postgr.es/m/ca+hukgk1x532hyqj_mzfwt0n1zt8trz980d79wbjwnt-yyl...@mail.gmail.com

Branch
--
master

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

Modified Files
--
contrib/bloom/blinsert.c  |  2 +-
contrib/pg_prewarm/pg_prewarm.c   |  2 +-
src/backend/access/gist/gistbuild.c   |  9 
src/backend/access/hash/hashpage.c|  2 +-
src/backend/access/heap/rewriteheap.c |  2 +-
src/backend/access/nbtree/nbtree.c|  2 +-
src/backend/access/nbtree/nbtsort.c   |  8 +---
src/backend/access/spgist/spginsert.c |  2 +-
src/backend/access/transam/generic_xlog.c | 13 
src/backend/access/transam/xlog.c |  2 +-
src/backend/catalog/storage.c |  2 +-
src/backend/storage/buffer/buf_init.c | 10 ++---
src/backend/storage/buffer/bufmgr.c   |  2 +-
src/backend/storage/buffer/localbuf.c |  7 +--
src/backend/storage/file/buffile.c|  6 ++
src/backend/storage/page/bufpage.c|  5 -
src/backend/storage/smgr/md.c | 15 +-
src/backend/utils/sort/logtape.c  |  2 +-
src/bin/pg_checksums/pg_checksums.c   |  2 +-
src/bin/pg_rewind/local_source.c  |  4 ++--
src/bin/pg_upgrade/file.c |  4 ++--
src/common/file_utils.c   |  4 ++--
src/include/c.h   | 34 +++
src/include/pg_config_manual.h|  6 ++
src/include/storage/fd.h  |  5 +++--
src/tools/pgindent/typedefs.list  |  1 +
26 files changed, 108 insertions(+), 45 deletions(-)



pgsql: Add io_direct setting (developer-only).

2023-04-07 Thread Thomas Munro
Add io_direct setting (developer-only).

Provide a way to ask the kernel to use O_DIRECT (or local equivalent)
where available for data and WAL files, to avoid or minimize kernel
caching.  This hurts performance currently and is not intended for end
users yet.  Later proposed work would introduce our own I/O clustering,
read-ahead, etc to replace the facilities the kernel disables with this
option.

The only user-visible change, if the developer-only GUC is not used, is
that this commit also removes the obscure logic that would activate
O_DIRECT for the WAL when wal_sync_method=open_[data]sync and
wal_level=minimal (which also requires max_wal_senders=0).  Those are
non-default and unlikely settings, and this behavior wasn't (correctly)
documented.  The same effect can be achieved with io_direct=wal.

Author: Thomas Munro 
Author: Andres Freund 
Author: Bharath Rupireddy 
Reviewed-by: Justin Pryzby 
Reviewed-by: Bharath Rupireddy 
Discussion: 
https://postgr.es/m/CA%2BhUKGK1X532hYqJ_MzFWt0n1zt8trz980D79WbjwnT-yYLZpg%40mail.gmail.com

Branch
--
master

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

Modified Files
--
doc/src/sgml/config.sgml  | 33 -
src/backend/access/transam/xlog.c | 37 +-
src/backend/access/transam/xlogprefetcher.c   |  2 +-
src/backend/storage/buffer/bufmgr.c   | 16 +++--
src/backend/storage/buffer/localbuf.c |  7 +-
src/backend/storage/file/fd.c | 98 +++
src/backend/storage/smgr/md.c | 24 +--
src/backend/storage/smgr/smgr.c   |  1 +
src/backend/utils/misc/guc_tables.c   | 12 
src/include/storage/fd.h  |  7 ++
src/include/storage/smgr.h|  1 +
src/include/utils/guc_hooks.h |  2 +
src/test/modules/test_misc/meson.build|  1 +
src/test/modules/test_misc/t/004_io_direct.pl | 57 
14 files changed, 263 insertions(+), 35 deletions(-)



pgsql: Doc: Fix the datatype of the newly added SUBSCRIPTION options.

2023-04-07 Thread Amit Kapila
Doc: Fix the datatype of the newly added SUBSCRIPTION options.

In docs, the datatype of "password_required" and "run_as_owner" was
incorrectly specified as a string.

Author: Amit Kapila
Reviewed-by: Sawada Masahiko
Discussion: 
https://postgr.es/m/CAHut+Pu=pnJf=ss1583pknsq3cboqlckwcjcqyt6zxtaghe...@mail.gmail.com

Branch
--
master

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

Modified Files
--
doc/src/sgml/ref/create_subscription.sgml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Add missing .gitignore entry.

2023-04-07 Thread Tom Lane
Add missing .gitignore entry.

Seems an oversight in 7d8219a44.  Fix before somebody commits
a generated file.

Branch
--
master

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

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



pgsql: Remove useless dependencies in daitch_mokotoff_header.pl.

2023-04-07 Thread Tom Lane
Remove useless dependencies in daitch_mokotoff_header.pl.

Actually, the correct fix for this is "we don't need this at all",
because this program isn't dealing in any non-ASCII data.  The
dependency on Data::Dumper seems to be a leftover too.

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

Branch
--
master

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

Modified Files
--
contrib/fuzzystrmatch/daitch_mokotoff_header.pl | 4 
1 file changed, 4 deletions(-)



pgsql: Add support for Kerberos credential delegation

2023-04-07 Thread Stephen Frost
Add support for Kerberos credential delegation

Support GSSAPI/Kerberos credentials being delegated to the server by a
client.  With this, a user authenticating to PostgreSQL using Kerberos
(GSSAPI) credentials can choose to delegate their credentials to the
PostgreSQL server (which can choose to accept them, or not), allowing
the server to then use those delegated credentials to connect to
another service, such as with postgres_fdw or dblink or theoretically
any other service which is able to be authenticated using Kerberos.

Both postgres_fdw and dblink are changed to allow non-superuser
password-less connections but only when GSSAPI credentials have been
delegated to the server by the client and GSSAPI is used to
authenticate to the remote system.

Authors: Stephen Frost, Peifeng Qiu
Reviewed-By: David Christensen
Discussion: 
https://postgr.es/m/co1pr05mb8023cc2cb575e0faad7df4f8a8...@co1pr05mb8023.namprd05.prod.outlook.com

Branch
--
master

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

Modified Files
--
contrib/dblink/dblink.c| 127 ++
contrib/dblink/expected/dblink.out |   4 +-
contrib/postgres_fdw/connection.c  |  72 --
contrib/postgres_fdw/expected/postgres_fdw.out |  19 +-
contrib/postgres_fdw/option.c  |   6 +
contrib/postgres_fdw/sql/postgres_fdw.sql  |   3 +-
doc/src/sgml/config.sgml   |  17 ++
doc/src/sgml/dblink.sgml   |   5 +-
doc/src/sgml/libpq.sgml|  41 +++
doc/src/sgml/monitoring.sgml   |   9 +
doc/src/sgml/postgres-fdw.sgml |   7 +-
src/backend/catalog/system_views.sql   |   3 +-
src/backend/foreign/foreign.c  |   1 +
src/backend/libpq/auth.c   |  13 +-
src/backend/libpq/be-gssapi-common.c   |  53 
src/backend/libpq/be-secure-gssapi.c   |  26 +-
src/backend/utils/activity/backend_status.c|   1 +
src/backend/utils/adt/pgstatfuncs.c|  21 +-
src/backend/utils/init/postinit.c  |   8 +-
src/backend/utils/misc/guc_tables.c|  10 +
src/backend/utils/misc/postgresql.conf.sample  |   1 +
src/include/catalog/pg_proc.dat|   6 +-
src/include/libpq/auth.h   |   1 +
src/include/libpq/be-gssapi-common.h   |   3 +
src/include/libpq/libpq-be.h   |   2 +
src/include/utils/backend_status.h |   1 +
src/interfaces/libpq/exports.txt   |   1 +
src/interfaces/libpq/fe-auth.c |  15 +-
src/interfaces/libpq/fe-connect.c  |  17 ++
src/interfaces/libpq/fe-secure-gssapi.c|  23 +-
src/interfaces/libpq/libpq-fe.h|   1 +
src/interfaces/libpq/libpq-int.h   |   2 +
src/test/kerberos/Makefile |   3 +
src/test/kerberos/t/001_auth.pl| 331 ++---
src/test/perl/PostgreSQL/Test/Utils.pm |  27 ++
src/test/regress/expected/rules.out|  11 +-
36 files changed, 755 insertions(+), 136 deletions(-)



pgsql: Pacify perlcritic.

2023-04-07 Thread Tom Lane
Pacify perlcritic.

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

Branch
--
master

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

Modified Files
--
contrib/fuzzystrmatch/daitch_mokotoff_header.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Track IO times in pg_stat_io

2023-04-07 Thread Andres Freund
Track IO times in pg_stat_io

a9c70b46dbe and 8aaa04b32S added counting of IO operations to a new view,
pg_stat_io. Now, add IO timing for reads, writes, extends, and fsyncs to
pg_stat_io as well.

This combines the tracking for pgBufferUsage with the tracking for pg_stat_io
into a new function pgstat_count_io_op_time(). This should make it a bit
easier to avoid the somewhat costly instr_time conversion done for
pgBufferUsage.

Author: Melanie Plageman 
Reviewed-by: Andres Freund 
Reviewed-by: Bertrand Drouvot 
Discussion: 
https://postgr.es/m/flat/CAAKRu_ay5iKmnbXZ3DsauViF3eMxu4m1oNnJXqV_HyqYeg55Ww%40mail.gmail.com

Branch
--
master

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

Modified Files
--
doc/src/sgml/monitoring.sgml   |  59 ++
src/backend/catalog/system_views.sql   |   4 ++
src/backend/storage/buffer/bufmgr.c|  66 ++--
src/backend/storage/buffer/localbuf.c  |  31 --
src/backend/storage/smgr/md.c  |  31 ++
src/backend/utils/activity/pgstat_io.c | 107 +++--
src/backend/utils/adt/pgstatfuncs.c|  64 ++--
src/include/catalog/pg_proc.dat|   6 +-
src/include/pgstat.h   |   7 ++-
src/test/regress/expected/rules.out|   6 +-
src/tools/pgindent/typedefs.list   |   1 +
11 files changed, 275 insertions(+), 107 deletions(-)



pgsql: Show more detail in nbtree rmgr descriptions.

2023-04-07 Thread Peter Geoghegan
Show more detail in nbtree rmgr descriptions.

Show a detailed description of the page offset number arrays that appear
in certain nbtree WAL records.

Also brings nbtree desc routines in line with the guidelines established
by recent commit 7d8219a4.

Author: Melanie Plageman 
Reviewed-By: Peter Geoghegan 
Discussion: 
https://postgr.es/m/flat/20230109215842.fktuhesvayno6o4g%40awork3.anarazel.de

Branch
--
master

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

Modified Files
--
src/backend/access/rmgrdesc/nbtdesc.c| 87 
src/backend/access/rmgrdesc/rmgrdesc_utils.c |  6 ++
src/include/access/rmgrdesc_utils.h  |  1 +
3 files changed, 83 insertions(+), 11 deletions(-)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
REL_12_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable reverse DNS lookup

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable reverse DNS lookup

In our Kerberos test suite, there isn't much need to worry about the
normal canonicalization that Kerberos provides by looking up the reverse
DNS for the IP address connected to, and in some cases it can actively
cause problems (eg: a captive portal wifi where the normally not
resolvable localhost address used ends up being resolved anyway, and
not to the domain we are using for testing, causing the entire
regression test to fail with errors about not being able to get a TGT
for the remote realm for cross-realm trust).

Therefore, disable it by adding rdns = false into the krb5.conf that's
generated for the test.

Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/Y/qd2zdkdyqa1...@tamriel.snowman.net

Branch
--
REL_11_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 12 
1 file changed, 12 insertions(+)



pgsql: For Kerberos testing, disable reverse DNS lookup

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable reverse DNS lookup

In our Kerberos test suite, there isn't much need to worry about the
normal canonicalization that Kerberos provides by looking up the reverse
DNS for the IP address connected to, and in some cases it can actively
cause problems (eg: a captive portal wifi where the normally not
resolvable localhost address used ends up being resolved anyway, and
not to the domain we are using for testing, causing the entire
regression test to fail with errors about not being able to get a TGT
for the remote realm for cross-realm trust).

Therefore, disable it by adding rdns = false into the krb5.conf that's
generated for the test.

Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/Y/qd2zdkdyqa1...@tamriel.snowman.net

Branch
--
REL_13_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 12 
1 file changed, 12 insertions(+)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
REL_15_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/52d83e927015ddfc7fdbc5bb65d555cdd0355522

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/154bcce3ba9d9817bdb5bd628b611d56fc434c46

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/0a46b2f89e188c9139fc095c0da0c145bec12f3d

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable DNS lookups

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable DNS lookups

Similar to 8dff2f224, this disables DNS lookups by the Kerberos library
to look up the KDC and the realm while the Kerberos tests are running.
In some environments, these lookups can take a long time and end up
timing out and causing tests to fail.  Further, since this isn't really
our domain, we shouldn't be sending out these DNS requests during our
tests.

Branch
--
master

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 7 +++
1 file changed, 7 insertions(+)



pgsql: For Kerberos testing, disable reverse DNS lookup

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable reverse DNS lookup

In our Kerberos test suite, there isn't much need to worry about the
normal canonicalization that Kerberos provides by looking up the reverse
DNS for the IP address connected to, and in some cases it can actively
cause problems (eg: a captive portal wifi where the normally not
resolvable localhost address used ends up being resolved anyway, and
not to the domain we are using for testing, causing the entire
regression test to fail with errors about not being able to get a TGT
for the remote realm for cross-realm trust).

Therefore, disable it by adding rdns = false into the krb5.conf that's
generated for the test.

Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/Y/qd2zdkdyqa1...@tamriel.snowman.net

Branch
--
REL_12_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 12 
1 file changed, 12 insertions(+)



pgsql: For Kerberos testing, disable reverse DNS lookup

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable reverse DNS lookup

In our Kerberos test suite, there isn't much need to worry about the
normal canonicalization that Kerberos provides by looking up the reverse
DNS for the IP address connected to, and in some cases it can actively
cause problems (eg: a captive portal wifi where the normally not
resolvable localhost address used ends up being resolved anyway, and
not to the domain we are using for testing, causing the entire
regression test to fail with errors about not being able to get a TGT
for the remote realm for cross-realm trust).

Therefore, disable it by adding rdns = false into the krb5.conf that's
generated for the test.

Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/Y/qd2zdkdyqa1...@tamriel.snowman.net

Branch
--
REL_14_STABLE

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

Modified Files
--
src/test/kerberos/t/001_auth.pl | 12 
1 file changed, 12 insertions(+)



pgsql: For Kerberos testing, disable reverse DNS lookup

2023-04-07 Thread Stephen Frost
For Kerberos testing, disable reverse DNS lookup

In our Kerberos test suite, there isn't much need to worry about the
normal canonicalization that Kerberos provides by looking up the reverse
DNS for the IP address connected to, and in some cases it can actively
cause problems (eg: a captive portal wifi where the normally not
resolvable localhost address used ends up being resolved anyway, and
not to the domain we are using for testing, causing the entire
regression test to fail with errors about not being able to get a TGT
for the remote realm for cross-realm trust).

Therefore, disable it by adding rdns = false into the krb5.conf that's
generated for the test.

Reviewed-By: Heikki Linnakangas
Discussion: https://postgr.es/m/Y/qd2zdkdyqa1...@tamriel.snowman.net

Branch
--
REL_15_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/0787432f33fbbda4f628f4499468a3f7d0bc11ad

Modified Files
--
src/test/kerberos/t/001_auth.pl | 12 
1 file changed, 12 insertions(+)



pgsql: Show more detail in heapam rmgr descriptions.

2023-04-07 Thread Peter Geoghegan
Show more detail in heapam rmgr descriptions.

Add helper functions that output arrays in a standard format, and use
the functions inside heapdesc routines.  This allows tools like
pg_walinspect to show a detailed description of the page offset number
arrays for records like PRUNE and VACUUM (unless there was an FPI).

Also document the conventions that desc routines should follow.  Only
the heapdesc routines follow the conventions for now, so they're just
guidelines for the time being.

Based on a suggestion from Andres Freund.

Author: Melanie Plageman 
Reviewed-By: Peter Geoghegan 
Discussion: 
https://postgr.es/m/flat/20230109215842.fktuhesvayno6o4g%40awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/7d8219a444bd917d21234c97e2417a410f10ebd3

Modified Files
--
doc/src/sgml/pgwalinspect.sgml   |  22 ++--
src/backend/access/rmgrdesc/Makefile |   1 +
src/backend/access/rmgrdesc/heapdesc.c   | 155 ++-
src/backend/access/rmgrdesc/meson.build  |   1 +
src/backend/access/rmgrdesc/rmgrdesc_utils.c |  84 +++
src/bin/pg_waldump/Makefile  |   2 +-
src/include/access/rmgrdesc_utils.h  |  22 
7 files changed, 247 insertions(+), 40 deletions(-)



pgsql: Adjust contrib/sepgsql regression test expected outputs.

2023-04-07 Thread Tom Lane
Adjust contrib/sepgsql regression test expected outputs.

Per buildfarm, the log output has changed as a consequence of
commit e056c557a changing the catalog accesses performed in
some commands.

Discussion: 
https://postgr.es/m/20230407211950.aojbdirwdrxje...@awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/76c111a7f16659f9018391f655764c8226461ca4

Modified Files
--
contrib/sepgsql/expected/alter.out | 12 
contrib/sepgsql/expected/ddl.out   |  2 ++
2 files changed, 2 insertions(+), 12 deletions(-)



pgsql: Add support for Daitch-Mokotoff Soundex in contrib/fuzzystrmatch

2023-04-07 Thread Tom Lane
Add support for Daitch-Mokotoff Soundex in contrib/fuzzystrmatch.

This modernized version of Soundex works significantly better than
the original, particularly for non-English names.

Dag Lem, reviewed by quite a few people along the way

Discussion: https://postgr.es/m/yger1atbgfy@sid.nimrod.no

Branch
--
master

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

Modified Files
--
contrib/fuzzystrmatch/.gitignore   |   2 +
contrib/fuzzystrmatch/Makefile |  20 +-
contrib/fuzzystrmatch/daitch_mokotoff.c| 577 +
contrib/fuzzystrmatch/daitch_mokotoff_header.pl| 223 
contrib/fuzzystrmatch/expected/fuzzystrmatch.out   | 171 ++
.../fuzzystrmatch/expected/fuzzystrmatch_utf8.out  |  61 +++
.../expected/fuzzystrmatch_utf8_1.out  |   8 +
contrib/fuzzystrmatch/fuzzystrmatch--1.1--1.2.sql  |   8 +
contrib/fuzzystrmatch/fuzzystrmatch.control|   2 +-
contrib/fuzzystrmatch/meson.build  |  14 +-
contrib/fuzzystrmatch/sql/fuzzystrmatch.sql|  45 ++
contrib/fuzzystrmatch/sql/fuzzystrmatch_utf8.sql   |  26 +
doc/src/sgml/fuzzystrmatch.sgml| 169 +-
13 files changed, 1315 insertions(+), 11 deletions(-)



pgsql: Fix table name clash in recently introduced test

2023-04-07 Thread Andres Freund
Fix table name clash in recently introduced test

A few buildfarm animals recently started complaining about the "child"
relation already existing. e056c557aef added a new child table to inherit.sql,
but triggers.sql, running in the same parallel group, also uses a child table.

Rename the new table to inh_child. It maybe worth renaming child, parent in
other tests as well, but that's work for another day.

Discussion: 
https://postgr.es/m/20230407204530.52q3v5cu5x6dj...@awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/728015a47016dcd734c516e43f326ae491b6a3d2

Modified Files
--
src/test/regress/expected/inherit.out | 16 
src/test/regress/sql/inherit.sql  |  6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)



pgsql: Improve IO accounting for temp relation writes

2023-04-07 Thread Andres Freund
Improve IO accounting for temp relation writes

Both pgstat_database and pgBufferUsage count IO timing for reads of temporary
relation blocks into local buffers. However, both failed to count write IO
timing for flushes of dirty local buffers. Fix.

Additionally, FlushRelationBuffers() seems to have omitted counting write
IO (both count and timing) stats for both pgstat_database and
pgBufferUsage. Fix.

Author: Melanie Plageman 
Reviewed-by: Andres Freund 
Discussion: 
https://postgr.es/m/20230321023451.7rzy4kjj2iktrg2r%40awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/704261ecc694db11d9b5feb4f05f57778214ba2f

Modified Files
--
src/backend/storage/buffer/bufmgr.c   | 17 +
src/backend/storage/buffer/localbuf.c | 16 
2 files changed, 33 insertions(+)



pgsql: Test SCRAM iteration changes with psql \password

2023-04-07 Thread Daniel Gustafsson
Test SCRAM iteration changes with psql \password

A version of this test was included in the original patch for altering
SCRAM iteration count, but was omitted due to how interactive psql TAP
sessions worked before being refactored.

Discussion: 
https://postgr.es/m/20230130194350.zj5v467x4jgqt...@awork3.anarazel.de
Discussion: https://postgr.es/m/f72e7bc7-189f-4b17-bf47-9735eb72c...@yesql.se

Branch
--
master

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

Modified Files
--
src/test/authentication/t/001_password.pl | 26 ++
1 file changed, 26 insertions(+)



pgsql: Refactor background psql TAP functions

2023-04-07 Thread Daniel Gustafsson
Refactor background psql TAP functions

This breaks out the background and interactive psql functionality into a
new class, PostgreSQL::Test::BackgroundPsql.  Sessions are still initiated
via PostgreSQL::Test::Cluster, but once started they can be manipulated by
the new helper functions which intend to make querying easier.  A sample
session for a command which can be expected to finish at a later time can
be seen below.

  my $session = $node->background_psql('postgres');
  $bsession->query_until(qr/start/, q(
\echo start
CREATE INDEX CONCURRENTLY idx ON t(a);
  ));
  $bsession->quit;

Patch by Andres Freund with some additional hacking by me.

Author: Andres Freund 
Reviewed-by: Andrew Dunstan 
Discussion: 
https://postgr.es/m/20230130194350.zj5v467x4jgqt...@awork3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/664d757531e11ea5ef6971884ddb2a7af6fae69a

Modified Files
--
contrib/amcheck/t/003_cic_2pc.pl   |  70 ++---
src/bin/psql/t/010_tab_completion.pl   |  28 +-
src/test/perl/PostgreSQL/Test/BackgroundPsql.pm| 299 +
src/test/perl/PostgreSQL/Test/Cluster.pm   |  79 ++
.../recovery/t/010_logical_decoding_timelines.pl   |   1 -
src/test/recovery/t/031_recovery_conflict.pl   | 102 ++-
src/test/subscription/t/015_stream.pl  |  51 ++--
7 files changed, 388 insertions(+), 242 deletions(-)



pgsql: Fix underspecified sort order in test query

2023-04-07 Thread Alvaro Herrera
Fix underspecified sort order in test query

Fail in e056c557aef4.

Branch
--
master

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

Modified Files
--
src/test/regress/expected/inherit.out | 8 
src/test/regress/sql/inherit.sql  | 4 ++--
2 files changed, 6 insertions(+), 6 deletions(-)



pgsql: Add pg_buffercache_usage_counts() to contrib/pg_buffercache.

2023-04-07 Thread Tom Lane
Add pg_buffercache_usage_counts() to contrib/pg_buffercache.

It was pointed out that pg_buffercache_summary()'s report of
the overall average usage count isn't that useful, and what
would be more helpful in many cases is to report totals for
each possible usage count.  Add a new function to do it like
that.  Since pg_buffercache 1.4 is already new for v16,
we don't need to create a new extension version; we'll just
define this as part of 1.4.

Nathan Bossart

Discussion: https://postgr.es/m/20230130233040.GA2800702@nathanxps13

Branch
--
master

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

Modified Files
--
contrib/pg_buffercache/expected/pg_buffercache.out |  14 +++
.../pg_buffercache/pg_buffercache--1.3--1.4.sql|  11 +++
contrib/pg_buffercache/pg_buffercache_pages.c  |  43 +
contrib/pg_buffercache/sql/pg_buffercache.sql  |   4 +
doc/src/sgml/pgbuffercache.sgml| 105 -
5 files changed, 173 insertions(+), 4 deletions(-)



pgsql: Catalog NOT NULL constraints

2023-04-07 Thread Alvaro Herrera
Catalog NOT NULL constraints

We now create pg_constaint rows for NOT NULL constraints with
contype='n'.

We propagate these constraints during operations such as adding
inheritance relationships, creating and attaching partitions, creating
tables LIKE other tables.  We mostly follow the well-known rules of
conislocal and coninhcount that we have for CHECK constraints, with some
adaptations; for example, as opposed to CHECK constraints, we don't
match NOT NULL ones by name when descending a hierarchy to alter it;
instead we match by column number.  This means we don't require the
constraint names to be identical across a hierarchy.

For now, we omit them from system catalogs.  Maybe this is worth
reconsidering.  We don't support NOT VALID nor DEFERRABLE clauses
either; these can be added as separate features later (this patch is
already large and complicated enough.)

This has been very long in the making.  The first patch was written by
Bernd Helmle in 2010 to add a new pg_constraint.contype value ('n'),
which I (Álvaro) then hijacked in 2011 and 2012, until that one was
killed by the realization that we ought to use contype='c' instead:
manufactured CHECK constraints.  However, later SQL standard
development, as well as nonobvious emergent properties of that design
(mostly, failure to distinguish them from "normal" CHECK constraints as
well as the performance implication of having to test the CHECK
expression) led us to reconsider this choice, so now the current
implementation uses contype='n' again.

In 2016 Vitaly Burovoy also worked on this feature[1] but found no
consensus for his proposed approach, which was claimed to be closer to
the letter of the standard, requiring additional pg_attribute columns to
track the OID of the NOT NULL constraint for that column.
[1] 
https://postgr.es/m/cakoswnkn6hsyatuys8xzxzrcr-kl1okhs5-b9qd9bf1rad3...@mail.gmail.com

Author: Álvaro Herrera 
Author: Bernd Helmle 
Reviewed-by: Justin Pryzby 
Reviewed-by: Peter Eisentraut 

Discussion: https://postgr.es/m/CACA0E642A0267EDA387AF2B%40%5B172.26.14.62%5D
Discussion: 
https://postgr.es/m/aanlktinlxmoemz+0j29tf1pookki4xdkwj6-ddr9b...@mail.gmail.com
Discussion: https://postgr.es/m/20110707213401.ga27...@alvh.no-ip.org
Discussion: https://postgr.es/m/1343682669-sup-2...@alvh.no-ip.org
Discussion: 
https://postgr.es/m/cakoswnkn6hsyatuys8xzxzrcr-kl1okhs5-b9qd9bf1rad3...@mail.gmail.com
Discussion: https://postgr.es/m/20220817181249.q7qvj3okywctra3c@alvherre.pgsql

Branch
--
master

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

Modified Files
--
doc/src/sgml/catalogs.sgml |1 +
doc/src/sgml/ref/alter_table.sgml  |   14 +-
doc/src/sgml/ref/create_table.sgml |8 +-
src/backend/catalog/heap.c |  491 ++--
src/backend/catalog/pg_constraint.c|   97 ++
src/backend/commands/tablecmds.c   | 1326 +++-
src/backend/nodes/outfuncs.c   |4 +
src/backend/nodes/readfuncs.c  |8 +-
src/backend/optimizer/util/plancat.c   |2 +
src/backend/parser/gram.y  |   13 +
src/backend/parser/parse_utilcmd.c |  206 ++-
src/backend/utils/adt/ruleutils.c  |   14 +
src/bin/pg_dump/common.c   |   15 +-
src/bin/pg_dump/pg_backup_archiver.c   |2 +
src/bin/pg_dump/pg_dump.c  |  209 ++-
src/bin/pg_dump/pg_dump.h  |2 +-
src/bin/pg_dump/t/002_pg_dump.pl   |6 +-
src/include/catalog/catversion.h   |2 +-
src/include/catalog/heap.h |7 +-
src/include/catalog/pg_constraint.h|   11 +-
src/include/commands/tablecmds.h   |2 +
src/include/nodes/parsenodes.h |   14 +-
.../test_ddl_deparse/expected/alter_table.out  |   18 +-
.../test_ddl_deparse/expected/create_table.out |   25 +-
.../modules/test_ddl_deparse/test_ddl_deparse.c|4 +
src/test/regress/expected/alter_table.out  |   50 +-
src/test/regress/expected/cluster.out  |7 +-
src/test/regress/expected/constraints.out  |  114 ++
src/test/regress/expected/create_table.out |   27 +-
src/test/regress/expected/event_trigger.out|2 +
src/test/regress/expected/foreign_data.out |   11 +-
src/test/regress/expected/foreign_key.out  |   16 +-
src/test/regress/expected/indexing.out |   41 +-
src/test/regress/expected/inherit.out  |  405 ++
src/test/regress/expected/replica_identity.out |   13 +
src/test/regress/parallel_schedule |3 +-
src/test/regress/sql/alter_table.sql   |   26 +-
src/test/regress/sql/constraints.sql   |   43 +

pgsql: Doc: improve descriptions of max_[pred_]locks_per_transaction GU

2023-04-07 Thread Tom Lane
Doc: improve descriptions of max_[pred_]locks_per_transaction GUCs.

The old wording described these as being multiplied by max_connections
plus max_prepared_transactions, which hasn't been exactly right for
some time thanks to the addition of various auxiliary processes.
Moreover, exactness here is a bit pointless given that the lock tables
can expand into the initially-unallocated "slop" space in shared
memory.  Rather than trying to track exactly what the code is doing,
let's just use the term "server processes".

Likewise adjust these GUCs' description strings in guc_tables.c.

Wang Wei, reviewed by Nathan Bossart and myself

Discussion: 
https://postgr.es/m/os3pr01mb6275bdd09c9b875c65fcc5ab9e...@os3pr01mb6275.jpnprd01.prod.outlook.com

Branch
--
master

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

Modified Files
--
doc/src/sgml/config.sgml| 28 +---
src/backend/utils/misc/guc_tables.c | 10 +-
2 files changed, 18 insertions(+), 20 deletions(-)



pgsql: Add array_sample() and array_shuffle() functions.

2023-04-07 Thread Tom Lane
Add array_sample() and array_shuffle() functions.

These are useful in Monte Carlo applications.

Martin Kalcher, reviewed/adjusted by Daniel Gustafsson and myself

Discussion: 
https://postgr.es/m/9d160a44-7675-51e8-60cf-6d64b76db...@aboutsource.net

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/888f2ea0a81ff171087bdd1c5c1eeda3b78d73d4

Modified Files
--
doc/src/sgml/func.sgml  |  44 -
src/backend/utils/adt/array_userfuncs.c | 166 
src/include/catalog/catversion.h|   2 +-
src/include/catalog/pg_proc.dat |   6 ++
src/test/regress/expected/arrays.out|  54 +++
src/test/regress/sql/arrays.sql |  14 +++
6 files changed, 284 insertions(+), 2 deletions(-)



pgsql: Fix locale-dependent test case.

2023-04-07 Thread Tom Lane
Fix locale-dependent test case.

psql parses the interval argument of \watch with locale-dependent
strtod().  In commit 00beecfe8 I added a test case that exercises
a fractional interval, but I hard-coded 0.01 which doesn't work
in locales where the radix point isn't ".".  We don't want to
change this longstanding parsing behavior, so fix the test case
to generate a suitably locale-aware spelling.

Report and patch by Alexander Korotkov.

Discussion: 
https://postgr.es/m/CAPpHfdv+10Uk6FWjsh3+ju7kHYr76LaRXbYayXmrM7FBU-=h...@mail.gmail.com

Branch
--
master

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

Modified Files
--
src/bin/psql/t/001_basic.pl | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)



Re: pgsql: psql: add an optional execution-count limit to \watch.

2023-04-07 Thread Alexander Korotkov
On Fri, Apr 7, 2023 at 5:00 PM Tom Lane  wrote:
> Alexander Korotkov  writes:
> > On Thu, Apr 6, 2023 at 8:18 PM Tom Lane  wrote:
> >> psql: add an optional execution-count limit to \watch.
>
> > This commit makes tests fail for me.  psql parses 'i' option of
> > '\watch' using locale-aware strtod(), but 001_basic.pl uses hard-coded
> > decimal separator.
>
> Huh, yeah, I see it too if I set LANG=ru_RU.utf8 before running psql's
> TAP tests.  It seems unfortunate that none of the buildfarm has noticed
> this.  I guess all the TAP tests are run under C locale?

I wonder if we can setup as least some buildfarm members to exercise
TAP tests on non-C locales.

> > The proposed fix is attached.
>
> LGTM, will push in a bit (unless you want to?)

Please push.

--
Regards,
Alexander Korotkov




Re: pgsql: psql: add an optional execution-count limit to \watch.

2023-04-07 Thread Tom Lane
Alexander Korotkov  writes:
> On Thu, Apr 6, 2023 at 8:18 PM Tom Lane  wrote:
>> psql: add an optional execution-count limit to \watch.

> This commit makes tests fail for me.  psql parses 'i' option of
> '\watch' using locale-aware strtod(), but 001_basic.pl uses hard-coded
> decimal separator.

Huh, yeah, I see it too if I set LANG=ru_RU.utf8 before running psql's
TAP tests.  It seems unfortunate that none of the buildfarm has noticed
this.  I guess all the TAP tests are run under C locale?

> The proposed fix is attached.

LGTM, will push in a bit (unless you want to?)

regards, tom lane




Re: pgsql: psql: add an optional execution-count limit to \watch.

2023-04-07 Thread Alexander Korotkov
Hi!

On Thu, Apr 6, 2023 at 8:18 PM Tom Lane  wrote:
> psql: add an optional execution-count limit to \watch.
>
> \watch can now be told to stop after N executions of the query.

This commit makes tests fail for me.  psql parses 'i' option of
'\watch' using locale-aware strtod(), but 001_basic.pl uses hard-coded
decimal separator.  The proposed fix is attached.

--
Regards,
Alexander Korotkov


psql_test_fix.patch
Description: Binary data


pgsql: Fix copy-paste bug in 12f3867f553 triggering an assert after a w

2023-04-07 Thread Andres Freund
Fix copy-paste bug in 12f3867f553 triggering an assert after a write error

The same condition accidentally was copied to both branches. Manual testing
confirms that otherwise the error recovery path works fine.

Found while reviewing the logical-decoding-on-standby patch.

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/21d7c05a5cf7637cbdf2739006936bb9d279d505

Modified Files
--
src/backend/storage/buffer/bufmgr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)