pgsql: doc: Fix command example to run regression tests with PGOPTIONS

2021-07-26 Thread Michael Paquier
doc: Fix command example to run regression tests with PGOPTIONS

The documentation mentioned the use of log_checkpoints, that cannot be
used in this context.  This commit replaces log_checkpoints with
force_parallel_mode, a developer option useful to perform checks related
to parallelism.

Oversight in 854434c.

Author: Haiying Tang
Discussion: 
https://postgr.es/m/os0pr01mb6113954b883aceb2ddc973f2fb...@os0pr01mb6113.jpnprd01.prod.outlook.com
Backpatch-through: 14

Branch
--
REL_14_STABLE

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

Modified Files
--
doc/src/sgml/regress.sgml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: doc: Fix command example to run regression tests with PGOPTIONS

2021-07-26 Thread Michael Paquier
doc: Fix command example to run regression tests with PGOPTIONS

The documentation mentioned the use of log_checkpoints, that cannot be
used in this context.  This commit replaces log_checkpoints with
force_parallel_mode, a developer option useful to perform checks related
to parallelism.

Oversight in 854434c.

Author: Haiying Tang
Discussion: 
https://postgr.es/m/os0pr01mb6113954b883aceb2ddc973f2fb...@os0pr01mb6113.jpnprd01.prod.outlook.com
Backpatch-through: 14

Branch
--
master

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

Modified Files
--
doc/src/sgml/regress.sgml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Allow numeric scale to be negative or greater than precision.

2021-07-26 Thread Dean Rasheed
Allow numeric scale to be negative or greater than precision.

Formerly, when specifying NUMERIC(precision, scale), the scale had to
be in the range [0, precision], which was per SQL spec. This commit
extends the range of allowed scales to [-1000, 1000], independent of
the precision (whose valid range remains [1, 1000]).

A negative scale implies rounding before the decimal point. For
example, a column might be declared with a scale of -3 to round values
to the nearest thousand. Note that the display scale remains
non-negative, so in this case the display scale will be zero, and all
digits before the decimal point will be displayed.

A scale greater than the precision supports fractional values with
zeros immediately after the decimal point.

Take the opportunity to tidy up the code that packs, unpacks and
validates the contents of a typmod integer, encapsulating it in a
small set of new inline functions.

Bump the catversion because the allowed contents of atttypmod have
changed for numeric columns. This isn't a change that requires a
re-initdb, but negative scale values in the typmod would confuse old
backends.

Dean Rasheed, with additional improvements by Tom Lane. Reviewed by
Tom Lane.

Discussion: 
https://postgr.es/m/caezatcwdnlgpkihmurf8nfofp0rftakj7kty6gczopnmfuo...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/085f931f52494e1f304e35571924efa6fcdc2b44

Modified Files
--
doc/src/sgml/datatype.sgml |  48 ++-
src/backend/utils/adt/numeric.c| 130 +
src/include/catalog/catversion.h   |   2 +-
src/include/utils/numeric.h|  16 +++-
src/test/regress/expected/numeric.out  |  63 ++
src/test/regress/expected/sanity_check.out |   1 +
src/test/regress/sql/numeric.sql   |  34 
7 files changed, 251 insertions(+), 43 deletions(-)



pgsql: psql \dX: check schema when listing statistics objects

2021-07-26 Thread Tomas Vondra
psql \dX: check schema when listing statistics objects

Commit ad600bba04 added psql command \dX listing extended statistics
objects, but it failed to consider search_path when selecting the
elements so some of the returned elements might be invisible.

The visibility was already considered for tab completion (added by
commit d99d58cdc8), so adding it to the query is fairly simple.

Reported and fix by Justin Pryzby, regression tests by me. Backpatch
to PostgreSQL 14, where \dX was introduced.

Batchpatch-through: 14
Author: Justin Pryzby
Reviewed-by: Tatsuro Yamada
Discussion: 
https://postgr.es/m/c027a541-5856-75a5-0868-341301e1624b%40nttcom.co.jp_1

Branch
--
master

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

Modified Files
--
src/bin/psql/describe.c |  2 +-
src/test/regress/expected/stats_ext.out | 52 +
src/test/regress/sql/stats_ext.sql  |  5 
3 files changed, 40 insertions(+), 19 deletions(-)



pgsql: psql \dX: check schema when listing statistics objects

2021-07-26 Thread Tomas Vondra
psql \dX: check schema when listing statistics objects

Commit ad600bba04 added psql command \dX listing extended statistics
objects, but it failed to consider search_path when selecting the
elements so some of the returned elements might be invisible.

The visibility was already considered for tab completion (added by
commit d99d58cdc8), so adding it to the query is fairly simple.

Reported and fix by Justin Pryzby, regression tests by me. Backpatch
to PostgreSQL 14, where \dX was introduced.

Batchpatch-through: 14
Author: Justin Pryzby
Reviewed-by: Tatsuro Yamada
Discussion: 
https://postgr.es/m/c027a541-5856-75a5-0868-341301e1624b%40nttcom.co.jp_1

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/611e42444b121370f561d860552beb7d28dacbf8

Modified Files
--
src/bin/psql/describe.c |  2 +-
src/test/regress/expected/stats_ext.out | 52 +
src/test/regress/sql/stats_ext.sql  |  5 
3 files changed, 40 insertions(+), 19 deletions(-)



pgsql: Remove newly added useless assertion check

2021-07-26 Thread Alvaro Herrera
Remove newly added useless assertion check

Coverity complained that my commit 80ba4bb38353 added a dubious coding
for a consistency check that there isn't more than one row for a certain
tgrelid/tgparentid combination.  But we don't check for that explicitly
anywhere else, and if we were to do it, it should be a full
shouldn't-happen elog not just an assert.  It doesn't seem that this is
very important anyway, so remove it.

Discussion: https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
src/backend/commands/trigger.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)



pgsql: Skip trailing whitespaces when parsing integer options

2021-07-26 Thread Michael Paquier
Skip trailing whitespaces when parsing integer options

strtoint(), via strtol(), would skip leading whitespaces but the same
rule was not applied for trailing whitespaces, leading to an
inconsistent behavior.  Some tests are changed to cover more this area.

Author: Michael Paquier
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
src/bin/pg_basebackup/t/020_pg_receivewal.pl | 4 +++-
src/bin/pg_dump/t/001_basic.pl   | 3 ++-
src/fe_utils/option_utils.c  | 9 -
3 files changed, 13 insertions(+), 3 deletions(-)



pgsql: Simplify matching pattern check in TAP tests of pg_receivewal

2021-07-26 Thread Michael Paquier
Simplify matching pattern check in TAP tests of pg_receivewal

A check in the ZLIB portion of the test to match the name of a
non-compressed partial segment with a completed compressed segment was
using m//, while a simple equality check is enough.  This makes the test
a bit stricter without impacting its coverage.

Author: Kyotaro Horiguchi
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/24ba1a87e4056ec34c8a685633a1a14fb89e5700

Modified Files
--
src/bin/pg_basebackup/t/020_pg_receivewal.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL_13_STABLE

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

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 20 +++
src/bin/pg_resetwal/pg_resetwal.c | 72 ++-
src/bin/pg_upgrade/controldata.c  | 17 -
src/bin/pg_upgrade/pg_upgrade.c   |  7 
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 85 insertions(+), 32 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/71121450e8f42b21665ee9c8f70b701f7a16c801

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 19 +++
src/bin/pg_resetwal/pg_resetwal.c | 37 +++--
src/bin/pg_upgrade/controldata.c  | 17 -
src/bin/pg_upgrade/pg_upgrade.c   |  7 +++
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 66 insertions(+), 15 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/7626e9f2be7d0fc9b20936910831b900b555728b

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 20 +++
src/bin/pg_resetwal/pg_resetwal.c | 72 ++-
src/bin/pg_upgrade/controldata.c  | 17 -
src/bin/pg_upgrade/pg_upgrade.c   |  7 
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 85 insertions(+), 32 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/088dbf3bc40bd866da71e07bef8963c81dbb14b9

Modified Files
--
doc/src/sgml/ref/pg_resetxlog.sgml  | 19 +++
src/bin/pg_resetxlog/pg_resetxlog.c | 37 +++--
src/bin/pg_upgrade/controldata.c| 17 -
src/bin/pg_upgrade/pg_upgrade.c |  7 +++
src/bin/pg_upgrade/pg_upgrade.h |  1 +
5 files changed, 66 insertions(+), 15 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/74cf7d46a91d601e0f8d957a7edbaeeb7df83efc

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 20 +++
src/bin/pg_resetwal/pg_resetwal.c | 72 ++-
src/bin/pg_upgrade/controldata.c  | 17 -
src/bin/pg_upgrade/pg_upgrade.c   |  7 
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 85 insertions(+), 32 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL_11_STABLE

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

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 20 
src/bin/pg_resetwal/pg_resetwal.c | 66 ++-
src/bin/pg_upgrade/controldata.c  | 17 +-
src/bin/pg_upgrade/pg_upgrade.c   |  7 +
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 82 insertions(+), 29 deletions(-)



pgsql: pg_resetxlog: add option to set oldest xid & use by pg_upgrade

2021-07-26 Thread Bruce Momjian
pg_resetxlog:  add option to set oldest xid & use by pg_upgrade

Add pg_resetxlog -u option to set the oldest xid in pg_control.
Previously -x set this value be -2 billion less than the -x value.
However, this causes the server to immediately scan all relation's
relfrozenxid so it can advance pg_control's oldest xid to be inside the
autovacuum_freeze_max_age range, which is inefficient and might disrupt
diagnostic recovery.  pg_upgrade will use this option to better create
the new cluster to match the old cluster.

Reported-by: Jason Harvey, Floris Van Nee

Discussion: https://postgr.es/m/[email protected], 
[email protected]

Author: Bertrand Drouvot

Backpatch-through: 9.6

Branch
--
REL_14_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/695b4a113abca380fd7aed26cefa039e4e8cd569

Modified Files
--
doc/src/sgml/ref/pg_resetwal.sgml | 20 +++
src/bin/pg_resetwal/pg_resetwal.c | 72 ++-
src/bin/pg_upgrade/controldata.c  | 17 -
src/bin/pg_upgrade/pg_upgrade.c   |  7 
src/bin/pg_upgrade/pg_upgrade.h   |  1 +
5 files changed, 85 insertions(+), 32 deletions(-)



pgsql: doc: for various substring funcs, document if only first match

2021-07-26 Thread Bruce Momjian
doc:  for various substring funcs, document if only first match

Reported-by: [email protected]

Discussion: 
https://postgr.es/m/[email protected]

Backpatch-through: 13

Branch
--
REL_13_STABLE

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

Modified Files
--
doc/src/sgml/func.sgml | 35 ---
1 file changed, 20 insertions(+), 15 deletions(-)



pgsql: doc: for various substring funcs, document if only first match

2021-07-26 Thread Bruce Momjian
doc:  for various substring funcs, document if only first match

Reported-by: [email protected]

Discussion: 
https://postgr.es/m/[email protected]

Backpatch-through: 13

Branch
--
REL_14_STABLE

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

Modified Files
--
doc/src/sgml/func.sgml | 35 ---
1 file changed, 20 insertions(+), 15 deletions(-)



pgsql: doc: for various substring funcs, document if only first match

2021-07-26 Thread Bruce Momjian
doc:  for various substring funcs, document if only first match

Reported-by: [email protected]

Discussion: 
https://postgr.es/m/[email protected]

Backpatch-through: 13

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/6feebcb6b44631c3dc435e971bd80c2dd218a5ab

Modified Files
--
doc/src/sgml/func.sgml | 35 ---
1 file changed, 20 insertions(+), 15 deletions(-)