pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: Fix the random test failure in 001_rep_changes.

2021-08-31 Thread Amit Kapila
Fix the random test failure in 001_rep_changes. The check to test whether the subscription workers were restarting after a change in the subscription was failing. The reason was that the test was assuming the walsender started before it reaches the 'streaming' state and the walsender was exiting d

pgsql: VACUUM VERBOSE: Don't report "pages removed".

2021-08-31 Thread Peter Geoghegan
VACUUM VERBOSE: Don't report "pages removed". It doesn't make any sense to report this information, since VACUUM VERBOSE reports on heap relation truncation directly. This was an oversight in commit 7ab96cf6, which made VACUUM VERBOSE output a little more consistent with nearby autovacuum-specifi

pgsql: VACUUM VERBOSE: Don't report "pages removed".

2021-08-31 Thread Peter Geoghegan
VACUUM VERBOSE: Don't report "pages removed". It doesn't make any sense to report this information, since VACUUM VERBOSE reports on heap relation truncation directly. This was an oversight in commit 7ab96cf6, which made VACUUM VERBOSE output a little more consistent with nearby autovacuum-specifi

pgsql: Refactor one conversion of SQLSTATE to string in elog.c

2021-08-31 Thread Michael Paquier
Refactor one conversion of SQLSTATE to string in elog.c unpack_sql_state() has been introduced in d46bc44 to refactor the unpacking of a SQLSTATE into a string, but it forgot one code path when sending error reports to clients that could make use of it. This changes the code to also use unpack_sq

pgsql: Add PostgresNode::command_fails_like()

2021-08-31 Thread Michael Paquier
Add PostgresNode::command_fails_like() This is useful to test for a command failure with some default connection parameters associated to a node, in combination with checks on error patterns expected. This routine will be used by an upcoming future patch, but could be also plugged into some of th

pgsql: Remove obsolete nbtree relation extension comment.

2021-08-31 Thread Peter Geoghegan
Remove obsolete nbtree relation extension comment. Commit 0d1fe9f7 improved the approach that vacuumlazy.c takes when it encounters an empty heap page. It no acquires the relation extension lock. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/0f6aa893cb58c2a5a9201

pgsql: vacuumlazy.c: Correct prune state comment.

2021-08-31 Thread Peter Geoghegan
vacuumlazy.c: Correct prune state comment. Oversight in commit 7ab96cf6b3. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/6320806ac3792a297f1c4eb149c3ddeda25d3930 Modified Files -- src/backend/access/heap/vacuumlazy.c | 2 +- 1 file changed, 1 insertion

pgsql: Don't print extra parens around expressions in extended stats

2021-08-31 Thread Tomas Vondra
Don't print extra parens around expressions in extended stats The code printing expressions for extended statistics doubled the parens, producing results like ((a+1)), which is unnecessary and not consistent with how we print expressions elsewhere. Fixed by tweaking the code to produce just a sin

pgsql: Don't print extra parens around expressions in extended stats

2021-08-31 Thread Tomas Vondra
Don't print extra parens around expressions in extended stats The code printing expressions for extended statistics doubled the parens, producing results like ((a+1)), which is unnecessary and not consistent with how we print expressions elsewhere. Fixed by tweaking the code to produce just a sin

pgsql: Remove unneeded old_rel_pages VACUUM state field.

2021-08-31 Thread Peter Geoghegan
Remove unneeded old_rel_pages VACUUM state field. The field hasn't been used since commit 3d351d91, which redefined pg_class.reltuples to be -1 before the first VACUUM or ANALYZE. Also rename a local variable of the same name ("old_rel_pages"). This is used by relation truncation to represent the

pgsql: Add historic commit to git-blame-ignore-revs file.

2021-08-31 Thread Peter Geoghegan
Add historic commit to git-blame-ignore-revs file. Add a historic pgindent commit that was missed by the initial work done in commit 8e638845. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/aec5cc9efda00f7f418c9a068c92cab119602084 Modified Files -- .gi

pgsql: Mark the timestamptz variant of date_bin() as stable

2021-08-31 Thread John Naylor
Mark the timestamptz variant of date_bin() as stable Previously, it was immutable by lack of marking. This is not correct, since the time zone could change. Bump catversion Discussion: https://www.postgresql.org/message-id/CAFBsxsG2UHk8mOWL0tca%3D_cg%2B_oA5mVRNLhDF0TBw980iOg5NQ%40mail.gmail.com

pgsql: Mark the timestamptz variant of date_bin() as stable

2021-08-31 Thread John Naylor
Mark the timestamptz variant of date_bin() as stable Previously, it was immutable by lack of marking. This is not correct, since the time zone could change. Bump catversion Discussion: https://www.postgresql.org/message-id/CAFBsxsG2UHk8mOWL0tca%3D_cg%2B_oA5mVRNLhDF0TBw980iOg5NQ%40mail.gmail.com

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: In pg_dump, avoid doing per-table queries for RLS policies.

2021-08-31 Thread Tom Lane
In pg_dump, avoid doing per-table queries for RLS policies. For no particularly good reason, getPolicies() queried pg_policy separately for each table. We can collect all the policies in a single query instead, and attach them to the correct TableInfo objects using findTableByOid() lookups. On t

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Cache the results of format_type() queries in pg_dump.

2021-08-31 Thread Tom Lane
Cache the results of format_type() queries in pg_dump. There's long been a "TODO: there might be some value in caching the results" annotation on pg_dump's getFormattedTypeName function; but we hadn't gotten around to checking what it was costing us to repetitively look up type names. It turns ou

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Rename the role in stats_ext to have regress_ prefix

2021-08-31 Thread Tomas Vondra
Rename the role in stats_ext to have regress_ prefix Commit 5be8ce82e8 added a new role to the stats_ext regression suite, but the role name did not start with regress_ causing failures when running with ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS. Fixed by renaming the role to start with the expect

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix lookup error in extended stats ownership check

2021-08-31 Thread Tomas Vondra
Fix lookup error in extended stats ownership check When an ownership check on extended statistics object failed, the code was calling aclcheck_error_type to report the failure, which is clearly wrong, resulting in cache lookup errors. Fix by calling aclcheck_error. This issue exists since the int

pgsql: Fix missed lock acquisition while inlining new-style SQL functio

2021-08-31 Thread Tom Lane
Fix missed lock acquisition while inlining new-style SQL functions. When starting to use a query parsetree loaded from the catalogs, we must begin by applying AcquireRewriteLocks(), to obtain the same relation locks that the parser would have gotten if the query were entered interactively, and to

pgsql: Fix missed lock acquisition while inlining new-style SQL functio

2021-08-31 Thread Tom Lane
Fix missed lock acquisition while inlining new-style SQL functions. When starting to use a query parsetree loaded from the catalogs, we must begin by applying AcquireRewriteLocks(), to obtain the same relation locks that the parser would have gotten if the query were entered interactively, and to

pgsql: Prohibit map and grep in void context

2021-08-31 Thread Daniel Gustafsson
Prohibit map and grep in void context map and grep are not intended to be used as mutators, iterating with side-effects should be done with for or foreach loops. This fixes the one occurrence of the pattern, and bumps the perlcritic policy to severity 5 for the map and grep policies. Author: Dagf