pgsql: Avoid instabilities with the regression tests of pg_freespacemap

2022-03-28 Thread Michael Paquier
Avoid instabilities with the regression tests of pg_freespacemap It was possible to run those tests with installcheck, but they are actually unstable as concurrent autovacuum jobs could prevent the truncation of the filespace map to happen (aka the scan of pg_database when building the list of rel

pgsql: Add system view pg_ident_file_mappings

2022-03-28 Thread Michael Paquier
Add system view pg_ident_file_mappings This view is similar to pg_hba_file_rules view, except that it is associated with the parsing of pg_ident.conf. Similarly to its cousin, this view is useful to check via SQL if changes planned in pg_ident.conf would work upon reload or restart, or to diagnos

pgsql: Modify query on pg_hba_file_rules to check for errors in regress

2022-03-28 Thread Michael Paquier
Modify query on pg_hba_file_rules to check for errors in regression tests The regression tests include a query to check the execution path of pg_hba_file_rules, but it has never checked that a given cluster has correct contents in pg_hba.conf. This commit extends the query of pg_hba_file_rules to

pgsql: IS JSON predicate

2022-03-28 Thread Andrew Dunstan
IS JSON predicate This patch intrdocuces the SQL standard IS JSON predicate. It operates on text and bytea values representing JSON as well as on the json and jsonb types. Each test has an IS and IS NOT variant. The tests are: IS JSON [VALUE] IS JSON ARRAY IS JSON OBJECT IS JSON SCALAR IS JSON W

pgsql: Use has_privs_for_roles for predefined role checks

2022-03-28 Thread Joe Conway
Use has_privs_for_roles for predefined role checks Generally if a role is granted membership to another role with NOINHERIT they must use SET ROLE to access the privileges of that role, however with predefined roles the membership and privilege is conflated. Fix that by replacing is_member_of_role

pgsql: Remove the ability of a role to administer itself.

2022-03-28 Thread Robert Haas
Remove the ability of a role to administer itself. Commit f9fd1764615ed5d85fab703b0ffb0c323fe7dfd5 effectively gave every role ADMIN OPTION on itself. However, this appears to be something that happened accidentally as a result of refactoring work rather than an intentional decision. Almost a deca

pgsql: Fix a few goofs in new backup compression code.

2022-03-28 Thread Robert Haas
Fix a few goofs in new backup compression code. When we try to set the zstd compression level either on the client or on the server, check for errors. For any algorithm, on the client side, don't try to set the compression level unless the user specified one. This was visibly broken for zstd, whi

pgsql: Add public ruleutils.c entry point to deparse a Query.

2022-03-28 Thread Tom Lane
Add public ruleutils.c entry point to deparse a Query. This has no in-core callers but will be wanted by extensions. It's just a thin wrapper around get_query_def, so it adds little code. Also, fix get_from_clause_item() to force insertion of an alias for a SUBQUERY RTE item. This is irrelevant

pgsql: Fix role names in merge.sql regress file

2022-03-28 Thread Alvaro Herrera
Fix role names in merge.sql regress file These names need to be prefixed with "regress_". Per buildfarm. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/386ca0abf4107721a363f1c152cd026041b609ea Modified Files -- src/test/regress/expected/merge.out | 28

pgsql: Add support for MERGE SQL command

2022-03-28 Thread Alvaro Herrera
Add support for MERGE SQL command MERGE performs actions that modify rows in the target table using a source table or query. MERGE provides a single SQL statement that can conditionally INSERT/UPDATE/DELETE rows -- a task that would otherwise require multiple PL statements. For example, MERGE IN

pgsql: Preparatory test cleanup

2022-03-28 Thread Peter Eisentraut
Preparatory test cleanup Add a little bit of explanation, clarity, and space. Extraced from a larger patch so that the changes from that patch would be easier to identify. Discussion: https://www.postgresql.org/message-id/flat/04e12818-2f98-257c-b926-2845d74ed04f%402ndquadrant.com Branch -

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Document autoanalyze limitations for partitioned tables

2022-03-28 Thread Tomas Vondra
Document autoanalyze limitations for partitioned tables When dealing with partitioned tables, counters for partitioned tables are not updated when modifying child tables. This means autoanalyze may not update optimizer statistics for the parent relations, which can result in poor plans for some qu

pgsql: Make JSON path numeric literals more correct

2022-03-28 Thread Peter Eisentraut
Make JSON path numeric literals more correct Per ECMAScript standard (ECMA-262, referenced by SQL standard), the syntax forms .1 1. should be allowed for decimal numeric literals, but the existing implementation rejected them. Also, by the same standard, reject trailing junk after numeric liter