pgsql: Avoid crash in estimate_array_length with null root pointer.
Avoid crash in estimate_array_length with null root pointer. Commit 9391f7152 added a "PlannerInfo *root" parameter to estimate_array_length, but failed to consider the possibility that NULL would be passed for that, leading to a null pointer dereference. We could rectify the particular case shown in the bug report by fixing simplify_function/inline_function to pass through the root pointer. However, as long as eval_const_expressions is documented to accept NULL for root, similar hazards would remain. For now, let's just do the narrow fix of hardening estimate_array_length to not crash. Its behavior with NULL root will be the same as it was before 9391f7152, so this is not too awful. Per report from Fredrik Widlert (via Paul Ramsey). Back-patch to v17 where 9391f7152 came in. Discussion: https://postgr.es/m/518339e7-173e-45ec-a0ff-9a4a62aa4...@cleverelephant.ca Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/5a4416192d220410779a4ef6d433e067ba7a7043 Modified Files -- src/backend/optimizer/path/costsize.c | 3 +++ src/backend/utils/adt/selfuncs.c | 5 - 2 files changed, 7 insertions(+), 1 deletion(-)
pgsql: Avoid crash in estimate_array_length with null root pointer.
Avoid crash in estimate_array_length with null root pointer. Commit 9391f7152 added a "PlannerInfo *root" parameter to estimate_array_length, but failed to consider the possibility that NULL would be passed for that, leading to a null pointer dereference. We could rectify the particular case shown in the bug report by fixing simplify_function/inline_function to pass through the root pointer. However, as long as eval_const_expressions is documented to accept NULL for root, similar hazards would remain. For now, let's just do the narrow fix of hardening estimate_array_length to not crash. Its behavior with NULL root will be the same as it was before 9391f7152, so this is not too awful. Per report from Fredrik Widlert (via Paul Ramsey). Back-patch to v17 where 9391f7152 came in. Discussion: https://postgr.es/m/518339e7-173e-45ec-a0ff-9a4a62aa4...@cleverelephant.ca Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/a3c4a91f1e283cc4b79f0b0482d2c490a599d880 Modified Files -- src/backend/optimizer/path/costsize.c | 3 +++ src/backend/utils/adt/selfuncs.c | 5 - 2 files changed, 7 insertions(+), 1 deletion(-)
pgsql: Allow pushdown of HAVING clauses with grouping sets
Allow pushdown of HAVING clauses with grouping sets In some cases, we may want to transfer a HAVING clause into WHERE in hopes of eliminating tuples before aggregation instead of after. Previously, we couldn't do this if there were any nonempty grouping sets, because we didn't have a way to tell if the HAVING clause referenced any columns that were nullable by the grouping sets, and moving such a clause into WHERE could potentially change the results. Now, with expressions marked nullable by grouping sets with the RT index of the RTE_GROUP RTE, it is much easier to identify those clauses that reference any nullable-by-grouping-sets columns: we just need to check if the RT index of the RTE_GROUP RTE is present in the clause. For other HAVING clauses, they can be safely pushed down. Author: Richard Guo Discussion: https://postgr.es/m/CAMbWs4-NpzPgtKU=hgnvyn+J-GanxQCjrUi7piNzZ=upiCV=2...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/67a54b9e83d331eadd3a595e6c3bfec06288d2c4 Modified Files -- src/backend/optimizer/plan/planner.c | 17 + src/test/regress/expected/groupingsets.out | 21 + src/test/regress/sql/groupingsets.sql | 5 + 3 files changed, 35 insertions(+), 8 deletions(-)
pgsql: Consider explicit incremental sort for mergejoins
Consider explicit incremental sort for mergejoins For a mergejoin, if the given outer path or inner path is not already well enough ordered, we need to do an explicit sort. Currently, we only consider explicit full sort and do not account for incremental sort. In this patch, for the outer path of a mergejoin, we choose to use explicit incremental sort if it is enabled and there are presorted keys. For the inner path, though, we cannot use incremental sort because it does not support mark/restore at present. The rationale is based on the assumption that incremental sort is always faster than full sort when there are presorted keys, a premise that has been applied in various parts of the code. In addition, the current cost model tends to favor incremental sort as being cheaper than full sort in the presence of presorted keys, making it reasonable not to consider full sort in such cases. It could be argued that what if a mergejoin with an incremental sort as the outer path is selected as the inner path of another mergejoin. However, this should not be a problem, because mergejoin itself does not support mark/restore either, and we will add a Material node on top of it anyway in this case (see final_cost_mergejoin). There is one ensuing plan change in the regression tests, and we have to modify that test case to ensure that it continues to test what it is intended to. No backpatch as this could result in plan changes. Author: Richard Guo Reviewed-by: David Rowley, Tomas Vondra Discussion: https://postgr.es/m/CAMbWs49x425QrX7h=ux05went8gs757h-jop3_xsx5t1fou...@mail.gmail.com Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/828e94c9d2fd87c06a75354361543119d9937068 Modified Files -- src/backend/optimizer/path/costsize.c | 69 src/backend/optimizer/plan/createplan.c| 89 +++--- src/test/regress/expected/aggregates.out | 34 +- src/test/regress/expected/incremental_sort.out | 21 ++ src/test/regress/sql/aggregates.sql| 6 +- src/test/regress/sql/incremental_sort.sql | 6 ++ 6 files changed, 184 insertions(+), 41 deletions(-)
pgsql: Apply GUC name from central table in more places of guc.c
Apply GUC name from central table in more places of guc.c The name extracted from the record of the GUC tables is applied to more internal places of guc.c. This change has the advantage to simplify parse_and_validate_value(), where the "name" was only used in elog messages, while it was required to match with the name from the GUC record. pg_parameter_aclcheck() now passes the name of the GUC from its record in two places rather than the caller's argument. The value given to this function goes through convert_GUC_name_for_parameter_acl() that does a simple ASCII downcasing. Few GUCs mix character casing in core; one test is added for one of these code paths with "IntervalStyle". Author: Peter Smith, Michael Paquier Discussion: https://postgr.es/m/zwnh4vkc2nhjh...@paquier.xyz Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/f3f06b13308e3c250bb8b0afee861744cda06cf6 Modified Files -- src/backend/utils/misc/guc.c | 65 +++ src/test/regress/expected/guc.out | 4 +++ src/test/regress/sql/guc.sql | 3 ++ 3 files changed, 39 insertions(+), 33 deletions(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/4a75ff7afb4db0283cac79bff546369462890063 Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/866e4a7d598b9edad235df1414b746e37825 Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/610c65064732d25e7a0066ea49b56433b9c2cc4c Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/79ca063de8dace1ae0bb9774ca1f0480f4bcc73f Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/c4528fdfa903c74cf99837a554bd3c7e115bb366 Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/c5b9097255ba70eed9ffe3d804453c80dc1a79f0 Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: Remove incorrect function import from pgindent
Remove incorrect function import from pgindent Commit 149ac7d4559 which re-implemented pgindent in Perl explicitly imported the devnull function from File::Spec, but the module does not export anything. In recent versions of Perl calling a missing import function cause a warning, which combined with warnings being fatal cause pgindent to error out. Backpatch to all supported versions. Author: Erik Wienhold Reviewed-by: Andrew Dunstan Reviewed-by: Daniel Gustafsson Discusson: https://postgr.es/m/2372cd74-11b0-46f9-b28e-8f9627215...@ewie.name Backpatch-through: v12 Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/f21e51ea73973f87715581fc68a6caf97f56505e Modified Files -- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: doc: Fix mention of AT LOCAL in release notes
doc: Fix mention of AT LOCAL in release notes The release notes accidentally spelled AT LOCAL as AS LOCAL. Reported-by: Takatsuka Haruka Discussion: https://postgr.es/m/18649-4d146d83086d4...@postgresql.org Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/647e76c0ff4ad81a457b66ef1581e84b5edf3f84 Modified Files -- doc/src/sgml/release-17.sgml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
pgsql: doc PG 17 relnotes: add missing commands for safe search path
doc PG 17 relnotes: add missing commands for safe search path Reported-by: Yugo NAGATA Discussion: https://postgr.es/m/20240926141921.57d0b430fa53ac4389344...@sraoss.co.jp Backpatch-through: 17 only Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/7e059fb6c04e76b712a5a92de8c62e56f42e1bbf Modified Files -- doc/src/sgml/release-17.sgml | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-)
pgsql: doc PG 17 relnotes: clarify pg_upgrade and logical slot preserv.
doc PG 17 relnotes: clarify pg_upgrade and logical slot preserv. Reported-by: Amit Kapila Discussion: https://postgr.es/m/CAA4eK1+bChgccySmcm0LbvkmBDJ3ufsLneF4iNa_aZ7t2P6=8...@mail.gmail.com Backpatch-through: 17 only Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff/912d15cba50c257f2195f79d3f80bad26996c018 Modified Files -- doc/src/sgml/release-17.sgml | 5 - 1 file changed, 4 insertions(+), 1 deletion(-)