pgsql: Revert unnecessary check for NULL

2025-08-22 Thread Heikki Linnakangas
Revert unnecessary check for NULL Jelte pointed out that this was unnecessary, but I failed to remove it before pushing f6f0542266. Oops. Reviewed-by: Jelte Fennema-Nio Discussion: https://www.postgresql.org/message-id/cageczqt%3dxnv-v%2bvfc7yqwyqmj0wgn61b3p%3dj1_rl6m0vbjt...@mail.gmail.com Bac

pgsql: Revert unnecessary check for NULL

2025-08-22 Thread Heikki Linnakangas
Revert unnecessary check for NULL Jelte pointed out that this was unnecessary, but I failed to remove it before pushing f6f0542266. Oops. Reviewed-by: Jelte Fennema-Nio Discussion: https://www.postgresql.org/message-id/cageczqt%3dxnv-v%2bvfc7yqwyqmj0wgn61b3p%3dj1_rl6m0vbjt...@mail.gmail.com Bac

pgsql: libpq: Handle OOM by disconnecting instead of hanging or skippin

2025-08-22 Thread Heikki Linnakangas
libpq: Handle OOM by disconnecting instead of hanging or skipping msgs In most cases, if an out-of-memory situation happens, we attach the error message to the connection and report it at the next PQgetResult() call. However, there are a few cases, while processing messages that are not associated

pgsql: libpq: Be strict about cancel key lengths

2025-08-22 Thread Heikki Linnakangas
libpq: Be strict about cancel key lengths The protocol documentation states that the maximum length of a cancel key is 256 bytes. This starts checking for that limit in libpq. Otherwise third party backend implementations will probably start using more bytes anyway. We also start requiring that a

pgsql: libpq: Handle OOM by disconnecting instead of hanging or skippin

2025-08-22 Thread Heikki Linnakangas
libpq: Handle OOM by disconnecting instead of hanging or skipping msgs In most cases, if an out-of-memory situation happens, we attach the error message to the connection and report it at the next PQgetResult() call. However, there are a few cases, while processing messages that are not associated

pgsql: libpq: Be strict about cancel key lengths

2025-08-22 Thread Heikki Linnakangas
libpq: Be strict about cancel key lengths The protocol documentation states that the maximum length of a cancel key is 256 bytes. This starts checking for that limit in libpq. Otherwise third party backend implementations will probably start using more bytes anyway. We also start requiring that a

pgsql: Use ereport() rather than elog()

2025-08-22 Thread Heikki Linnakangas
Use ereport() rather than elog() Noah pointed this out before I committed 50f770c3d9, but I accidentally pushed the old version with elog() anyway. Oops. Reported-by: Noah Misch Discussion: https://www.postgresql.org/message-id/20250820003756.31.nmi...@google.com Branch -- master Details

pgsql: Revert GetTransactionSnapshot() to return historic snapshot duri

2025-08-22 Thread Heikki Linnakangas
Revert GetTransactionSnapshot() to return historic snapshot during LR Commit 1585ff7387 changed GetTransactionSnapshot() to throw an error if it's called during logical decoding, instead of returning the historic snapshot. I made that change for extra protection, because a historic snapshot can on

pgsql: Revert GetTransactionSnapshot() to return historic snapshot duri

2025-08-22 Thread Heikki Linnakangas
Revert GetTransactionSnapshot() to return historic snapshot during LR Commit 1585ff7387 changed GetTransactionSnapshot() to throw an error if it's called during logical decoding, instead of returning the historic snapshot. I made that change for extra protection, because a historic snapshot can on

pgsql: Fix LSN format in debug message

2025-08-14 Thread Heikki Linnakangas
Fix LSN format in debug message Commit 2633dae2e48 standardized all existing messages to use `%X/%08X` for LSNs, but this one crept back in after the commit. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/4ec6e22b4358e8c8fbfa7cfd6d3314ae41663247 Modified Files ---

pgsql: libpq: Complain about missing BackendKeyData later with PGgetCan

2025-08-01 Thread Heikki Linnakangas
libpq: Complain about missing BackendKeyData later with PGgetCancel() PostgreSQL always sends the BackendKeyData message at connection startup, but there are some third party backend implementations out there that don't support cancellation, and don't send the message [1]. While the protocol docs

pgsql: libpq: Complain about missing BackendKeyData later with PGgetCan

2025-08-01 Thread Heikki Linnakangas
libpq: Complain about missing BackendKeyData later with PGgetCancel() PostgreSQL always sends the BackendKeyData message at connection startup, but there are some third party backend implementations out there that don't support cancellation, and don't send the message [1]. While the protocol docs

pgsql: Handle cancel requests with PID 0 gracefully

2025-07-29 Thread Heikki Linnakangas
Handle cancel requests with PID 0 gracefully If the client sent a query cancel request with backend PID 0, it tripped an assertion. With assertions disabled, you got this in the log instead: LOG: invalid cancel request with PID 0 LOG: wrong key in cancel request for process 0 Query can

pgsql: Handle cancel requests with PID 0 gracefully

2025-07-29 Thread Heikki Linnakangas
Handle cancel requests with PID 0 gracefully If the client sent a query cancel request with backend PID 0, it tripped an assertion. With assertions disabled, you got this in the log instead: LOG: invalid cancel request with PID 0 LOG: wrong key in cancel request for process 0 Query can

Re: pgsql: inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

2025-06-10 Thread Heikki Linnakangas
On 10 June 2025 13:31:50 GMT-07:00, Tom Lane wrote: >Jeff Davis writes: >> On Tue, 2025-06-10 at 18:24 +, Jeff Davis wrote: >>> inet_net_pton.c: use pg_ascii_tolower() rather than tolower(). > >> These 4 small patches were somewhat of a "false start" on 19 -- sorry >> about that. Not sure

pgsql: Fix cross-version upgrade test failure

2025-05-20 Thread Heikki Linnakangas
Fix cross-version upgrade test failure Commit 29f7ce6fe7 added another view that needs adjustment in the cross-version upgrade test. This should fix the XversionUpgrade failures in the buildfarm. Backpatch-through: 16 Discussion: https://www.postgresql.org/message-id/18929-077d6b7093b17...@postg

pgsql: Fix cross-version upgrade test failure

2025-05-20 Thread Heikki Linnakangas
Fix cross-version upgrade test failure Commit 29f7ce6fe7 added another view that needs adjustment in the cross-version upgrade test. This should fix the XversionUpgrade failures in the buildfarm. Backpatch-through: 16 Discussion: https://www.postgresql.org/message-id/18929-077d6b7093b17...@postg

pgsql: Fix cross-version upgrade test failure

2025-05-20 Thread Heikki Linnakangas
Fix cross-version upgrade test failure Commit 29f7ce6fe7 added another view that needs adjustment in the cross-version upgrade test. This should fix the XversionUpgrade failures in the buildfarm. Backpatch-through: 16 Discussion: https://www.postgresql.org/message-id/18929-077d6b7093b17...@postg

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of simple constants and expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the expressi

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of integer literals and simple expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the e

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of integer literals and simple expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the e

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of integer literals and simple expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the e

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of integer literals and simple expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the e

pgsql: Fix deparsing FETCH FIRST ROWS WITH TIES

2025-05-19 Thread Heikki Linnakangas
Fix deparsing FETCH FIRST ROWS WITH TIES In the grammar, is a c_expr, which accepts only a limited set of integer literals and simple expressions without parens. The deparsing logic didn't quite match the grammar rule, and failed to use parens e.g. for "5::bigint". To fix, always surround the e

pgsql: Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays

2025-05-08 Thread Heikki Linnakangas
Use 'void *' for arbitrary buffers, 'uint8 *' for byte arrays A 'void *' argument suggests that the caller might pass an arbitrary struct, which is appropriate for functions like libc's read/write, or pq_sendbytes(). 'uint8 *' is more appropriate for byte arrays that have no structure, like the ca

pgsql: Use more mundane 'int' type for cancel key lengths in libpq

2025-05-08 Thread Heikki Linnakangas
Use more mundane 'int' type for cancel key lengths in libpq The documented max length of a cancel key is 256 bytes, so it fits in uint8. It nevertheless seems weird to not just use 'int', like in commit 0f1433f053 for the backend. Discussion: https://www.postgresql.org/message-id/61be9e31-7b7d-4

Re: pgsql: Make cancel request keys longer

2025-04-09 Thread Heikki Linnakangas
On 08/04/2025 20:06, Peter Eisentraut wrote: On 02.04.25 15:43, Heikki Linnakangas wrote: Make cancel request keys longer This patch changed the signature of ProcSignal() -ProcSignalInit(bool cancel_key_valid, int32 cancel_key) +ProcSignalInit(char *cancel_key, int cancel_key_len) but did

pgsql: Fix a few oversights in the longer cancel keys patch

2025-04-09 Thread Heikki Linnakangas
Fix a few oversights in the longer cancel keys patch Change MyCancelKeyLength's type from uint8 to int. While it always fits in a uint8, plain int is less surprising, as there's no particular reason for it to be uint8. Fix one ProcSignalInit caller that passed 'false' instead of NULL for the poin

Re: pgsql: Make cancel request keys longer

2025-04-09 Thread Heikki Linnakangas
On 08/04/2025 22:41, Heikki Linnakangas wrote: On 08/04/2025 20:06, Peter Eisentraut wrote: While I was looking at this, I suggest to make the first argument void *.  This is consistent for passing binary data. Ok, sure. On second thoughts, -1 on that. 'void *' is appropriate for

pgsql: Fix rare assertion failure in standby, if primary is restarted

2025-04-05 Thread Heikki Linnakangas
Fix rare assertion failure in standby, if primary is restarted During hot standby, ExpireAllKnownAssignedTransactionIds() and ExpireOldKnownAssignedTransactionIds() functions mark old transactions as no-longer running, but they failed to update xactCompletionCount and latestCompletedXid. AFAICS it

pgsql: Fix rare assertion failure in standby, if primary is restarted

2025-04-05 Thread Heikki Linnakangas
Fix rare assertion failure in standby, if primary is restarted During hot standby, ExpireAllKnownAssignedTransactionIds() and ExpireOldKnownAssignedTransactionIds() functions mark old transactions as no-longer running, but they failed to update xactCompletionCount and latestCompletedXid. AFAICS it

pgsql: Fix rare assertion failure in standby, if primary is restarted

2025-04-05 Thread Heikki Linnakangas
Fix rare assertion failure in standby, if primary is restarted During hot standby, ExpireAllKnownAssignedTransactionIds() and ExpireOldKnownAssignedTransactionIds() functions mark old transactions as no-longer running, but they failed to update xactCompletionCount and latestCompletedXid. AFAICS it

pgsql: docs: Update phrase on message lengths in the protocol

2025-04-05 Thread Heikki Linnakangas
docs: Update phrase on message lengths in the protocol The reasoning for why all the message formats are parseable without the explicit message length field is anachronistic; the real reason is that protocol version 2 did not have a message length field. There's nothing wrong with relying on the m

pgsql: libpq: Add min/max_protocol_version connection options

2025-04-04 Thread Heikki Linnakangas
libpq: Add min/max_protocol_version connection options All supported version of the PostgreSQL server send the NegotiateProtocolVersion message when an unsupported minor protocol version is requested by a client. But many other applications that implement the PostgreSQL protocol (connection pooler

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: docs: Clarify that NULL arg to set_config() means reset to defau

2025-04-04 Thread Heikki Linnakangas
docs: Clarify that NULL arg to set_config() means reset to default Author: David G. Johnston Reviewed-by: Zhang Mingli Discussion: https://www.postgresql.org/message-id/cakfquwy0sk6jdcci1vjx6xsztrxggevey-grkenzx%2b3czpy...@mail.gmail.com Branch -- master Details --- https://git.postgr

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: Relax assertion in finding correct GiST parent

2025-04-04 Thread Heikki Linnakangas
Relax assertion in finding correct GiST parent Commit 28d3c2ddcf introduced an assertion that if the memorized downlink location in the insertion stack isn't valid, the parent's LSN should've changed too. Turns out that was too strict. In gistFindCorrectParent(), if we walk right, we update the pa

pgsql: Use standard die() signal handler in walreceiver

2025-04-04 Thread Heikki Linnakangas
Use standard die() signal handler in walreceiver This gets rid of the bespoken ProcessWalRcvInterrupts() function, which lets walreceiver terminate at any CHECK_FOR_INTERRUPTS() call. And it's less code anyway. We can now use the standard libpqsrv_connect_params() libpq wrapper from libpq-be-fe-h

pgsql: Add support for sorted gist index builds to btree_gist

2025-04-03 Thread Heikki Linnakangas
Add support for sorted gist index builds to btree_gist This enables sortsupport in the btree_gist extension for faster builds of gist indexes. Sorted gist index build strategy is the new default now. Regression tests are unchanged (except for one small change in the 'enum' test to add coverage fo

pgsql: Fix boilerplate comments in btree_gist

2025-04-03 Thread Heikki Linnakangas
Fix boilerplate comments in btree_gist A few of these were copy-pasted wrong, like the comment "Bytea ops" in btree_numeric.c. Instead of fixing the incorrect ones, replace them all with generic comment "GiST support functions". Also tidy up the inconsistent newlines between various functions whi

pgsql: Add GiST and btree sortsupport routines for range types

2025-04-02 Thread Heikki Linnakangas
Add GiST and btree sortsupport routines for range types For GiST, having a sortsupport function allows building the index using the "sorted build" method, which is much faster. For b-tree, the sortsupport routine doesn't give any new functionality, but speeds up sorting a tiny bit. The difference

pgsql: docs: Fix column count attribute in table

2025-04-02 Thread Heikki Linnakangas
docs: Fix column count attribute in table Nothing seems to actually depend on the attribute, as the docs built successfully, but let's be tidy. Reported offlist by Matthias van de Meent Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/ea3f9b6da34a1a4dc2c0c118789587c

pgsql: Make cancel request keys longer

2025-04-02 Thread Heikki Linnakangas
Make cancel request keys longer Currently, the cancel request key is a 32-bit token, which isn't very much entropy. If you want to cancel another session's query, you can brute-force it. In most environments, an unauthorized cancellation of a query isn't very serious, but it nevertheless would be

pgsql: libpq: Handle NegotiateProtocolVersion message differently

2025-04-02 Thread Heikki Linnakangas
libpq: Handle NegotiateProtocolVersion message differently Previously libpq would always error out if the server sends a NegotiateProtocolVersion message. This was fine because libpq only supported a single protocol version and did not support any protocol parameters. But in the upcoming commits,

pgsql: docs: Add a new section and a table listing protocol versions

2025-04-02 Thread Heikki Linnakangas
docs: Add a new section and a table listing protocol versions Move the discussion on protocol versions and version negotiation to a new "Protocol versions" section. Add a table listing all the different protocol versions, starting from the obsolete protocol version 2, and the PostgreSQL versions t

pgsql: Add timingsafe_bcmp(), for constant-time memory comparison

2025-04-02 Thread Heikki Linnakangas
Add timingsafe_bcmp(), for constant-time memory comparison timingsafe_bcmp() should be used instead of memcmp() or a naive for-loop, when comparing passwords or secret tokens, to avoid leaking information about the secret token by timing. This commit just introduces the function but does not chang

pgsql: heapam: Only set tuple's block once per page in pagemode

2025-04-01 Thread Heikki Linnakangas
heapam: Only set tuple's block once per page in pagemode Due to splitting the block id into two 16 bit integers, BlockIdSet() is more expensive than one might think. Doing it once per returned tuple shows up as a small but reliably reproducible cost. It's simple enough to set the block number ju

pgsql: Fix crash if LockErrorCleanup() is called twice

2025-03-28 Thread Heikki Linnakangas
Fix crash if LockErrorCleanup() is called twice The refactoring in commit 3c0fd64fec removed the clearing of awaitedLock from LockErrorCleanup(). It's still needed, otherwise LockErrorCleanup() during abort processing will try to update the LOCALLOCK struct even after the lock has already been rel

pgsql: Add test case for when subscriber table is missing a column

2025-03-24 Thread Heikki Linnakangas
Add test case for when subscriber table is missing a column We haven't had bugs in this area, but there's some not-entirely trivial code to detect that case, so it seems good to have test coverage for it. Author: Peter Smith Reviewed-by: vignesh C Reviewed-by: Tomas Vondra Discussion: https:/

pgsql: Fix rare assertion failure in standby, if primary is restarted

2025-03-23 Thread Heikki Linnakangas
Fix rare assertion failure in standby, if primary is restarted During hot standby, ExpireAllKnownAssignedTransactionIds() and ExpireOldKnownAssignedTransactionIds() functions mark old transactions as no-longer running, but they failed to update xactCompletionCount and latestCompletedXid. AFAICS it

pgsql: Fix rare assertion failure in standby, if primary is restarted

2025-03-23 Thread Heikki Linnakangas
Fix rare assertion failure in standby, if primary is restarted During hot standby, ExpireAllKnownAssignedTransactionIds() and ExpireOldKnownAssignedTransactionIds() functions mark old transactions as no-longer running, but they failed to update xactCompletionCount and latestCompletedXid. AFAICS it

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-15 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix snapshot used in logical replication index lookup

2025-03-15 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-15 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Handle interrupts while waiting on Append's async subplans

2025-03-12 Thread Heikki Linnakangas
Handle interrupts while waiting on Append's async subplans We did not wake up on interrupts while waiting on async events on an async-capable append node. For example, if you tried to cancel the query, nothing would happen until one of the async subplans becomes readable. To fix, add WL_LATCH_SET

pgsql: Rename alloc/free functions in reorderbuffer.c

2025-03-12 Thread Heikki Linnakangas
Rename alloc/free functions in reorderbuffer.c There used to be bespoken pools for these structs to reduce the palloc/pfree overhead, but that was ripped out a long time ago and replaced with the generic, cheaper generational memory allocator (commit a4ccc1cef5). The Get/Return terminology made se

pgsql: Handle interrupts while waiting on Append's async subplans

2025-03-12 Thread Heikki Linnakangas
Handle interrupts while waiting on Append's async subplans We did not wake up on interrupts while waiting on async events on an async-capable append node. For example, if you tried to cancel the query, nothing would happen until one of the async subplans becomes readable. To fix, add WL_LATCH_SET

pgsql: Handle interrupts while waiting on Append's async subplans

2025-03-12 Thread Heikki Linnakangas
Handle interrupts while waiting on Append's async subplans We did not wake up on interrupts while waiting on async events on an async-capable append node. For example, if you tried to cancel the query, nothing would happen until one of the async subplans becomes readable. To fix, add WL_LATCH_SET

pgsql: Handle interrupts while waiting on Append's async subplans

2025-03-12 Thread Heikki Linnakangas
Handle interrupts while waiting on Append's async subplans We did not wake up on interrupts while waiting on async events on an async-capable append node. For example, if you tried to cancel the query, nothing would happen until one of the async subplans becomes readable. To fix, add WL_LATCH_SET

pgsql: Handle interrupts while waiting on Append's async subplans

2025-03-12 Thread Heikki Linnakangas
Handle interrupts while waiting on Append's async subplans We did not wake up on interrupts while waiting on async events on an async-capable append node. For example, if you tried to cancel the query, nothing would happen until one of the async subplans becomes readable. To fix, add WL_LATCH_SET

pgsql: Fix snapshot used in logical replication index lookup

2025-03-12 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Improve snapmgr.c comment

2025-03-11 Thread Heikki Linnakangas
Improve snapmgr.c comment Add more details on the different kinds of snapshots, how to use them, and how the active snapshot stack works. Discussion: https://www.postgresql.org/message-id/7c56f180-b9e1-481e-8c1d-efa63de3e...@iki.fi Branch -- master Details --- https://git.postgresql.or

pgsql: Assert that a snapshot is active or registered before it's used

2025-03-11 Thread Heikki Linnakangas
Assert that a snapshot is active or registered before it's used The comment in GetTransactionSnapshot() said that you "should call RegisterSnapshot or PushActiveSnapshot on the returned snap if it is to be used very long". That felt too unclear to me. Make the comment more strongly worded. To enf

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix snapshot used in logical replication index lookup

2025-03-11 Thread Heikki Linnakangas
Fix snapshot used in logical replication index lookup The function calls GetLatestSnapshot() to acquire a fresh snapshot, makes it active, and was meant to pass it to table_tuple_lock(), but instead called GetLatestSnapshot() again to acquire yet another snapshot. It was harmless because the heap

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-11 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix a few more redundant calls of GetLatestSnapshot()

2025-03-10 Thread Heikki Linnakangas
Fix a few more redundant calls of GetLatestSnapshot() Commit 2367503177 fixed this in RelationFindReplTupleByIndex(), but I missed two other similar cases. Per report from Ranier Vilela. Discussion: https://www.postgresql.org/message-id/caeudqarut1de45wn87f-gb7xmy_hw6x1dfd3sqdhhxp-rmd...@mail.g

pgsql: Fix test name and username used in failed connection attempts

2025-03-09 Thread Heikki Linnakangas
Fix test name and username used in failed connection attempts The first failed connection tests the "regular" connections limit, not the reserved limit. In the second failed connection, the username doesn't really matter, but since the previous successful connections used "regress_reserved", it s

pgsql: Fix incorrect assertion in libpqwalreceiver

2025-03-09 Thread Heikki Linnakangas
Fix incorrect assertion in libpqwalreceiver Was supposed to check the length of the array, but was checking its size in bytes. Author: Jacob Brazeal Discussion: https://www.postgresql.org/message-id/ca%2bcozaa_9afjxj9zuo73u5p7wxp%2bzm9ngnzvtdcmbfz0fgp%2...@mail.gmail.com Branch -- master

pgsql: Fix compiler warnings about typedef redefinitions

2025-03-05 Thread Heikki Linnakangas
Fix compiler warnings about typedef redefinitions Clang with -Wtypedef-redefinition produced warnings: src/include/storage/latch.h:122:3: error: redefinition of typedef 'Latch' is a C11 feature [-Werror,-Wtypedef-redefinition] Per buildfarm Branch -- master Details --- https://git

pgsql: Use ModifyWaitEvent to update exit_on_postmaster_death

2025-03-05 Thread Heikki Linnakangas
Use ModifyWaitEvent to update exit_on_postmaster_death This is in preparation for splitting WaitEventSet related functions to a separate source file. That will hide the details of WaitEventSet from WaitLatch, so it must use an exposed function instead of modifying WaitEventSet->exit_on_postmaster_

pgsql: Split WaitEventSet functions to separate source file

2025-03-05 Thread Heikki Linnakangas
Split WaitEventSet functions to separate source file latch.c now only contains the Latch related functions, which build on the WaitEventSet abstraction. Most of the platform-dependent stuff is now in waiteventset.c. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/8a

pgsql: Remove unused ShutdownLatchSupport() function

2025-03-05 Thread Heikki Linnakangas
Remove unused ShutdownLatchSupport() function The only caller was removed in commit 80a8f95b3b. I don't foresee needing it any time soon, and I'm working on some big changes in this area, so let's remove it out of the way. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/messag

pgsql: Rename some signal and interrupt handling functions for consiste

2025-03-05 Thread Heikki Linnakangas
Rename some signal and interrupt handling functions for consistency The usual pattern for handling a signal is that the signal handler sets a flag and calls SetLatch(MyLatch), and CHECK_FOR_INTERRUPTS() or other code that is part of a wait loop calls another function to deal with it. The naming of

pgsql: Fix outdated comment

2025-03-04 Thread Heikki Linnakangas
Fix outdated comment Commit bc971f4025 replaced the latch-setting mechanism that the comment talked about with a condition variable. And before that, commit 2258e76f90 moved the code so that the comment got detached from the loop that it talked about, so move the comment closer to the loop. Branc

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Fix catcache invalidation of a list entry that's being built

2025-01-14 Thread Heikki Linnakangas
Fix catcache invalidation of a list entry that's being built If a new catalog tuple is inserted that belongs to a catcache list entry, and cache invalidation happens while the list entry is being built, the list entry might miss the newly inserted tuple. To fix, change the way we detect concurren

pgsql: Remove duplicate definitions in proc.h

2025-01-06 Thread Heikki Linnakangas
Remove duplicate definitions in proc.h These are also present in procnumber.h Reported-by: Peter Eisentraut Discussion: https://www.postgresql.org/message-id/bd04d675-4672-4f87-800a-eb5d470c1...@eisentraut.org Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/5e68f6

pgsql: Remove duplicate definitions in proc.h

2025-01-06 Thread Heikki Linnakangas
Remove duplicate definitions in proc.h These are also present in procnumber.h Reported-by: Peter Eisentraut Discussion: https://www.postgresql.org/message-id/bd04d675-4672-4f87-800a-eb5d470c1...@eisentraut.org Branch -- REL_17_STABLE Details --- https://git.postgresql.org/pg/commitdiff

Re: pgsql: Replace BackendIds with 0-based ProcNumbers

2025-01-01 Thread Heikki Linnakangas
On 29/12/2024 19:43, Peter Eisentraut wrote: On 03.03.24 18:39, Heikki Linnakangas wrote: Replace BackendIds with 0-based ProcNumbers There are a couple of declarations that are duplicated between src/ include/storage/proc.h and src/include/storage/procnumber.h, such as MyProcNumber

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libpgport that need special CFLAGS to compile. Currently, that includes the CRC-32 functions. Commit 2571c1d5cc did this for libcommon, but I missed that

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libpgport that need special CFLAGS to compile. Currently, that includes the CRC-32 functions. Commit 2571c1d5cc did this for libcommon, but I missed that

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libpgport that need special CFLAGS to compile. Currently, that includes the CRC-32 functions. Commit 2571c1d5cc did this for libcommon, but I missed that

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libcommon. This was reported with pgvector. Reported-by: Andrew Kane Author: Vladlen Popolitov Backpatch-through: 16, where Meson was introduced Discussio

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libcommon. This was reported with pgvector. Reported-by: Andrew Kane Author: Vladlen Popolitov Backpatch-through: 16, where Meson was introduced Discussio

pgsql: meson: Export all libcommon functions in Windows builds

2024-12-25 Thread Heikki Linnakangas
meson: Export all libcommon functions in Windows builds This fixes "unresolved external symbol" errors with extensions that use functions from libcommon. This was reported with pgvector. Reported-by: Andrew Kane Author: Vladlen Popolitov Backpatch-through: 16, where Meson was introduced Discussio

pgsql: Remove unnecessary GetTransactionSnapshot() calls

2024-12-23 Thread Heikki Linnakangas
Remove unnecessary GetTransactionSnapshot() calls In get_database_list() and get_subscription_list(), the GetTransactionSnapshot() call is not required because the catalog table scans use the catalog snapshot, which is held until the end of the scan. See table_beginscan_catalog(), which calls Regi

pgsql: Don't allow GetTransactionSnapshot() in logical decoding

2024-12-23 Thread Heikki Linnakangas
Don't allow GetTransactionSnapshot() in logical decoding A historic snapshot should only be used for catalog access, not general queries. We never call GetTransactionSnapshot() during logical decoding, which is good because it wouldn't be very sensible, so the code to deal with that was unreachabl

  1   2   3   4   5   6   7   8   9   10   >