pgsql: Adjust new pg_read_file() test cases for more portability.

2022-07-30 Thread Tom Lane
Adjust new pg_read_file() test cases for more portability.

It's allowed for an installation to remove postgresql.auto.conf,
so don't rely on that being present.  Instead probe whether we can
read postmaster.pid.  (If you've removed that, you broke the data
directory's multiple-postmaster interlock, not to mention pg_ctl.)
Per gripe from Michael Paquier.

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

Branch
--
master

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

Modified Files
--
src/test/regress/expected/misc_functions.out | 14 +++---
src/test/regress/sql/misc_functions.sql  | 10 +-
2 files changed, 12 insertions(+), 12 deletions(-)



pgsql: Fix incorrect is-this-the-topmost-join tests in parallel plannin

2022-07-30 Thread Tom Lane
Fix incorrect is-this-the-topmost-join tests in parallel planning.

Two callers of generate_useful_gather_paths were testing the wrong
thing when deciding whether to call that function: they checked for
being at the top of the current join subproblem, rather than being at
the actual top join.  This'd result in failing to construct parallel
paths for a sub-join for which they might be useful.

While set_rel_pathlist() isn't actively broken, it seems best to
make its identical-in-intention test for this be like the other two.

This has been wrong all along, but given the lack of field complaints
I'm hesitant to back-patch into stable branches; we usually prefer
to avoid non-bug-fix changes in plan choices in minor releases.
It seems not too late for v15 though.

Richard Guo, reviewed by Antonin Houska and Tom Lane

Discussion: 
https://postgr.es/m/CAMbWs4-mH8Zf87-w+3P2J=nJB+5OyicO28ia9q_9o=lamf_...@mail.gmail.com

Branch
--
master

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

Modified Files
--
src/backend/optimizer/geqo/geqo_eval.c | 2 +-
src/backend/optimizer/path/allpaths.c  | 9 -
2 files changed, 5 insertions(+), 6 deletions(-)



pgsql: Fix incorrect is-this-the-topmost-join tests in parallel plannin

2022-07-30 Thread Tom Lane
Fix incorrect is-this-the-topmost-join tests in parallel planning.

Two callers of generate_useful_gather_paths were testing the wrong
thing when deciding whether to call that function: they checked for
being at the top of the current join subproblem, rather than being at
the actual top join.  This'd result in failing to construct parallel
paths for a sub-join for which they might be useful.

While set_rel_pathlist() isn't actively broken, it seems best to
make its identical-in-intention test for this be like the other two.

This has been wrong all along, but given the lack of field complaints
I'm hesitant to back-patch into stable branches; we usually prefer
to avoid non-bug-fix changes in plan choices in minor releases.
It seems not too late for v15 though.

Richard Guo, reviewed by Antonin Houska and Tom Lane

Discussion: 
https://postgr.es/m/CAMbWs4-mH8Zf87-w+3P2J=nJB+5OyicO28ia9q_9o=lamf_...@mail.gmail.com

Branch
--
REL_15_STABLE

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

Modified Files
--
src/backend/optimizer/geqo/geqo_eval.c | 2 +-
src/backend/optimizer/path/allpaths.c  | 9 -
2 files changed, 5 insertions(+), 6 deletions(-)



pgsql: Add regression test coverage for contrib/pg_buffercache.

2022-07-30 Thread Tom Lane
Add regression test coverage for contrib/pg_buffercache.

We can't check the output of this view very closely without
creating portability headaches, but we can make sure that
the number of rows is as-expected.  In any case, this is
sufficient to exercise all the C code within, which is a
lot better than the 0% coverage we had before.

DongWook Lee

Discussion: 
https://postgr.es/m/CAAcByaLCHGJB7qAENEcx9D09UL=w4ma+yijwf_-1msqqz9w...@mail.gmail.com

Branch
--
master

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

Modified Files
--
contrib/pg_buffercache/.gitignore  |  4 
contrib/pg_buffercache/Makefile|  2 ++
contrib/pg_buffercache/expected/pg_buffercache.out | 10 ++
contrib/pg_buffercache/sql/pg_buffercache.sql  |  6 ++
4 files changed, 22 insertions(+)



pgsql: Improve regression test coverage of GiST index building.

2022-07-30 Thread Tom Lane
Improve regression test coverage of GiST index building.

Add a test case that exercises the "buffering build" code path.
This covers almost all the non-error-case lines in gistbuild.c
and gistbuildbuffers.c.

Matheus Alcantara, based on earlier work by Pavel Borisov

Discussion: 
https://postgr.es/m/3z8Fde-IHbW57a7bEZtaf19f4YOCWu67IZoWJoGW18rKD9R16ZHHchf4d7KFI3Yg7-0N4NonFuwKEgh98HjMCZYoVx7KOioPo6Wn2nZRpf4=@pm.me

Branch
--
master

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

Modified Files
--
src/test/regress/expected/gist.out | 3 +++
src/test/regress/sql/gist.sql  | 4 
2 files changed, 7 insertions(+)



pgsql: Expand tests of test_ddl_deparse/ for ALTER TABLE

2022-07-30 Thread Michael Paquier
Expand tests of test_ddl_deparse/ for ALTER TABLE

This module is expanded to track the description of the objects changed
in the subcommands of ALTER TABLE by reworking the function
get_altertable_subcmdtypes() (now named get_altertable_subcmdinfo) used
in the event trigger of the test.  It now returns a set of rows made of
(subcommand type, object description) instead of a text array with only
the information about the subcommand type.

The tests have been lacking a lot of the subcommands added to
AlterTableType over the years.  All the missing subcommands are added,
and the code is now structured so as the addition of a new subcommand
is detected by removing the default clause used in the switch for the
subcommand types.

The coverage of the module is increased from roughly 30% to 50%.  More
could be done but this is already a nice improvement.

Author: Michael Paquier, Hou Zhijie
Reviewed-by: Álvaro Herrera, Amit Kapila, Hayato Kuroda
Discussion: 
https://postgr.es/m/os0pr01mb571626984bd099dadf53f38394...@os0pr01mb5716.jpnprd01.prod.outlook.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/07ff701dbd53aeb86dd5a09a8b943b3782d4b67f

Modified Files
--
.../test_ddl_deparse/expected/alter_table.out  | 126 -
.../test_ddl_deparse/expected/create_table.out |   8 +-
.../test_ddl_deparse/expected/create_view.out  |   2 +-
.../test_ddl_deparse/expected/test_ddl_deparse.out |   4 +-
.../modules/test_ddl_deparse/sql/alter_table.sql   |  56 +
.../test_ddl_deparse/sql/test_ddl_deparse.sql  |   4 +-
.../test_ddl_deparse/test_ddl_deparse--1.0.sql |   6 +-
.../modules/test_ddl_deparse/test_ddl_deparse.c|  73 +---
8 files changed, 250 insertions(+), 29 deletions(-)



pgsql: Feed ObjectAddress to event triggers for ALTER TABLE ATTACH/DETA

2022-07-30 Thread Michael Paquier
Feed ObjectAddress to event triggers for ALTER TABLE ATTACH/DETACH

These flavors of ALTER TABLE were already shaped to report the
ObjectAddress of the partition attached or detached, but this data was
not added to what is collected for event triggers.  The tests of
test_ddl_deparse are updated to show the modification in the data
reported.

Author: Hou Zhijie
Reviewed-by: Álvaro Herrera, Amit Kapila, Hayato Kuroda, Michael Paquier
Discussion: 
https://postgr.es/m/os0pr01mb571626984bd099dadf53f38394...@os0pr01mb5716.jpnprd01.prod.outlook.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/43231423dafc0cedcb52169465589b0d1d3c47d2

Modified Files
--
src/backend/commands/tablecmds.c | 16 
.../modules/test_ddl_deparse/expected/alter_table.out|  4 ++--
2 files changed, 10 insertions(+), 10 deletions(-)