summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-02-19Fix incorrect pruning of NULL partition for boolean IS NOT clausesDavid Rowley
Partition pruning wrongly assumed that, for a table partitioned on a boolean column, a clause in the form "boolcol IS NOT false" and "boolcol IS NOT true" could be inverted to correspondingly become "boolcol IS true" and "boolcol IS false". These are not equivalent as the NOT version matches the opposite boolean value *and* NULLs. This incorrect assumption meant that partition pruning pruned away partitions that could contain NULL values. Here we fix this by correctly not pruning partitions which could store NULLs. To be affected by this, the table must be partitioned by a NULLable boolean column and queries would have to contain "boolcol IS NOT false" or "boolcol IS NOT true". This could result in queries filtering out NULL values with a LIST partitioned table and "ERROR: invalid strategy number 0" for RANGE and HASH partitioned tables. Reported-by: Alexander Lakhin Bug: #18344 Discussion: https://postgr.es/m/[email protected] Backpatch-through: 12
2024-02-19Fix test race between primary XLOG_RUNNING_XACTS and standby logical slot.Noah Misch
Before the previous commit, the test could hang until LOG_SNAPSHOT_INTERVAL_MS (15s), until checkpoint_timeout (300s), or indefinitely. An indefinite hang was awfully improbable. It entailed the test reaching checkpoint_timeout before the DecodingContextFindStartpoint() of a CREATE SUBSCRIPTION, yet after the preceding WAL record. Back-patch to v16, which introduced the test. Bertrand Drouvot, reported by Noah Misch. Discussion: https://postgr.es/m/[email protected]
2024-02-19Bound waits in 035_standby_logical_decoding.pl.Noah Misch
One IPC::Run::start() used an IPC::Run::timer() without checking for expiration. The other used no timeout or timer. Back-patch to v16, which introduced the test. Reviewed by Bertrand Drouvot. Discussion: https://postgr.es/m/[email protected]
2024-02-19Get rid of pg_class usage in SJE regression testsAlexander Korotkov
Usage of pg_class led to instability, see the buildfarm failure. https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=prion&dt=2024-02-15%2021%3A58%3A04 Reported-by: Andrei Lepikhov Discussion: https://postgr.es/m/[email protected]
2024-02-19Fix 004_subscription.pl to allow its usage in --link mode.Amit Kapila
The test was failing when executed in --link mode and the reason was that we were using the old cluster from a previously successful upgrade test. Re-arrange the tests so that the successful test case is at the end. Reported-by: Justin Pryzby, Peter Eisentraut Author: Kuroda Hayato Reviewed-by: Vignesh C, Amit Kapila Discussion: https://postgr.es/m/ZcvZipRoi_kopIpb@pryzbyj2023 Discussion: https://postgr.es/m/[email protected]
2024-02-19ecpg: Fix zero-termination of string generated by intoasc()Michael Paquier
intoasc(), a wrapper for PGTYPESinterval_to_asc that converts an interval to its textual representation, used a plain memcpy() when copying its result. This could miss a zero-termination in the result string, leading to an incorrect result. The routines in informix.c do not provide the length of their result buffer, which would allow a replacement of strcpy() to safer strlcpy() calls, but this requires an ABI breakage and that cannot happen in back-branches. Author: Oleg Tselebrovskiy Reviewed-by: Ashutosh Bapat Discussion: https://postgr.es/m/[email protected] Backpatch-through: 12
2024-02-19ecpg: Fix error handling on OOMs when parsing timestampsMichael Paquier
pgtypes_alloc() can return NULL when failing an allocation, which is something that PGTYPEStimestamp_defmt_asc() has forgotten about when translating a timestamp for 'D', 'r', 'R' and 'T' as these require a temporary allocation. This is unlikely going to be a problem in practice, so no backpatch is done. Author: Oleg Tselebrovskiy Discussion: https://postgr.es/m/[email protected]
2024-02-16Remove remaining references to timeouts-longAlexander Korotkov
Reported-by: Alexander Lakhin
2024-02-16Use new overflow-safe integer comparison functions.Nathan Bossart
Commit 6b80394781 introduced integer comparison functions designed to be as efficient as possible while avoiding overflow. This commit makes use of these functions in many of the in-tree qsort() comparators to help ensure transitivity. Many of these comparator functions should also see a small performance boost. Author: Mats Kindahl Reviewed-by: Andres Freund, Fabrízio de Royes Mello Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com
2024-02-16Introduce overflow-safe integer comparison functions.Nathan Bossart
This commit adds integer comparison functions that are designed to be as efficient as possible while avoiding overflow. A follow-up commit will make use of these functions in many of the in-tree qsort() comparators. The new functions are not better in all cases (e.g., when the comparator function is inlined), so it is important to consider the context before using them. Author: Mats Kindahl Reviewed-by: Tom Lane, Heikki Linnakangas, Andres Freund, Thomas Munro, Andrey Borodin, Fabrízio de Royes Mello Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com
2024-02-16Pass correct count to WALRead().Jeff Davis
Previously, some callers requested XLOG_BLCKSZ bytes unconditionally. While this did not cause a problem, because the extra bytes are ignored, it's confusing and makes it harder to add safety checks. Additionally, the comment about zero padding was incorrect. With this commit, all callers request the number of bytes they actually need. Author: Bharath Rupireddy Reviewed-by: Kyotaro Horiguchi Discussion: https://postgr.es/m/CALj2ACWBRFac2TingD3PE3w2EBHXUHY3=AEEZPJmqhpEOBGExg@mail.gmail.com
2024-02-16Add assert to WALReadFromBuffers().Jeff Davis
Per suggestion from Andres. Discussion: https://postgr.es/m/[email protected]
2024-02-16Replace calls to pg_qsort() with the qsort() macro.Nathan Bossart
Calls to this function might give the impression that pg_qsort() is somehow different than qsort(), when in fact there is a qsort() macro in port.h that expands all in-tree uses to pg_qsort(). Reviewed-by: Mats Kindahl Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com
2024-02-16Add missing check_stack_depth() to some recursive functionsAlexander Korotkov
Reported-by: Egor Chindyaskin, Alexander Lakhin Discussion: https://postgr.es/m/1672760457.940462079%40f306.i.mail.ru
2024-02-16Remove timeouts-long.outAlexander Korotkov
bf82f43790 removes timeouts-long.spec, but forgets to remove timeouts-long.out. Reported-by: Alexander Lakhin
2024-02-16Improve compression and storage support with inheritancePeter Eisentraut
A child table can specify a compression or storage method different from its parents. This was previously an error. (But this was inconsistently enforced because for example the settings could be changed later using ALTER TABLE.) This now also allows an explicit override if multiple parents have different compression or storage settings, which was previously an error that could not be overridden. The compression and storage properties remains unchanged in a child inheriting from parent(s) after its creation, i.e., when using ALTER TABLE ... INHERIT. (This is not changed.) Before this change, the error detail would mention the first pair of conflicting parent compression or storage methods. But with this change it waits till the child specification is considered by which time we may have encountered many such conflicting pairs. Hence the error detail after this change does not include the conflicting compression/storage methods. Those can be obtained from parent definitions if necessary. The code to maintain list of all conflicting methods or even the first conflicting pair does not seem worth the convenience it offers. This change is inline with what we do with conflicting default values. Before this commit, the specified storage method could be stored in ColumnDef::storage (CREATE TABLE ... LIKE) or ColumnDef::storage_name (CREATE TABLE ...). This caused the MergeChildAttribute() and MergeInheritedAttribute() to ignore a storage method specified in the child definition since it looked only at ColumnDef::storage. This commit removes ColumnDef::storage and instead uses ColumnDef::storage_name to save any storage method specification. This is similar to how compression method specification is handled. Author: Ashutosh Bapat <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/[email protected]
2024-02-16Disable autovacuum on primary in 040_standby_failover_slots_sync test.Amit Kapila
Disable autovacuum to avoid generating xid during stats update as otherwise the new XID could then be replicated to standby at some random point making slots at primary lag behind standby during slot sync. As per buildfarm Author: Hou Zhijie Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/CAA4eK1Jun8SGCoc6JEktxY_+L7GmoJWrdsx-KCEP=GL-SsWggQ@mail.gmail.com
2024-02-16Fix the incorrect format specifier used in commit 7a424ece48.Amit Kapila
Author: Hou Zhijie Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/OS0PR01MB5716CB015BAD807B29BC55BE944C2@OS0PR01MB5716.jpnprd01.prod.outlook.com
2024-02-16Change the LOG level in 040_standby_failover_slots_sync.pl to DEBUG2.Amit Kapila
Temporarily change the log level of 040_standby_failover_slots_sync.pl to DEBUG2. This is to get more information about BF failures. We will reset it back to default once the tests are stabilized. Author: Hou Zhijie Reviewed-by: Amit Kapila Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/OS0PR01MB571633C23B2A4CAC5FB0371A944C2@OS0PR01MB5716.jpnprd01.prod.outlook.com
2024-02-16Add more LOG and DEBUG messages for slot synchronization.Amit Kapila
This provides more information about remote slots during synchronization which helps in debugging bugs and BF failures due to test case issues. We might later want to change the LOG message added by this patch to DEBUG1. Author: Hou Zhijie Reviewed-by: Amit Kapila, Bertrand Drouvot Discussion: https://postgr.es/m/[email protected] Discussion: https://postgr.es/m/OS0PR01MB571633C23B2A4CAC5FB0371A944C2@OS0PR01MB5716.jpnprd01.prod.outlook.com
2024-02-16Attempt to stabilize flapping regression testDavid Rowley
Per buildfarm animal mylodon, the plan for this test was sometimes swapping the join order for tenk1 and tenk2. Given that add_path() has no code that would cause this fluctuation when given paths with consistent costs, this indicates that the costs must be fluctuating in some runs. The only proven reason I've seen where that could happen was slight variations in pg_class.relpages for some tables. This was demonstrated to be true by f03a9ca43 and related discussion. Manually adjusting tenk2's pg_class.relpages by subtracting just 1 page does cause the plan to change for this test. Here we've not gone to the same lengths to prove that's what's going on in this case. Proving that does not seem worth the time. Let's just shrink one side of the join so the additional cost of the swapped join order is sufficiently different that if the relpages estimate is off a few pages that the planner still shouldn't swap the join order. Reported-by: Thomas Munro Author: Andy Fan, David Rowley Discussion: https://postgr.es/m/CA+hUKGLqC-NobKYfjxNM3Gexv9OJ-Fhvy9bugUcXsZjTqH7W=Q@mail.gmail.com
2024-02-16Followup fixes for transaction_timeoutAlexander Korotkov
Don't deal with transaction timeout in PostgresMain(). Instead, release transaction timeout activated by StartTransaction() in CommitTransaction()/AbortTransaction()/PrepareTransaction(). Deal with both enabling and disabling transaction timeout in assign_transaction_timeout(). Also, remove potentially flaky timeouts-long isolation test, which has no guarantees to pass on slow/busy machines. Reported-by: Andres Freund Discussion: https://postgr.es/m/20240215230856.pc6k57tqxt7fhldm%40awork3.anarazel.de
2024-02-15Introduce transaction_timeoutAlexander Korotkov
This commit adds timeout that is expected to be used as a prevention of long-running queries. Any session within the transaction will be terminated after spanning longer than this timeout. However, this timeout is not applied to prepared transactions. Only transactions with user connections are affected. Discussion: https://postgr.es/m/CAAhFRxiQsRs2Eq5kCo9nXE3HTugsAAJdSQSmxncivebAxdmBjQ%40mail.gmail.com Author: Andrey Borodin <[email protected]> Author: Japin Li <[email protected]> Author: Junwang Zhao <[email protected]> Reviewed-by: Nikolay Samokhvalov <[email protected]> Reviewed-by: Andres Freund <[email protected]> Reviewed-by: Fujii Masao <[email protected]> Reviewed-by: bt23nguyent <[email protected]> Reviewed-by: Yuhang Qiu <[email protected]>
2024-02-15Doc: improve a couple of comments in postgresql.conf.sample.Tom Lane
Clarify comments associated with max_parallel_workers and related settings. Per bug #18343 from Christopher Kline. Discussion: https://postgr.es/m/[email protected]
2024-02-15Pull up ANY-SUBLINK with the necessary lateral support.Alexander Korotkov
For ANY-SUBLINK, we adopted a two-stage pull-up approach to handle different types of scenarios. In the first stage, the sublink is pulled up as a subquery. Because of this, when writing this code, we did not have the ability to perform lateral joins, and therefore, we were unable to pull up Var with varlevelsup=1. Now that we have the ability to use lateral joins, we can eliminate this limitation. Author: Andy Fan <[email protected]> Author: Tom Lane <[email protected]> Reviewed-by: Tom Lane <[email protected]> Reviewed-by: Richard Guo <[email protected]> Reviewed-by: Alena Rybakina <[email protected]> Reviewed-by: Andrey Lepikhov <[email protected]>
2024-02-15Allow passing extra options to initdb for testsPeter Eisentraut
Setting the environment variable PG_TEST_INITDB_EXTRA_OPTS passes extra options to initdb run by pg_regress or PostgreSQL::Test::Cluster's init. This can be useful for a wide variety of uses, like running all tests with checksums enabled, or with JIT enabled, or with different GUC settings, or with different locale settings. (Not all tests are going to pass with arbitrary options, but it is useful to run this against specific test suites.) Reviewed-by: Ian Lawrence Barwick <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/d4d2ad9f-1c1d-47a1-bb4d-c10a747d4f15%40eisentraut.org
2024-02-15Another try to fix BF failure introduced in commit ddd5f4f54a.Amit Kapila
Before attempting to sync the slot on standby by pg_sync_replication_slots(), ensure that on the primary restart_lsn for the slot has moved to a recent WAL position, by re-creating the subscription and the logical slot. Author: Hou Zhijie Discussion: https://postgr.es/m/CAA4eK1+d5Lne8vCAn0un4SP9x-ZBr2-xfxg01uSfeBTSCKFZoQ@mail.gmail.com
2024-02-15Simplify PathKey checking codeDavid Rowley
pathkeys_useful_for_ordering() contained some needless checks to return 0 when either root->query_pathkeys or pathkeys lists were empty. This is already handled by pathkeys_count_contained_in(), so let's have it do the work instead of having redundant checks. Similarly, in pathkeys_useful_for_grouping(), checking pathkeys is an empty list just before looping over it isn't required. Technically, neither is the list empty check for group_pathkeys, but I felt a bit more work would have to be done to get the equivalent behavior if we'd left it up to the foreach loop to call list_member_ptr(). This was noticed by Andy while he was reviewing a patch to improve the UNION planner. Since that patch adds another function similar to pathkeys_useful_for_ordering() and since I wasn't planning to copy these redundant checks over to the new function, let's adjust the existing code so that both functions will be consistent. Author: Andy Fan Discussion: https://postgr.es/m/[email protected]
2024-02-15Clarify the 'rows' parameter in create_append_pathDavid Rowley
This is extracted from a larger patch to improve the UNION planner. While working on that, I found myself having to check what the 'rows' parameter is for. It's not obvious that passing a negative number is the way to have the rows estimate calculated and to find that out you need to read code in create_append_path() and in cost_append(). Discussion: https://postgr.es/m/CAApHDvpb_63XQodmxKUF8vb9M7CxyUyT4sWvEgqeQU-GB7QFoQ@mail.gmail.com
2024-02-14Remove obsolete check in SIGTERM handler for the startup process.Nathan Bossart
Thanks to commit 3b00fdba9f, this check in the SIGTERM handler for the startup process is now obsolete and can be removed. Instead of leaving around the dead function write_stderr_signal_safe(), I've opted to just remove it for now. This partially reverts commit 97550c0711. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
2024-02-14Centralize logic for restoring errno in signal handlers.Nathan Bossart
Presently, we rely on each individual signal handler to save the initial value of errno and then restore it before returning if needed. This is easily forgotten and, if missed, often goes undetected for a long time. In commit 3b00fdba9f, we introduced a wrapper signal handler function that checks whether MyProcPid matches getpid(). This commit moves the aforementioned errno restoration code from the individual signal handlers to the new wrapper handler so that we no longer need to worry about missing it. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
2024-02-14Check that MyProcPid == getpid() in backend signal handlers.Nathan Bossart
In commit 97550c0711, we added a similar check to the SIGTERM handler for the startup process. This commit adds this check to backend signal handlers installed with pqsignal(). This is done by using a wrapper function that performs the check before calling the actual handler. The hope is that this will offer more general protection against child processes of Postgres backends inadvertently modifying shared memory due to inherited signal handlers. Another potential follow-up improvement is to use this wrapper handler function to restore errno instead of relying on each individual handler function to do so. This commit makes the changes in commit 97550c0711 obsolete but leaves reverting it for a follow-up commit. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
2024-02-14Allow pg_monitor to execute pg_current_logfile().Nathan Bossart
We allow roles with privileges of pg_monitor to execute functions like pg_ls_logdir(), so it seems natural that such roles would also be able to execute this function. Bumps catversion. Co-authored-by: Pavlo Golub Reviewed-by: Daniel Gustafsson Discussion: https://postgr.es/m/CAK7ymcLmEYWyQkiCZ64WC-HCzXAB0omM%3DYpj9B3rXe8vUAFMqw%40mail.gmail.com
2024-02-14Fix multiranges to behave more like dependent types.Tom Lane
For most purposes, multiranges act like dependent objects of the associated range type: you can't create them separately or drop them separately. This is like the way that autogenerated array types behave. However, a couple of points were overlooked: array types automatically track the ownership of their base type, and array types do not have their own permissions but use those of the base type, while multiranges didn't emulate those behaviors. This is fairly broken, mainly because pg_dump doesn't think it needs to worry about multiranges as separate objects, and thus it fails to dump/restore ownership or permissions of multiranges. There's no apparent value in letting a multirange diverge from its parent's ownership or permissions, so let's make them act like arrays in these respects. However, we continue to let multiranges be renamed or moved to a different schema independently of their parent, since that doesn't break anything. Discussion: https://postgr.es/m/[email protected]
2024-02-14Fix BF introduced in commit ddd5f4f54a.Amit Kapila
The failure is that the remote slot is not synchronized after the same slot on standby gets invalidated. The reason was that remote_slot's restart_lsn was lagged behind the standby's oldest WAL segment. The test didn't ensure that remote_slot's LSN was advanced to the latest position before we tried to sync the slots via new the function pg_sync_replication_slots(). Discussion: https://postgr.es/m/CAA4eK1JLBi3HzenB6do3_hd78kN0UDD1mz-vumWE52XHHEq5Bw@mail.gmail.com
2024-02-14Add a slot synchronization function.Amit Kapila
This commit introduces a new SQL function pg_sync_replication_slots() which is used to synchronize the logical replication slots from the primary server to the physical standby so that logical replication can be resumed after a failover or planned switchover. A new 'synced' flag is introduced in pg_replication_slots view, indicating whether the slot has been synchronized from the primary server. On a standby, synced slots cannot be dropped or consumed, and any attempt to perform logical decoding on them will result in an error. The logical replication slots on the primary can be synchronized to the hot standby by using the 'failover' parameter of pg-create-logical-replication-slot(), or by using the 'failover' option of CREATE SUBSCRIPTION during slot creation, and then calling pg_sync_replication_slots() on standby. For the synchronization to work, it is mandatory to have a physical replication slot between the primary and the standby aka 'primary_slot_name' should be configured on the standby, and 'hot_standby_feedback' must be enabled on the standby. It is also necessary to specify a valid 'dbname' in the 'primary_conninfo'. If a logical slot is invalidated on the primary, then that slot on the standby is also invalidated. If a logical slot on the primary is valid but is invalidated on the standby, then that slot is dropped but will be recreated on the standby in the next pg_sync_replication_slots() call provided the slot still exists on the primary server. It is okay to recreate such slots as long as these are not consumable on standby (which is the case currently). This situation may occur due to the following reasons: - The 'max_slot_wal_keep_size' on the standby is insufficient to retain WAL records from the restart_lsn of the slot. - 'primary_slot_name' is temporarily reset to null and the physical slot is removed. The slot synchronization status on the standby can be monitored using the 'synced' column of pg_replication_slots view. A functionality to automatically synchronize slots by a background worker and allow logical walsenders to wait for the physical will be done in subsequent commits. Author: Hou Zhijie, Shveta Malik, Ajin Cherian based on an earlier version by Peter Eisentraut Reviewed-by: Masahiko Sawada, Bertrand Drouvot, Peter Smith, Dilip Kumar, Nisha Moond, Kuroda Hayato, Amit Kapila Discussion: https://postgr.es/m/[email protected]
2024-02-14Revert "Refactor CopyReadAttributes{CSV,Text}() to use a callback in COPY FROM"Michael Paquier
This reverts commit 95fb5b49024, for reasons similar to what led to 1aa8324b81fa. In this case, the callback was called once per row, which is less worse than the previous callback introduced for COPY TO called once per argument for each row, still the patch set discussed to plug in custom routines to the COPY paths would be able to know which subroutine to use depending on its CopyFromState, so this led to a suboptimal approach at the end. For now, this part is reverted to consider better which approach to use. Discussion: https://postgr.es/m/[email protected]
2024-02-13Improve comment about query_id_enabled in queryjumblefuncs.cMichael Paquier
The comment was inexact because query_id_enabled will not be switched to "true" even if compute_query_id is "on", unless a module requests for it. While on it, this adds a comment to mention that IsQueryIdEnabled() should be used to check if query ID computation is enabled or not. Author: Yugo Nagata Reviewed-by: Julien Rouhaud Discussion: https://postgr.es/m/[email protected]
2024-02-13Catch overflow when rounding intervals in AdjustIntervalForTypmod.Tom Lane
Previously, an interval microseconds field close to INT64_MAX or INT64_MIN could overflow, producing a result with not even the correct sign, while being rounded to match a precision specification. This seems worth fixing, but not worth back-patching, in part because the ereturn() notation doesn't exist very far back. Report and patch by Joseph Koshakow (some cosmetic mods by me) Discussion: https://postgr.es/m/CAAvxfHfpuLgqJYzkUcher466Z1LpmE+5Sm+zc8L6zKCOQ+6TDQ@mail.gmail.com
2024-02-13Fix 'mmap' DSM implementation with allocations larger than 4 GBHeikki Linnakangas
Fixes bug #18341. Backpatch to all supported versions. Discussion: https://www.postgresql.org/message-id/[email protected]
2024-02-13Use a safer outfuncs/readfuncs representation for BitStrings.Tom Lane
For a long time, our outfuncs.c code has supposed that the string contents of a BitString node could just be printed literally with no concern for quoting/escaping. Now, that's okay if the string literal contains only valid binary or hex digits ... but our lexer doesn't check that, preferring to let bitin() be the sole authority on what's valid. So we could have raw parse trees that contain incorrect BitString literals, and that can result in failures when WRITE_READ_PARSE_PLAN_TREES debugging is enabled. Fix by using outToken() to print the string field, and debackslash() to read it. This results in a change in the emitted representation only in cases that would have failed before, and don't represent valid SQL in the first place. Between that and the fact that we don't store raw parse trees in the catalogs, I judge this safe to apply without a catversion bump. Per bug #18340 from Alexander Lakhin. Back-patch to v16; before that, we lacked readfuncs support for BitString nodes, so that the problem was only cosmetic. Discussion: https://postgr.es/m/[email protected]
2024-02-13Skip .DS_Store files in server side utilsDaniel Gustafsson
The macOS Finder application creates .DS_Store files in directories when opened, which creates problems for serverside utilities which expect all files to be PostgreSQL specific files. Skip these files when encountered in pg_checksums, pg_rewind and pg_basebackup. This was extracted from a larger patchset for skipping hidden files and system files, where the concencus was to just skip these. Since this is equally likely to happen in every version, backpatch to all supported versions. Reported-by: Mark Guertin <[email protected]> Reviewed-by: Michael Paquier <[email protected]> Reviewed-by: Tobias Bussmann <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: v12
2024-02-13Use correct format placeholder for timeline IDsPeter Eisentraut
Should be %u rather than %d.
2024-02-12Read WAL directly from WAL buffers.Jeff Davis
If available, read directly from WAL buffers, avoiding the need to go through the filesystem. Only for physical replication for now, but can be expanded to other callers. In preparation for replicating unflushed WAL data. Author: Bharath Rupireddy Discussion: https://postgr.es/m/CALj2ACXKKK%3DwbiG5_t6dGao5GoecMwRkhr7GjVBM_jg54%2BNa%3DQ%40mail.gmail.com Reviewed-by: Andres Freund, Alvaro Herrera, Nathan Bossart, Dilip Kumar, Nitin Jadhav, Melih Mutlu, Kyotaro Horiguchi
2024-02-12Remove "#ifdef WIN32" guards from src/port/win32*.cHeikki Linnakangas
These files are only compiled on Windows, and most of them didn't have "#ifdef WIN32" guards. Remove them from the few that did, for consistency. Author: Tristan Partin Discussion: https://www.postgresql.org/message-id/[email protected]
2024-02-12Remove unnecessary smgropen() callsHeikki Linnakangas
Now that RelationCreateStorage() returns the SmgrRelation (since commit 5c1560606dc), use that. Author: Japin Li Discussion: https://www.postgresql.org/message-id/ME3P282MB316600FA62F6605477F26F6AB6742@ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
2024-02-11Use heap_inplace_update() to unset pg_database.dathasloginevtAlexander Korotkov
Doing this instead of regular updates serves two purposes. First, that avoids possible waiting on the row-level lock. Second, that avoids dealing with TOAST. It's known that changes made by heap_inplace_update() may be lost due to concurrent normal updates. However, we are OK with that. The subsequent connections will still have a chance to set "dathasloginevt" to false. Reported-by: Alexander Lakhin Discussion: https://postgr.es/m/e2a0248e-5f32-af0c-9832-a90d303c2c61%40gmail.com
2024-02-11Remove obsolete script related to MSVC build systemPeter Eisentraut
2024-02-11Fix gai_strerror() thread-safety on Windows.Thomas Munro
Commit 5579388d removed code that supplied a fallback implementation of getaddrinfo(), which was dead code on modern systems. One tiny piece of the removed code was still doing something useful on Windows, though: that OS's own gai_strerror()/gai_strerrorA() function returns a pointer to a static buffer that it overwrites each time, so it's not thread-safe. In rare circumstances, a multi-threaded client program could get an incorrect or corrupted error message. Restore the replacement gai_strerror() function, though now that it's only for Windows we can put it into a win32-specific file and cut it down to the errors that Windows documents. The error messages here are taken from FreeBSD, because Windows' own messages seemed too verbose. Back-patch to 16. Reviewed-by: Kyotaro Horiguchi <[email protected]> Discussion: https://postgr.es/m/CA%2BhUKGKz%2BF9d2PTiXwfYV7qJw%2BWg2jzACgSDgPizUw7UG%3Di58A%40mail.gmail.com
2024-02-11Use extensible buffers to assemble command linesPeter Eisentraut
This makes use of StringInfo to assemble command lines, instead of using fixed-size buffers and the (remote) possibility of "command too long" errors. Also makes the code a bit simpler. This covers the test driver programs pg_regress and pg_isolation_regress. Similar to the changes done for pg_rewind in a33e17f210. Discussion: https://www.postgresql.org/message-id/2be4fee5-738f-4749-b9f8-b452032c7ade%40eisentraut.org