summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
8 daysCheckNNConstraintFetch: Fill all of ConstrCheck in a single passÁlvaro Herrera
Previously, we'd fill all fields except ccbin, and only later obtain and detoast ccbin, with hypothetical failures being possible. If ccbin is null (rare catalog corruption I have never witnessed) or its a corrupted toast entry, we leak a tiny bit of memory in CacheMemoryContext from having strdup'd the constraint name. Repair these by only attempting to fill the struct once ccbin has been detoasted. Author: Ranier Vilela <ranier.vf@gmail.com> Discussion: https://postgr.es/m/CAEudQAr=i3_Z4GvmediX900+sSySTeMkvuytYShhQqEwoGyvhA@mail.gmail.com
8 daysReorganize GUC structsPeter Eisentraut
Instead of having five separate GUC structs, one for each type, with the generic part contained in each of them, flip it around and have one common struct, with the type-specific part has a subfield. The very original GUC design had type-specific structs and type-specific lists, and the membership in one of the lists defined the type. But now the structs themselves know the type (from the .vartype field), and they are all loaded into a common hash table at run time, and so this original separation no longer makes sense. It creates a bunch of inconsistencies in the code about whether the type-specific or the generic struct is the primary struct, and a lot of casting in between, which makes certain assumptions about the struct layouts. After the change, all these casts are gone and all the data is accessed via normal field references. Also, various code is simplified because only one kind of struct needs to be processed. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Discussion: https://www.postgresql.org/message-id/flat/8fdfb91e-60fb-44fa-8df6-f5dea47353c9@eisentraut.org
8 daysformatting.c cleanup: Remove unnecessary extra parenthesesPeter Eisentraut
Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
8 daysformatting.c cleanup: Use array syntax instead of pointer arithmeticPeter Eisentraut
for easier readability Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
8 daysformatting.c cleanup: Add some const pointer qualifiersPeter Eisentraut
Co-authored-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
8 daysformatting.c cleanup: Use size_t for string length variables and argumentsPeter Eisentraut
Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
8 daysReplace pg_restrict by standard restrictPeter Eisentraut
MSVC in C11 mode supports the standard restrict qualifier, so we don't need the workaround naming pg_restrict anymore. Even though restrict is in C99 and should be supported by all supported compilers, we keep the configure test and the hardcoded redirection to __restrict, because that will also work in C++ in all supported compilers. (restrict is not part of the C++ standard.) For backward compatibility for extensions, we keep a #define of pg_restrict around, but our own code doesn't use it anymore. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/0e3d8644-c01d-4374-86ea-9f0a987981f0%40eisentraut.org
8 daysRemove obsolete commentPeter Eisentraut
The comment "type prefixes (const, signed, volatile, inline) are handled in pg_config.h." has been mostly not true for a long time.
9 daysFix correctness issue with computation of FPI size in WAL statsMichael Paquier
XLogRecordAssemble() may be called multiple times before inserting a record in XLogInsertRecord(), and the amount of FPIs generated inside a record whose insertion is attempted multiple times may vary. The logic added in f9a09aa29520 touched directly pgWalUsage in XLogRecordAssemble(), meaning that it could be possible for pgWalUsage to be incremented multiple times for a single record. This commit changes the code to use the same logic as the number of FPIs added to a record, where XLogRecordAssemble() returns this information and feeds it to XLogInsertRecord(), updating pgWalUsage only when a record is inserted. Reported-by: Shinya Kato <shinya11.kato@gmail.com> Discussion: https://postgr.es/m/CAOzEurSiSr+rusd0GzVy8Bt30QwLTK=ugVMnF6=5WhsSrukvvw@mail.gmail.com
9 daysAdd psql PROMPT variable for search_path.Nathan Bossart
The new %S substitution shows the current value of search_path. Note that this only works when connected to Postgres v18 or newer, since search_path was first marked as GUC_REPORT in commit 28a1121fd9. On older versions that don't report search_path, %S is replaced with a question mark. Suggested-by: Lauri Siltanen <lauri.siltanen@gmail.com> Author: Florents Tselai <florents.tselai@gmail.com> Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl> Reviewed-by: Jim Jones <jim.jones@uni-muenster.de> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://postgr.es/m/CANsM767JhTKCRagTaq5Lz52fVwLPVkhSpyD1C%2BOrridGv0SO0A%40mail.gmail.com
9 daysformatting.c cleanup: Move loop variables definitions into for statementPeter Eisentraut
Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
9 daysformatting.c cleanup: Remove dashes in commentsPeter Eisentraut
This saves some vertical space and makes the comments style more consistent with the rest of the code. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/6dd9d208-a3ed-49b5-b03d-8617261da973%40eisentraut.org
9 daysDon't error out when dropping constraint if relchecks is already zeroÁlvaro Herrera
I have never seen this be a problem in practice, but it came up when purposely corrupting catalog contents to study the fix for a nearby bug: we'd try to decrement relchecks, but since it's zero we error out and fail to drop the constraint. The fix is to downgrade the error to warning, skip decrementing the counter, and otherwise proceed normally. Given lack of field complaints, no backpatch. Author: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://postgr.es/m/202508291058.q2zscdcs64fj@alvherre.pgsql
9 daysMove comment about casts from pg_wchar.Jeff Davis
Suggested-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CA+hUKGLXQUYK7Cq5KbLGgTWo7pORs7yhBWO1AEnZt7xTYbLRhg@mail.gmail.com
9 daysCheck that index can return in get_actual_variable_range()Peter Eisentraut
Some recent changes were made to remove the explicit dependency on btree indexes in some parts of the code. One of these changes was made in commit 9ef1851685b, which allows non-btree indexes to be used in get_actual_variable_range(). A follow-up commit ee1ae8b99f9 fixes the cases where an index doesn’t have a sortopfamily as this is a prerequisite to be used in get_actual_variable_range(). However, it was found that indexes that have amcanorder = true but do not allow index-only-scans (amcanreturn returns false or is NULL) will pass all of the conditions, while they should be rejected since get_actual_variable_range() uses the index-only-scan machinery in get_actual_variable_endpoint(). Such an index might cause errors like ERROR: no data returned for index-only scan during query planning. The fix is to add a check in get_actual_variable_range() to reject indexes that do not allow index-only scans. Author: Maxime Schoemans <maxime.schoemans@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/20ED852A-C2D9-41EB-8671-8C8B9D418BE9%40enterprisedb.com
9 daysAdd wal_fpi_bytes to pg_stat_wal and pg_stat_get_backend_wal()Michael Paquier
This new counter, called "wal_fpi_bytes", tracks the total amount in bytes of full page images (FPIs) generated in WAL. This data becomes available globally via pg_stat_wal, and for backend statistics via pg_stat_get_backend_wal(). Previously, this information could only be retrieved with pg_waldump or pg_walinspect, which may not be available depending on the environment, and are expensive to execute. It offers hints about how much FPIs impact the WAL generated, which could be a large percentage for some workloads, as well as the effects of wal_compression or page holes. Bump catalog version. Bump PGSTAT_FILE_FORMAT_ID, due to the addition of wal_fpi_bytes in PgStat_WalCounters. Author: Shinya Kato <shinya11.kato@gmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAOzEurQtZEAfg6P0kU3Wa-f9BWQOi0RzJEMPN56wNTOmJLmfaQ@mail.gmail.com
9 daysAdd worker type argument to logical replication worker functions.Amit Kapila
Extend logicalrep_worker_stop, logicalrep_worker_wakeup, and logicalrep_worker_find to accept a worker type argument. This change enables differentiation between logical replication worker types, such as apply workers and table sync workers. While preserving existing behavior, it lays the groundwork for upcoming patch to add sequence synchronization workers. Author: Vignesh C <vignesh21@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Peter Smith <smithpb2250@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
10 daysSimplify newline handling in two TAP testsMichael Paquier
Two tests are changed in this commit: - libpq's 006_service - ldap's 003_ldap_connection_param_lookup CRLF translation is already handled by the text mode, so there should be need for any specific logic. See also 1c6d4629394d, msys perl being one case where the translation mattered. Note: This is first applied on HEAD, and backpatch will follow once the buildfarm has provided an opinion about this commit. Author: Jacob Champion <jacob.champion@enterprisedb.com> Co-authored-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Discussion: https://postgr.es/m/aPsh39bxwYKvUlAf@paquier.xyz Backpatch-through: 13
10 daysFix a couple of comments.Nathan Bossart
These were discovered while reviewing Aleksander Alekseev's proposed changes to pgindent. Oversights in commits 393e0d2314 and 25a30bbd42. Discussion: https://postgr.es/m/aP-H6kSsGOxaB21k%40nathan
10 daysAdd new RLS tests to test policies applied by command type.Dean Rasheed
The existing RLS tests focus on the outcomes of various testing scenarios, rather than the exact policies applied. This sometimes makes it hard to see why a particular result occurred (e.g., which policy failed), or to construct a test that fails a particular policy check without an earlier check failing. These new tests issue NOTICE messages to show the actual policies applied for each command type, including the different paths through INSERT ... ON CONFLICT and MERGE, making it easier to verify the expected behaviour. Author: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: Viktor Holmberg <v@viktorh.net> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/CAEZATCWqnfeChjK=n1V_dYZT4rt4mnq+ybf9c0qXDYTVMsy8pg@mail.gmail.com
10 daysAdd some const qualificationsPeter Eisentraut
Add some const qualifications afforded by the previous change that added a const qualification to PageAddItemExtended(). Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://www.postgresql.org/message-id/flat/c75cccf5-5709-407b-a36a-2ae6570be766@eisentraut.org
10 daysRemove Item typePeter Eisentraut
This type is just char * underneath, it provides no real value, no type safety, and just makes the code one level more mysterious. It is more idiomatic to refer to blobs of memory by a combination of void * and size_t, so change it to that. Also, since this type hides the pointerness, we can't apply qualifiers to what is pointed to, which requires some unconstify nonsense. This change allows fixing that. Extension code that uses the Item type can change its code to use void * to be backward compatible. Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Peter Geoghegan <pg@bowt.ie> Discussion: https://www.postgresql.org/message-id/flat/c75cccf5-5709-407b-a36a-2ae6570be766@eisentraut.org
10 daysRemove meaninglist restrict qualifiersPeter Eisentraut
The use of the restrict qualifier in casts is meaningless, so remove them. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/0e3d8644-c01d-4374-86ea-9f0a987981f0%40eisentraut.org
10 daysFix GUC check_hook validation for synchronized_standby_slots.Amit Kapila
Previously, the check_hook for synchronized_standby_slots attempted to validate that each specified slot existed and was physical. However, these checks were not performed during server startup. As a result, if users configured non-existent slots before startup, the misconfiguration would go undetected initially. This could later cause parallel query failures, as newly launched workers would detect the issue and raise an ERROR. This patch improves the check_hook by validating the syntax and format of slot names. Validation of slot existence and type is deferred to the WAL sender process, aligning with the behavior of the check_hook for primary_slot_name. Reported-by: Fabrice Chapuis <fabrice636861@gmail.com> Author: Shlok Kyal <shlok.kyal.oss@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com> Reviewed-by: Rahila Syed <rahilasyed90@gmail.com> Backpatch-through: 17, where it was introduced Discussion: https://postgr.es/m/CAA5-nLCeO4MQzWipCXH58qf0arruiw0OeUc1+Q=Z=4GM+=v1NQ@mail.gmail.com
10 daysImprove test in 009_matviews.pl.Amit Kapila
Ensure that the target table on the subscriber exists before executing any DML intended for replication. Currently, if the table is missing, the replication logic keeps retrying until the table is eventually created by the test. Although this behaviour does not cause test failures, since the table is created after the INSERT is published and replication eventually succeeds, however, it introduces unnecessary looping and delays. Author: Grem Snoort <grem.snoort@gmail.com> Discussion: https://postgr.es/m/CANV9Qw5HD7=Fp4nox2O7DoVctHoabRRVW9Soo4A=QipqW5B=Tg@mail.gmail.com
11 daysComment typo fixes: pg_wchar_t should be pg_wchar.Jeff Davis
Reported-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/CA+hUKGJ5Xh0KxLYXDZuPvw1_fHX=yuzb4xxtam1Cr6TPZZ1o+w@mail.gmail.com
12 daysFix incorrect logic for caching ResultRelInfos for triggersDavid Rowley
When dealing with ResultRelInfos for partitions, there are cases where there are mixed requirements for the ri_RootResultRelInfo. There are cases when the partition itself requires a NULL ri_RootResultRelInfo and in the same query, the same partition may require a ResultRelInfo with its parent set in ri_RootResultRelInfo. This could cause the column mapping between the partitioned table and the partition not to be done which could result in crashes if the column attnums didn't match exactly. The fix is simple. We now check that the ri_RootResultRelInfo matches what the caller passed to ExecGetTriggerResultRel() and only return a cached ResultRelInfo when the ri_RootResultRelInfo matches what the caller wants, otherwise we'll make a new one. Author: David Rowley <dgrowleyml@gmail.com> Author: Amit Langote <amitlangote09@gmail.com> Reported-by: Dmitry Fomin <fomin.list@gmail.com> Discussion: https://postgr.es/m/7DCE78D7-0520-4207-822B-92F60AEA14B4@gmail.com Backpatch-through: 15
12 daysGuard against division by zero in test_int128 module.Dean Rasheed
When testing 128/32-bit division in the test_int128 test module, make sure that we don't attempt to divide by zero. While at it, use pg_prng_int64() and pg_prng_int32() to generate the random numbers required for the tests, rather than pg_prng_uint64(). This eliminates the need for any implicit or explicit type casts. Author: Dean Rasheed <dean.a.rasheed@gmail.com> Reported-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/da4wqngd6gwz5s4yf5y5f75xj7gpja62l4dbp6w4j3vs7fcjue@upvolcu4e6o2
13 dayspg_rewind: Skip copy of WAL segments generated before point of divergenceMichael Paquier
This commit makes the way WAL segments are handled from the source to the target server slightly smarter: the copy of the WAL segments is now skipped if these have been created before the point where source and target have diverged (the WAL segment where the point of divergence exists is still copied), because we know that such segments exist on both the target and source. Note that the on-disk size of the WAL segments on the source and target need to match. Hence, only the segments generated after the point of divergence are now copied. A segment existing on the source but not the target is copied. Previously, all the WAL segments were just copied in full. This change can make the rewind operation cheaper in some configurations, especially for setups where some WAL retention causes many segments to remain on the source server even after the promotion of a standby used as source to rewind a previous primary. A TAP test is added to track these new behaviors. The file map printed with --debug now includes all the information related to WAL segments, to be able to track if these are copied or skipped, and the test relies on the debug output generated. Author: John Hsu <johnhyvr@gmail.com> Author: Justin Kwan <justinpkwan@outlook.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Japin Li <japinli@hotmail.com> Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> Discussion: https://postgr.es/m/181b4c6fa9c.b8b725681941212.7547232617810891479@viggy28.dev
13 dayspsql: Improve tab completion for large objects.Fujii Masao
This commit enhances psql's tab completion support for large objects: - Completes \lo_export <oid> with a file name - Completes GRANT/REVOKE ... LARGE with OBJECT - Completes ALTER DEFAULT PRIVILEGES GRANT/REVOKE ... LARGE with OBJECTS Author: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Co-authored-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Chao Li <lic@highgo.com> Discussion: https://postgr.es/m/87y0syikki.fsf@wibble.ilmari.org
14 daysUpdate expected output for contrib/sepgsql's regression tests.Tom Lane
Commit 65281391a caused some additional error context lines to appear in the output of one test case. That's fine, but we missed updating the expected output. Do it now. While here, add some missing test-output subdirectories to contrib/sepgsql/.gitignore, so that we don't get git warnings after running the tests. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1613232.1761255361@sss.pgh.pa.us Backpatch-through: 18
14 daysdoc: Remove mention of Git protocol supportDaniel Gustafsson
The project Git server hasn't supported cloning with the Git protocol in a very long time, but the documentation never got the memo. Remove the mention of using the Git protocol, and while there wrap a mention of Git in <productname> tags. Backpatch down to all supported versions. Author: Daniel Gustafsson <daniel@yesql.se> Reported-by: Gurjeet Singh <gurjeet@singh.im> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com> Reviewed-by: Gurjeet Singh <gurjeet@singh.im> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CABwTF4WMiMb-KT2NRcib5W0C8TQF6URMb+HK9a_=rnZnY8Q42w@mail.gmail.com Backpatch-through: 13
14 daysAvoid memory leak in validation of a PL/Python trigger function.Tom Lane
If we're trying to perform check_function_bodies validation of a PL/Python trigger function, we create a new PLyProcedure, but we don't put it into the PLy_procedure_cache hash table. (Doing so would be useless, since we don't have the relation OID that is part of the cache key for a trigger function, so we could not make an entry that would be found by later uses.) However, we didn't think through what to do instead, with the result that the PLyProcedure was simply leaked. It would take a pretty large number of CREATE FUNCTION operations for this to amount to a serious problem, but it's easy to see the memory bloat if you do CREATE OR REPLACE FUNCTION in a loop. To fix, have PLy_procedure_get delete the new PLyProcedure and return NULL if it's not going to cache the PLyProcedure. I considered making plpython3_validator do the cleanup instead, which would be more natural. But then plpython3_validator would have to know the rules under which PLy_procedure_get returns a non-cached PLyProcedure, else it risks deleting something that's pointed to by a cache entry. On the whole it seems more robust to deal with the case inside PLy_procedure_get. Found by the new version of Coverity (nice catch!). In the end I feel this fix is more about satisfying Coverity than about fixing a real-world problem, so I'm not going to back-patch.
14 daysFix off-by-one Asserts in FreePageBtreeInsertInternal/Leaf.Tom Lane
These two functions expect there to be room to insert another item in the FreePageBtree's array, but their assertions were too weak to guarantee that. This has little practical effect granting that the callers are not buggy, but it seems to be misleading late-model Coverity into complaining about possible array overrun. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/799984.1761150474@sss.pgh.pa.us Backpatch-through: 13
14 daysFix resource leaks in PL/Python error reporting, redux.Tom Lane
Commit c6f7f11d8 intended to prevent leaking any PyObject reference counts in edge cases (such as out-of-memory during string construction), but actually it introduced a leak in the normal case. Repeating an error-trapping operation often enough would lead to session-lifespan memory bloat. The problem is that I failed to think about the fact that PyObject_GetAttrString() increments the refcount of the returned PyObject, so that simply walking down the list of error frame objects causes all but the first one to have their refcount incremented. I experimented with several more-or-less-complex ways around that, and eventually concluded that the right fix is simply to drop the newly-obtained refcount as soon as we walk to the next frame object in PLy_traceback. This sounds unsafe, but it's perfectly okay because the caller holds a refcount on the first frame object and each frame object holds a refcount on the next one; so the current frame object can't disappear underneath us. By the same token, we can simplify the caller's cleanup back to simply dropping its refcount on the first object. Cleanup of each frame object will lead in turn to the refcount of the next one going to zero. I also added a couple of comments explaining why PLy_elog_impl() doesn't try to free the strings acquired from PLy_get_spi_error_data() or PLy_get_error_data(). That's because I got here by looking at a Coverity complaint about how those strings might get leaked. They are not leaked, but in testing that I discovered this other leak. Back-patch, as c6f7f11d8 was. It's a bit nervous-making to be putting such a fix into v13, which is only a couple weeks from its final release; but I can't see that leaving a recently-introduced leak in place is a better idea. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/1203918.1761184159@sss.pgh.pa.us Backpatch-through: 13
2025-10-23Introduce "REFRESH SEQUENCES" for subscriptions.Amit Kapila
This patch adds support for a new SQL command: ALTER SUBSCRIPTION ... REFRESH SEQUENCES This command updates the sequence entries present in the pg_subscription_rel catalog table with the INIT state to trigger resynchronization. In addition to the new command, the following subscription commands have been enhanced to automatically refresh sequence mappings: ALTER SUBSCRIPTION ... REFRESH PUBLICATION ALTER SUBSCRIPTION ... ADD PUBLICATION ALTER SUBSCRIPTION ... DROP PUBLICATION ALTER SUBSCRIPTION ... SET PUBLICATION These commands will perform the following actions: Add newly published sequences that are not yet part of the subscription. Remove sequences that are no longer included in the publication. This ensures that sequence replication remains aligned with the current state of the publication on the publisher side. Note that the actual synchronization of sequence data/values will be handled in a subsequent patch that introduces a dedicated sequence sync worker. Author: Vignesh C <vignesh21@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Peter Smith <smithpb2250@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Shlok Kyal <shlok.kyal.oss@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com> Discussion: https://postgr.es/m/CAA4eK1LC+KJiAkSrpE_NwvNdidw9F2os7GERUeSxSKv71gXysQ@mail.gmail.com
2025-10-23pg_rewind: Extend code detecting relation files to work with WAL filesMichael Paquier
isRelDataFile() is renamed to getFileContentType(), extended so as it becomes able to detect more file patterns than only relation files. The new file name pattern that can be detected is WAL files. This refactoring has been suggested by Robert Haas. This will be used in a follow-up patch where we are looking at improving how WAL files are processed by pg_rewind. As of this change, WAL files are still handled the same way as previously, always copied from the source to the target server. Extracted from a larger patch by the same authors. Author: John Hsu <johnhyvr@gmail.com> Author: Justin Kwan <justinpkwan@outlook.com> Reviewed-by: Japin Li <japinli@hotmail.com> Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> Discussion: https://postgr.es/m/181b4c6fa9c.b8b725681941212.7547232617810891479@viggy28.dev
2025-10-23Add comments explaining overflow entries in the replication lag tracker.Fujii Masao
Commit 883a95646a8 introduced overflow entries in the replication lag tracker to fix an issue where lag columns in pg_stat_replication could stall when the replay LSN stopped advancing. This commit adds comments clarifying the purpose and behavior of overflow entries to improve code readability and understanding. Since commit 883a95646a8 was recently applied and backpatched to all supported branches, this follow-up commit is also backpatched accordingly. Author: Xuneng Zhou <xunengzhou@gmail.com> Reviewed-by: Fujii Masao <masao.fujii@gmail.com> Discussion: https://postgr.es/m/CABPTF7VxqQA_DePxyZ7Y8V+ErYyXkmwJ1P6NC+YC+cvxMipWKw@mail.gmail.com Backpatch-through: 13
2025-10-23Fix coding style with "else".Tatsuo Ishii
The "else" code block having single statement with comments on a separate line should have been surrounded by braces. Reported-by: Chao Li <lic@highgo.com> Suggested-by: David Rowley <dgrowleyml@gmail.com> Author: Tatsuo Ishii <ishii@postgresql.org> Discussion: https://postgr.es/m/20251020.125847.997839131426057290.ishii%40postgresql.org
2025-10-23Fix some misplaced comments in parallel_scheduleDavid Rowley
These are listing which other tests one of the tests in the subsequent group depends on. A couple of comments were located with unrelated tests. In passing, fix a small grammatical issue. Noticed in passing while working on something else. Author: David Rowley <dgrowleyml@gmail.com>
2025-10-22Add copyright notice to vacuum_horizon_floor.pl test.Masahiko Sawada
Fix oversight in commit 303ba0573, which was backpatched through 14. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CAD21AoBeFdTJcwUfUYPcEgONab3TS6i1PB9S5cSXcBAmdAdQKw%40mail.gmail.com Backpatch-through: 14
2025-10-23Fix incorrect zero extension of Datum in JIT tuple deform codeDavid Rowley
When JIT deformed tuples (controlled via the jit_tuple_deforming GUC), types narrower than sizeof(Datum) would be zero-extended up to Datum width. This wasn't the same as what fetch_att() does in the standard tuple deforming code. Logically the values are the same when fetching via the DatumGet*() marcos, but negative numbers are not the same in binary form. In the report, the problem was manifesting itself with: ERROR: could not find memoization table entry in a query which had a "Cache Mode: binary" Memoize node. However, it's currently unclear what else is affected. Anything that uses datum_image_eq() or datum_image_hash() on a Datum from a tuple deformed by JIT could be affected, but it may not be limited to that. The fix for this is simple: use signed extension instead of zero extension. Many thanks to Emmanuel Touzery for reporting this issue and providing steps and backup which allowed the problem to easily be recreated. Reported-by: Emmanuel Touzery <emmanuel.touzery@plandela.si> Author: David Rowley <dgrowleyml@gmail.com> Discussion: https://postgr.es/m/DB8P194MB08532256D5BAF894F241C06393F3A@DB8P194MB0853.EURP194.PROD.OUTLOOK.COM Backpatch-through: 13
2025-10-22Avoid assuming that time_t can fit in an int.Tom Lane
We had several places that used cast-to-unsigned-int as a substitute for properly checking for overflow. Coverity has started objecting to that practice as likely introducing Y2038 bugs. An extra comparison is surely not much compared to the cost of time(NULL), nor is this coding practice particularly readable. Let's do it honestly, with explicit logic covering the cases of first-time-through and clock-went-backwards. I don't feel a need to back-patch though: our released versions will be out of support long before 2038, and besides which I think the code would accidentally work anyway for another 70 years or so.
2025-10-22Fix type of infomask parameter in htup_details.h functions.Nathan Bossart
Oversight in commit 34694ec888. Since there aren't any known live bugs related to this, no back-patch. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/aPk4u955ZPPZ_nYw%40nathan
2025-10-22Remove useless pstrdup() calls.Tom Lane
The result of PLyUnicode_AsString is already palloc'd, so pstrdup'ing it is just a waste of time and memory. More importantly it might confuse people about whether that's necessary. Doesn't seem important enough to back-patch, but we should fix it. Spotted by Coverity.
2025-10-22Fix memory leaks in scripts/vacuuming.c.Tom Lane
Coverity complained that the list of table names returned by retrieve_objects() was leaked, and it's right. Potentially this is quite a lot of memory; however, it's not entirely clear how much we gain by cleaning it up, since in many operating modes we're going to need the list until the program is about to exit. Still, it will win in some cases, so fix the leak. vacuuming.c is new in v19, and this patch doesn't apply at all cleanly to the predecessor code in v18. I'm not excited enough about the issue to devise a back-patch.
2025-10-22Fix memory leaks in pg_combinebackup/reconstruct.c.Tom Lane
One code path forgot to free the separately-malloc'd filename part of a struct rfile. Another place freed the filename but forgot the struct rfile itself. These seem worth fixing because with a large backup we could be dealing with many files. Coverity found the bug in make_rfile(). I found the other one by manual inspection.
2025-10-22Remove make_temptable_name_n().Nathan Bossart
This small function is only used in one place, and it fails to handle quoted table names (although the table name portion of the input should never be quoted in current usage). In addition to removing make_temptable_name_n() in favor of open-coding it where needed, this commit ensures the "diff" table name is properly quoted in order to future-proof this area a bit. Author: Aleksander Alekseev <aleksander@tigerdata.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Shinya Kato <shinya11.kato@gmail.com> Discussion: https://postgr.es/m/CAJ7c6TO3a5q2NKRsjdJ6sLf8isVe4aMaaX1-Hj2TdHdhFw8zRA%40mail.gmail.com
2025-10-22Make invalid primary_slot_name follow standard GUC error reporting.Fujii Masao
Previously, if primary_slot_name was set to an invalid slot name and the configuration file was reloaded, both the postmaster and all other backend processes reported a WARNING. With many processes running, this could produce a flood of duplicate messages. The problem was that the GUC check hook for primary_slot_name reported errors at WARNING level via ereport(). This commit changes the check hook to use GUC_check_errdetail() and GUC_check_errhint() for error reporting. As with other GUC parameters, this causes non-postmaster processes to log the message at DEBUG3, so by default, only the postmaster's message appears in the log file. Backpatch to all supported versions. Author: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Chao Li <lic@highgo.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com> Discussion: https://postgr.es/m/CAHGQGwFud-cvthCTfusBfKHBS6Jj6kdAPTdLWKvP2qjUX6L_wA@mail.gmail.com Backpatch-through: 13
2025-10-22Fix multi WinGetFuncArgInFrame/Partition calls with IGNORE NULLS.Tatsuo Ishii
Previously it was mistakenly assumed that there's only one window function argument which needs to be processed by WinGetFuncArgInFrame or WinGetFuncArgInPartition when IGNORE NULLS option is specified. To eliminate the limitation, WindowObject->notnull_info is modified from "uint8 *" to "uint8 **" so that WindowObject->notnull_info could store pointers to "uint8 *" which holds NOT NULL info corresponding to each window function argument. Moreover, WindowObject->num_notnull_info is changed from "int" to "int64 *" so that WindowObject->num_notnull_info could store the number of NOT NULL info corresponding to each function argument. Memories for these data structures will be allocated when WinGetFuncArgInFrame or WinGetFuncArgInPartition is called. Thus no memory except the pointers is allocated for function arguments which do not call these functions Also fix the set mark position logic in WinGetFuncArgInPartition to not raise a "cannot fetch row before WindowObject's mark position" error in IGNORE NULLS case. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Author: Tatsuo Ishii <ishii@postgresql.org> Discussion: https://postgr.es/m/2952409.1760023154%40sss.pgh.pa.us