pgsql: Detect redundant GROUP BY columns using UNIQUE indexes

2024-12-11 Thread David Rowley
Detect redundant GROUP BY columns using UNIQUE indexes d4c3a156c added support that when the GROUP BY contained all of the columns belonging to a relation's PRIMARY KEY, all other columns belonging to that relation would be removed from the GROUP BY clause. That's possible because all other column

pgsql: Improve the test case from 5668a857d

2024-12-11 Thread Richard Guo
Improve the test case from 5668a857d In commit 5668a857d, we fixed an issue with incorrect results in right semi joins and introduced a test case to verify the fix. The test case involves SubPlans and InitPlans, which may not be immediately apparent in relation to the issue we addressed. This pa

pgsql: Add some regression tests for missing DDL patterns

2024-12-11 Thread Michael Paquier
Add some regression tests for missing DDL patterns The following commands gain increased coverage for some of the errors they can trigger: - ALTER TABLE .. ALTER COLUMN - CREATE DOMAIN - CREATE TYPE (LIKE) This has come up while discussing the possibility to add more information about the locatio

pgsql: Defer remove_useless_groupby_columns() work until query_planner(

2024-12-11 Thread David Rowley
Defer remove_useless_groupby_columns() work until query_planner() Traditionally, remove_useless_groupby_columns() was called during grouping_planner() directly after the call to preprocess_groupclause(). While in many ways, it made sense to populate the field and remove the functionally dependent

pgsql: Add UUID version 7 generation function.

2024-12-11 Thread Masahiko Sawada
Add UUID version 7 generation function. This commit introduces the uuidv7() SQL function, which generates UUID version 7 as specified in RFC 9652. UUIDv7 combines a Unix timestamp in milliseconds and random bits, offering both uniqueness and sortability. In our implementation, the 12-bit sub-mill

Re: pgsql: Enable BUFFERS with EXPLAIN ANALYZE by default

2024-12-11 Thread David Rowley
On Thu, 12 Dec 2024 at 08:13, Peter Geoghegan wrote: > FYI, I saw a harmless Cirrus CI failure which is likely tied to this > commit, affecting pg_stat_statements -- see attached diffs file. I had been holding off pushing the fix for that one until I could verify that was the last issue with a co

pgsql: Fix further fallout from EXPLAIN ANALYZE BUFFERS change

2024-12-11 Thread David Rowley
Fix further fallout from EXPLAIN ANALYZE BUFFERS change c2a4078eb adjusted EXPLAIN ANALYZE to default the BUFFERS to ON. This (hopefully) fixes the last remaining issue with regression test failures with -D RELCACHE_FORCE_RELEASE -D CATCACHE_FORCE_RELEASE builds, where the planner accesses more b

pgsql: Use pg_memory_is_all_zeros() in pgstatfuncs.c.

2024-12-11 Thread Nathan Bossart
Use pg_memory_is_all_zeros() in pgstatfuncs.c. There are a few places in this file that use memset() and memcmp() to determine whether a section of memory is all zeros. This commit modifies them to use pg_memory_is_all_zeros() instead. These aren't expected to be hot code paths, but this may opt

Re: pgsql: Enable BUFFERS with EXPLAIN ANALYZE by default

2024-12-11 Thread Guillaume Lelarge
Le mer. 11 déc. 2024 à 20:13, Peter Geoghegan a écrit : > On Wed, Dec 11, 2024 at 4:35 AM David Rowley > wrote: > > Enable BUFFERS with EXPLAIN ANALYZE by default > > FYI, I saw a harmless Cirrus CI failure which is likely tied to this > commit, affecting pg_stat_statements -- see attached diffs

Re: pgsql: Enable BUFFERS with EXPLAIN ANALYZE by default

2024-12-11 Thread Peter Geoghegan
On Wed, Dec 11, 2024 at 4:35 AM David Rowley wrote: > Enable BUFFERS with EXPLAIN ANALYZE by default FYI, I saw a harmless Cirrus CI failure which is likely tied to this commit, affecting pg_stat_statements -- see attached diffs file. I spotted this same issue on http://cfbot.cputube.org/highlig

pgsql: Unmark gen_random_uuid() function leakproof.

2024-12-11 Thread Masahiko Sawada
Unmark gen_random_uuid() function leakproof. The functions without arguments don't need to be marked leakproof. This commit unmarks gen_random_uuid() leakproof for consistency with upcoming UUID generation functions. Also, this commit adds a regression test to prevent reintroducing such cases. Bu

pgsql: Fix a memory leak in dumping functions with TRANSFORMs

2024-12-11 Thread Daniel Gustafsson
Fix a memory leak in dumping functions with TRANSFORMs The gneration of the dump clause for functions with TRANSFORM calls would leak the memory for holding the result of the Oid array parsing. Fix by freeing. While in there, switch to using pg_malloc instead of palloc in order to be consistent

pgsql: Add missing BUFFERS OFF in regression tests, take 2

2024-12-11 Thread David Rowley
Add missing BUFFERS OFF in regression tests, take 2 Similar to 9fa1aaa65, but running with -D RELCACHE_FORCE_RELEASE and -D CATCACHE_FORCE_RELEASE yielded some additional missing places that needed BUFFERS OFF. Discussion: https://postgr.es/m/CANNMO++W7MM8T0KyXN3ZheXXt-uLVM3aEtZd+WNfZ=obxff...@m

pgsql: Add missing BUFFERS OFF in select_into regression tests

2024-12-11 Thread David Rowley
Add missing BUFFERS OFF in select_into regression tests c2a4078eb adjusted EXPLAIN ANALYZE to include BUFFERS by default, but a few tests in select_into.sql neglected to add BUFFERS OFF. The failing tests seem unlikely to ever access buffers during execution, but they certainly could during plann

pgsql: Enable BUFFERS with EXPLAIN ANALYZE by default

2024-12-11 Thread David Rowley
Enable BUFFERS with EXPLAIN ANALYZE by default The topic of turning EXPLAIN's BUFFERS option on with the ANALYZE option has come up a few times over the past few years. In many ways, doing this seems like a good idea as it may be more obvious to users why a given query is running more slowly than