pgsql: Fix typos in comments.

2021-04-02 Thread Fujii Masao
Fix typos in comments.

Author: Masahiko Sawada
Discussion: 
https://postgr.es/m/cad21aoa1yl7t0nzvseysx6zoae7xo3r0jyu8hkitgl2_xba...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/98e5bd103f887326e381c509c2fbe879ba3ea2f3

Modified Files
--
contrib/amcheck/verify_heapam.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
REL_13_STABLE

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

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/89bd8e8b332841247649551e95c8d22c19a97529

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
REL9_6_STABLE

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

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/677357047b9c920e351b73d9670a813fcdc6801b

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
master

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

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: doc: Clarify how to generate backup files with non-exclusive bac

2021-04-02 Thread Michael Paquier
doc: Clarify how to generate backup files with non-exclusive backups

The current instructions describing how to write the backup_label and
tablespace_map files are confusing.  For example, opening a file in text
mode on Windows and copy-pasting the file's contents would result in a
failure at recovery because of the extra CRLF characters generated.  The
documentation was not stating that clearly, and per discussion this is
not considered as a supported scenario.

This commit extends a bit the documentation to mention that it may be
required to open the file in binary mode before writing its data.

Reported-by: Wang Shenhao
Author: David Steele
Reviewed-by: Andrew Dunstan, Magnus Hagander
Discussion: 
https://postgr.es/m/8373f61426074f2cb6be92e02f838389@G08CNEXMBPEKD06.g08.fujitsu.local
Backpatch-through: 9.6

Branch
--
REL_11_STABLE

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

Modified Files
--
doc/src/sgml/backup.sgml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)



pgsql: Fix pgstat_report_replslot() to use proper data types for its ar

2021-04-02 Thread Fujii Masao
Fix pgstat_report_replslot() to use proper data types for its arguments.

The caller of pgstat_report_replslot() passes int64 values to the function.
Also the function stores those values in PgStat_Counter (i.e., int64) fields
of PgStat_MsgReplSlot struct. But previously the function used "int" as
the data types of some arguments for those values, which could lead to
the overflow of values.

To avoid this risk, this commit fixes pgstat_report_replslot() to use
PgStat_Counter type for the arguments. Since they are the statistics counters,
PgStat_Counter, the data type used for counters, is used for them
instead of int64.

Reported-by: Vignesh C
Author: Vignesh C
Reviewed-by: Jeevan Ladhe, Fujii Masao
Discussion: 
https://postgr.es/m/CALDaNm080OpG=zwob0i8eychh5syhamfwjckaktxmrfvjlb...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/96bdb7e19de80a0c9521c5696455bca2a685c919

Modified Files
--
src/backend/postmaster/pgstat.c | 6 --
src/include/pgstat.h| 6 --
2 files changed, 8 insertions(+), 4 deletions(-)



pgsql: Add support for NullIfExpr in eval_const_expressions

2021-04-02 Thread Peter Eisentraut
Add support for NullIfExpr in eval_const_expressions

Author: Hou Zhijie 
Discussion: 
https://www.postgresql.org/message-id/flat/7ea5ce773bbc4eea9ff1a381acd3b102@G08CNEXMBPEKD05.g08.fujitsu.local

Branch
--
master

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

Modified Files
--
src/backend/optimizer/util/clauses.c | 30 ++
src/test/regress/expected/case.out   | 25 +
src/test/regress/sql/case.sql| 11 +++
3 files changed, 66 insertions(+)



pgsql: postgres_fdw: Add option to control whether to keep connections

2021-04-02 Thread Fujii Masao
postgres_fdw: Add option to control whether to keep connections open.

This commit adds a new option keep_connections that controls
whether postgres_fdw keeps the connections to the foreign server open
so that the subsequent queries can re-use them. This option can only be
specified for a foreign server. The default is on. If set to off,
all connections to the foreign server will be discarded
at the end of transaction. Closed connections will be re-established
when they are necessary by future queries using a foreign table.

This option is useful, for example, when users want to prevent
the connections from eating up the foreign servers connections
capacity.

Author: Bharath Rupireddy
Reviewed-by: Alexey Kondratov, Vignesh C, Fujii Masao
Discussion: 
https://postgr.es/m/CALj2ACVvrp5=avp2pupem+nac8s4buqr3fjmmacoc7ftt0a...@mail.gmail.com

Branch
--
master

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

Modified Files
--
contrib/postgres_fdw/connection.c  | 33 ---
contrib/postgres_fdw/expected/postgres_fdw.out | 23 +++-
contrib/postgres_fdw/option.c  |  4 ++-
contrib/postgres_fdw/sql/postgres_fdw.sql  | 13 +
doc/src/sgml/postgres-fdw.sgml | 37 +++---
5 files changed, 101 insertions(+), 9 deletions(-)



pgsql: Fix typo in 6d7a6feac4

2021-04-02 Thread Andrew Dunstan
Fix typo in 6d7a6feac4

Per gripe from Daniel Gustafsson

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1877c9ac3acc05cc787dd6392d073202f8c8ee21

Modified Files
--
src/test/ssl/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Strip file names reported in error messages on Windows, too.

2021-04-02 Thread Tom Lane
Strip file names reported in error messages on Windows, too.

Commit dd136052b established a policy that error message FILE items
should include only the base name of the reporting source file, for
uniformity and succinctness.  We now observe that some Windows compilers
use backslashes in __FILE__ strings, so truncate at backslashes as well.

This is expected to fix some platform variation in the results of the
new libpq_pipeline test module.

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

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/53aafdb9ff6a561c7dea0f428a7c168f2b7e0f16

Modified Files
--
src/backend/utils/error/elog.c | 4 
1 file changed, 4 insertions(+)



pgsql: pg_checksums: Fix progress reporting.

2021-04-02 Thread Fujii Masao
pg_checksums: Fix progress reporting.

pg_checksums uses two counters, total size and current size,
to calculate the progress. Previously the progress that
pg_checksums reported could not reach 100% at the end.
The cause of this issue was that the sizes of only pages excluding
new ones in each file were counted as the current size
while the size of each file is counted as the total size.
That is, the total size of all new pages could be reported
as the difference between the total size and current size.

This commit fixes this issue by making pg_checksums count
the sizes of all pages including new ones in each file as
the current size.

Back-patch to v12 where progress reporting was added to pg_checksums.

Reported-by: Shinya Kato
Author: Shinya Kato
Reviewed-by: Fujii Masao
Discussion: 
https://postgr.es/m/tyapr01mb289656b1aca0a5e7cad07be3c4...@tyapr01mb2896.jpnprd01.prod.outlook.com

Branch
--
REL_12_STABLE

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

Modified Files
--
src/bin/pg_checksums/pg_checksums.c | 9 -
1 file changed, 8 insertions(+), 1 deletion(-)



pgsql: pg_checksums: Fix progress reporting.

2021-04-02 Thread Fujii Masao
pg_checksums: Fix progress reporting.

pg_checksums uses two counters, total size and current size,
to calculate the progress. Previously the progress that
pg_checksums reported could not reach 100% at the end.
The cause of this issue was that the sizes of only pages excluding
new ones in each file were counted as the current size
while the size of each file is counted as the total size.
That is, the total size of all new pages could be reported
as the difference between the total size and current size.

This commit fixes this issue by making pg_checksums count
the sizes of all pages including new ones in each file as
the current size.

Back-patch to v12 where progress reporting was added to pg_checksums.

Reported-by: Shinya Kato
Author: Shinya Kato
Reviewed-by: Fujii Masao
Discussion: 
https://postgr.es/m/tyapr01mb289656b1aca0a5e7cad07be3c4...@tyapr01mb2896.jpnprd01.prod.outlook.com

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/104164361cb18d7c36d068e1ddd2453b0e4dc1bb

Modified Files
--
src/bin/pg_checksums/pg_checksums.c | 9 -
1 file changed, 8 insertions(+), 1 deletion(-)



pgsql: pg_checksums: Fix progress reporting.

2021-04-02 Thread Fujii Masao
pg_checksums: Fix progress reporting.

pg_checksums uses two counters, total size and current size,
to calculate the progress. Previously the progress that
pg_checksums reported could not reach 100% at the end.
The cause of this issue was that the sizes of only pages excluding
new ones in each file were counted as the current size
while the size of each file is counted as the total size.
That is, the total size of all new pages could be reported
as the difference between the total size and current size.

This commit fixes this issue by making pg_checksums count
the sizes of all pages including new ones in each file as
the current size.

Back-patch to v12 where progress reporting was added to pg_checksums.

Reported-by: Shinya Kato
Author: Shinya Kato
Reviewed-by: Fujii Masao
Discussion: 
https://postgr.es/m/tyapr01mb289656b1aca0a5e7cad07be3c4...@tyapr01mb2896.jpnprd01.prod.outlook.com

Branch
--
master

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

Modified Files
--
src/bin/pg_checksums/pg_checksums.c | 9 -
1 file changed, 8 insertions(+), 1 deletion(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/174edbe9f9c1538ab3347474e96d176223591cd1

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/53f5c2df05368bade3523d440f5c10cfae6ad5ef

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/4a1b95fcf4710c9578750d1d9ab4672eab3a5a82

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
REL_11_STABLE

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

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
REL_10_STABLE

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

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Clarify documentation of RESET ROLE

2021-04-02 Thread Joe Conway
Clarify documentation of RESET ROLE

Command-line options, or previous "ALTER (ROLE|DATABASE) ...
SET ROLE ..." commands, can change the value of the default role
for a session. In the presence of one of these, RESET ROLE will
change the current user identifier to the default role rather
than the session user identifier. Fix the documentation to
reflect this reality. Backpatch to all supported versions.

Author: Nathan Bossart
Reviewed-By: Laurenz Albe, David G. Johnston, Joe Conway
Reported by: Nathan Bossart
Discussion: 
https://postgr.es/m/flat/925134DB-8212-4F60-8AB1-B1231D750CB4%40amazon.com
Backpatch-through: 9.6

Branch
--
REL9_6_STABLE

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

Modified Files
--
doc/src/sgml/ref/set_role.sgml | 13 ++---
1 file changed, 10 insertions(+), 3 deletions(-)



pgsql: Detect POLLHUP/POLLRDHUP while running queries.

2021-04-02 Thread Thomas Munro
Detect POLLHUP/POLLRDHUP while running queries.

Provide a new GUC check_client_connection_interval that can be used to
check whether the client connection has gone away, while running very
long queries.  It is disabled by default.

For now this uses a non-standard Linux extension (also adopted by at
least one other OS).  POLLRDHUP is not defined by POSIX, and other OSes
don't have a reliable way to know if a connection was closed without
actually trying to read or write.

In future we might consider trying to send a no-op/heartbeat message
instead, but that could require protocol changes.

Author: Sergey Cherkashin 
Author: Thomas Munro 
Reviewed-by: Thomas Munro 
Reviewed-by: Tatsuo Ishii 
Reviewed-by: Konstantin Knizhnik 
Reviewed-by: Zhihong Yu 
Reviewed-by: Andres Freund 
Reviewed-by: Maksim Milyutin 
Reviewed-by: Tsunakawa, Takayuki/綱川 貴之 
Reviewed-by: Tom Lane  (much earlier version)
Discussion: 
https://postgr.es/m/77def86b27e41f0efcba411460e929ae%40postgrespro.ru

Branch
--
master

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

Modified Files
--
doc/src/sgml/config.sgml  | 37 +
src/backend/libpq/pqcomm.c| 40 +++
src/backend/tcop/postgres.c   | 32 +
src/backend/utils/init/globals.c  |  1 +
src/backend/utils/init/postinit.c | 10 +++
src/backend/utils/misc/guc.c  | 29 +++
src/backend/utils/misc/postgresql.conf.sample |  3 ++
src/include/libpq/libpq.h |  1 +
src/include/miscadmin.h   |  1 +
src/include/tcop/tcopprot.h   |  1 +
src/include/utils/timeout.h   |  1 +
11 files changed, 156 insertions(+)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/6972d9104b6c54bae2fd63d8e02e9c014d162ca3

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/438d7f36ffcc91c81d4e6a4716e556d5bf4f9a78

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/84bc2b17523ef485f102be7f00f7affb88f00f18

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
REL_10_STABLE

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

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/605ef23c7c0fb44f841ec8f1f588325dd8fc951e

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



pgsql: Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

2021-04-02 Thread Bruce Momjian
Use macro MONTHS_PER_YEAR instead of '12' in /ecpg/pgtypeslib

All other places already use MONTHS_PER_YEAR appropriately.

Backpatch-through: 9.6

Branch
--
REL_13_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/45aea47ef430bc942b831932adaca7730c6ae775

Modified Files
--
src/interfaces/ecpg/pgtypeslib/interval.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)



Re: pgsql: Add Result Cache executor node (take 2)

2021-04-02 Thread Andres Freund
Hi,

On 2021-04-02 01:11:35 +, David Rowley wrote:
> Add Result Cache executor node (take 2)

Since this commit I am seeing

In file included from /home/andres/src/postgresql/src/include/postgres.h:46,
 from 
/home/andres/src/postgresql/src/backend/executor/nodeResultCache.c:67:
/home/andres/src/postgresql/src/backend/executor/nodeResultCache.c: In function 
‘entry_purge_tuples’:
/home/andres/src/postgresql/src/backend/executor/nodeResultCache.c:290:27: 
warning: comparison of unsigned expression in ‘>= 0’ is always true 
[-Wtype-limits]
  290 |  Assert(rcstate->mem_used >= 0);
  |   ^~
/home/andres/src/postgresql/src/include/c.h:848:9: note: in definition of macro 
‘Assert’
  848 |   if (!(condition)) \
  | ^
/home/andres/src/postgresql/src/backend/executor/nodeResultCache.c: In function 
‘remove_cache_entry’:
/home/andres/src/postgresql/src/backend/executor/nodeResultCache.c:349:27: 
warning: comparison of unsigned expression in ‘>= 0’ is always true 
[-Wtype-limits]
  349 |  Assert(rcstate->mem_used >= 0);
  |   ^~
/home/andres/src/postgresql/src/include/c.h:848:9: note: in definition of macro 
‘Assert’
  848 |   if (!(condition)) \
  | ^

Now, it's a bit of an over-pedantic warning, but it's also kinda right,
ensuring that a variable that cannot be negative is bigger than 0 is a
bit redundant.

Greetings,

Andres Freund




pgsql: Remove useless Asserts in Result Cache code

2021-04-02 Thread David Rowley
Remove useless Asserts in Result Cache code

Testing if an unsigned variable is >= 0 is pretty pointless.

There's likely enough code in remove_cache_entry() to verify the cache
memory accounting is correct in assert enabled builds. These Asserts
were not adding much extra cover, even if they had been checking >= 0 on a
signed variable.

Reported-by: Andres Freund
Discussion: 
https://postgr.es/m/20210402204734.6mo3nfacnljli...@alap3.anarazel.de

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/1267d9862fc6a4f8cdc0ca38d1988b61f39da585

Modified Files
--
src/backend/executor/nodeResultCache.c | 4 
1 file changed, 4 deletions(-)



Re: pgsql: Add Result Cache executor node (take 2)

2021-04-02 Thread David Rowley
On Sat, 3 Apr 2021 at 09:47, Andres Freund  wrote:
> Since this commit I am seeing
>
> In file included from /home/andres/src/postgresql/src/include/postgres.h:46,
>  from 
> /home/andres/src/postgresql/src/backend/executor/nodeResultCache.c:67:
> /home/andres/src/postgresql/src/backend/executor/nodeResultCache.c: In 
> function ‘entry_purge_tuples’:
> /home/andres/src/postgresql/src/backend/executor/nodeResultCache.c:290:27: 
> warning: comparison of unsigned expression in ‘>= 0’ is always true 
> [-Wtype-limits]
>   290 |  Assert(rcstate->mem_used >= 0);
>   |   ^~

Those were last-minute additions and seems not well thought through.
I've now removed them.

Thanks for the report.

David




Re: pgsql: Add 'noError' argument to encoding conversion functions.

2021-04-02 Thread Jaime Casanova
On Thu, Apr 01, 2021 at 09:25:00AM +, Heikki Linnakangas wrote:
> 
> Add regression tests for built-in encoding conversions. This doesn't cover
> every conversion, but it covers all the internal functions in conv.c that
> are used to implement the conversions.
> 

sqlsmith thinks that test_enc_conversion() must be marked as STRICT. It
crashes with something like this:

```
SELECT test_enc_conversion('\xe4dede'::bytea, 
   null::name, 
   pg_catalog.getdatabaseencoding(), 
   false
  );
```

-- 
Jaime Casanova
Director de Servicios Profesionales
SystemGuards - Consultores de PostgreSQL




Re: pgsql: Add 'noError' argument to encoding conversion functions.

2021-04-02 Thread Michael Paquier
On Fri, Apr 02, 2021 at 06:53:37PM -0500, Jaime Casanova wrote:
> sqlsmith thinks that test_enc_conversion() must be marked as STRICT. It
> crashes with something like this:

This one has won an open item.
--
Michael


signature.asc
Description: PGP signature


pgsql: Split wait event related code from pgstat.[ch] into wait_event.[

2021-04-02 Thread Andres Freund
Split wait event related code from pgstat.[ch] into wait_event.[ch].

The wait event related code is independent from the rest of the
pgstat.[ch] code, of nontrivial size and changes on a regular
basis. Put it into its own set of files.

As there doesn't seem to be a good pre-existing directory for code
like this, add src/backend/utils/activity.

Reviewed-By: Robert Haas 
Discussion: 
https://postgr.es/m/20210316195440.twxmlov24rr2n...@alap3.anarazel.de

Branch
--
master

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

Modified Files
--
src/backend/postmaster/pgstat.c | 673 ---
src/backend/utils/Makefile  |  15 +-
src/backend/utils/activity/Makefile |  19 +
src/backend/utils/activity/wait_event.c | 690 
src/include/pgstat.h| 274 +
src/include/utils/wait_event.h  | 301 ++
6 files changed, 1025 insertions(+), 947 deletions(-)



pgsql: Do not rely on pgstat.h to indirectly include storage/ headers.

2021-04-02 Thread Andres Freund
Do not rely on pgstat.h to indirectly include storage/ headers.

An upcoming patch might remove the (now indirect) proc.h
include (which in turn includes other headers), and it's cleaner for
the modified files to include their dependencies directly anyway...

Discussion: 
https://postgr.es/m/20210402194458.2vu324hkk2djq...@alap3.anarazel.de

Branch
--
master

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

Modified Files
--
contrib/pg_stat_statements/pg_stat_statements.c | 2 ++
src/backend/postmaster/pgarch.c | 2 ++
src/backend/postmaster/pgstat.c | 1 +
src/backend/replication/walreceiver.c   | 1 +
src/backend/storage/lmgr/lmgr.c | 1 +
src/backend/utils/adt/misc.c| 1 +
6 files changed, 8 insertions(+)