pgsql: Refactor lock manager initialization to make it a bit less speci

2024-08-29 Thread Heikki Linnakangas
Refactor lock manager initialization to make it a bit less special Split the shared and local initialization to separate functions, and follow the common naming conventions. With this, we no longer create the LockMethodLocalHash hash table in the postmaster process, which was always pointless. Re

pgsql: Rename some shared memory initialization routines

2024-08-29 Thread Heikki Linnakangas
Rename some shared memory initialization routines To make them follow the usual naming convention where FoobarShmemSize() calculates the amount of shared memory needed by Foobar subsystem, and FoobarShmemInit() performs the initialization. I didn't rename CreateLWLocks() and InitShmmeIndex(), bec

pgsql: Fix garbled process name on backend crash

2024-08-18 Thread Heikki Linnakangas
Fix garbled process name on backend crash The log message on backend crash used wrong variable, which could be uninitialized. Introduced in commit 28a520c0b7. Reported-by: Alexander Lakhin Discussion: https://www.postgresql.org/message-id/451b0797-83b8-cdbc-727f-8d7a7b0e3...@gmail.com Branch --

pgsql: Relax fsyncing at end of a bulk load that was not WAL-logged

2024-08-16 Thread Heikki Linnakangas
Relax fsyncing at end of a bulk load that was not WAL-logged And improve the comments. Backpatch to v17 where this was introduced. Reviewed-by: Noah Misch Discussion: https://www.postgresql.org/message-id/cac7d1b6-8358-40be-af0b-21bc9b27d...@iki.fi Branch -- master Details --- https:/

pgsql: Relax fsyncing at end of a bulk load that was not WAL-logged

2024-08-16 Thread Heikki Linnakangas
Relax fsyncing at end of a bulk load that was not WAL-logged And improve the comments. Backpatch to v17 where this was introduced. Reviewed-by: Noah Misch Discussion: https://www.postgresql.org/message-id/cac7d1b6-8358-40be-af0b-21bc9b27d...@iki.fi Branch -- REL_17_STABLE Details ---

pgsql: Refactor CopyOneRowTo

2024-08-16 Thread Heikki Linnakangas
Refactor CopyOneRowTo The handling of binary and text formats are quite different here, so it's more clear to check for the format first and have two separate loops. Author: jian he Reviewed-by: Ilia Evdokimov, Junwang Zhao Discussion: https://www.postgresql.org/message-id/cacjufxfzhcefbqf0m%2b

pgsql: Remove unused 'cur_skey' argument from IndexScanOK()

2024-08-16 Thread Heikki Linnakangas
Remove unused 'cur_skey' argument from IndexScanOK() Commit a78fcfb51243 removed the last use of it. Author: Hugo Zhang, Aleksander Alekseev Reviewed-by: Daniel Gustafsson Discussion: https://www.postgresql.org/message-id/NT0PR01MB129459E243721B954611938F9CDD2%40NT0PR01MB1294.CHNPR01.prod.partne

pgsql: Fix bad indentation introduced in commit f011e82c2c

2024-08-12 Thread Heikki Linnakangas
Fix bad indentation introduced in commit f011e82c2c Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/8de5ca1dc9fa809102acd1983ee19159d0bc469f Modified Files -- src/backend/access/transam/xlogprefetcher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-

pgsql: Consolidate postmaster code to launch background processes

2024-08-12 Thread Heikki Linnakangas
Consolidate postmaster code to launch background processes Much of the code in process_pm_child_exit() to launch replacement processes when one exits or when progressing to next postmaster state was unnecessary, because the ServerLoop will launch any missing background processes anyway. Remove the

pgsql: Initialize HASHCTL differently, to suppress Coverity warning

2024-08-11 Thread Heikki Linnakangas
Initialize HASHCTL differently, to suppress Coverity warning Coverity complained that the hash_create() call might access hash_table_ctl->hctl. That's a false alarm, hash_create() only accesses that field when passed the HASH_SHARED_MEM flag. Try to silence it by using a plain local variable inste

pgsql: Fix comment on processes being kept over a restart

2024-08-09 Thread Heikki Linnakangas
Fix comment on processes being kept over a restart All child processes except the syslogger are killed on a restart. The archiver might be already running though, if it was started during recovery. The split in the comments between "other special children" and the first group of "background tasks

pgsql: Refactor code to handle death of a backend or bgworker in postma

2024-08-09 Thread Heikki Linnakangas
Refactor code to handle death of a backend or bgworker in postmaster Currently, when a child process exits, the postmaster first scans through BackgroundWorkerList, to see if it the child process was a background worker. If not found, then it scans through BackendList to see if it was a regular ba

pgsql: Make BackgroundWorkerList doubly-linked

2024-08-09 Thread Heikki Linnakangas
Make BackgroundWorkerList doubly-linked This allows ForgetBackgroundWorker() and ReportBackgroundWorkerExit() to take a RegisteredBgWorker pointer as argument, rather than a list iterator. That feels a little more natural. But more importantly, this paves the way for more refactoring in the next c

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Fix pg_rewind debug output to print the source timeline history

2024-08-08 Thread Heikki Linnakangas
Fix pg_rewind debug output to print the source timeline history getTimelineHistory() is called twice, to read the source and the target timeline history files. However, the loop to print the file with the --debug option used the wrong variable when dealing with the source. As a result, the source'

pgsql: Make fallback MD5 implementation thread-safe on big-endian syste

2024-08-07 Thread Heikki Linnakangas
Make fallback MD5 implementation thread-safe on big-endian systems Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which

pgsql: Make fallback MD5 implementation thread-safe on big-endian syste

2024-08-07 Thread Heikki Linnakangas
Make fallback MD5 implementation thread-safe on big-endian systems Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which

pgsql: Make fallback MD5 implementation thread-safe on big-endian syste

2024-08-07 Thread Heikki Linnakangas
Make fallback MD5 implementation thread-safe on big-endian systems Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which

pgsql: Make fallback MD5 implementation thread-safe on big-endian syste

2024-08-07 Thread Heikki Linnakangas
Make fallback MD5 implementation thread-safe on big-endian systems Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which

pgsql: Make fallback MD5 implementation thread-safe on big-endian syste

2024-08-07 Thread Heikki Linnakangas
Make fallback MD5 implementation thread-safe on big-endian systems Replace a static scratch buffer with a local variable, because a static buffer makes the function not thread-safe. This function is used in client-code in libpq, so it needs to be thread-safe. It was until commit b67b57a966, which

pgsql: Mark misc static global variables as const

2024-08-06 Thread Heikki Linnakangas
Mark misc static global variables as const Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd...@iki.fi Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/fe8dd65bf28db1a6ad690ffcd5124d1863b5a4c6 Modified Fi

pgsql: Make nullSemAction const, add 'const' decorators to related func

2024-08-06 Thread Heikki Linnakangas
Make nullSemAction const, add 'const' decorators to related functions To make it more clear that these should never be modified. Reviewed-by: Andres Freund Discussion: https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd...@iki.fi Branch -- master Details --- https:/

pgsql: Turn a few 'validnsps' static variables into locals

2024-08-06 Thread Heikki Linnakangas
Turn a few 'validnsps' static variables into locals There was no need for these to be static buffers, local variables work just as well. I think they were marked as 'static' to imply that they are read-only, but 'const' is more appropriate for that, so change them to const. To make it possible to

pgsql: Constify fields and parameters in spell.c

2024-08-06 Thread Heikki Linnakangas
Constify fields and parameters in spell.c I started by marking VoidString as const, and fixing the fallout by marking more fields and function arguments as const. It proliferated quite a lot, but all within spell.c and spell.h. A more narrow patch to get rid of the static VoidString buffer would

pgsql: Use psprintf to simplify gtsvectorout()

2024-08-06 Thread Heikki Linnakangas
Use psprintf to simplify gtsvectorout() The buffer allocation was correct, but looked archaic and scary: - It was weird to calculate the buffer size before determining which format string was used. With the same effort, we could've used the right-sized buffer for each branch. - Commit aa0d35

pgsql: Fix datatypes in comments in instr_time.h

2024-08-06 Thread Heikki Linnakangas
Fix datatypes in comments in instr_time.h The INSTR_TIME_GET_NANOSEC(t) and INSTR_TIME_GET_MICROSEC(t) macros return a signed int64. Discussion: https://www.postgresql.org/message-id/zrhkv3maqfwns...@ip-10-97-1-34.eu-west-3.compute.internal Branch -- master Details --- https://git.post

pgsql: Revert "Fix comments in instr_time.h and remove an unneeded cast

2024-08-06 Thread Heikki Linnakangas
Revert "Fix comments in instr_time.h and remove an unneeded cast to int64" This reverts commit 3dcb09de7b. Tom Lane pointed out that it broke the abstraction provided by the macros. The callers should not need to know what the internal type is. This commit is an exact revert, the next commit will

pgsql: Fix comments in instr_time.h and remove an unneeded cast to int6

2024-08-06 Thread Heikki Linnakangas
Fix comments in instr_time.h and remove an unneeded cast to int64 03023a2664 represented time as an int64 on all platforms but forgot to update the comment related to INSTR_TIME_GET_MICROSEC() and provided an incorrect comment for INSTR_TIME_GET_NANOSEC(). In passing remove an unneeded cast to in

pgsql: Minor refactoring of assign_backendlist_entry()

2024-08-01 Thread Heikki Linnakangas
Minor refactoring of assign_backendlist_entry() Make assign_backendlist_entry() responsible just for allocating the Backend struct. Linking it to the RegisteredBgWorker is the caller's responsibility now. Seems more clear that way. Discussion: https://www.postgresql.org/message-id/835232c0-a5f7-

pgsql: Fix outdated comment; all running bgworkers are in BackendList

2024-08-01 Thread Heikki Linnakangas
Fix outdated comment; all running bgworkers are in BackendList Before commit 8a02b3d732, only bgworkers that connected to a database had an entry in the Backendlist. Commit 8a02b3d732 changed that, but forgot to update this comment. Discussion: https://www.postgresql.org/message-id/835232c0-a5f7

pgsql: Refactor getWeights to write to caller-supplied buffer

2024-07-30 Thread Heikki Linnakangas
Refactor getWeights to write to caller-supplied buffer This gets rid of the static result buffer. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0...@iki.fi Branch -- master Details --- https://git.postgresql.org/pg/commitdiff

pgsql: Replace static buf with palloc in str_time()

2024-07-30 Thread Heikki Linnakangas
Replace static buf with palloc in str_time() The function is used only once in the startup process, so the leak into current memory context is harmless. This is a tiny step in making the server thread-safe. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5

pgsql: Replace static buf with a stack-allocated one in ReadControlFile

2024-07-30 Thread Heikki Linnakangas
Replace static buf with a stack-allocated one in ReadControlFile It's only used very locally within the function. Reviewed-by: Robert Haas Discussion: https://www.postgresql.org/message-id/7f86e06a-98c5-4ce3-8ec9-3885c8de0...@iki.fi Branch -- master Details --- https://git.postgresql.o

pgsql: Replace static bufs with a StringInfo in cash_words()

2024-07-30 Thread Heikki Linnakangas
Replace static bufs with a StringInfo in cash_words() For clarity. The code was correct, and the buffer was large enough, but string manipulation with no bounds checking is scary. This incurs an extra palloc+pfree to every call, but in quick performance testing, it doesn't seem to be significant.

pgsql: Replace static buf with a stack-allocated one in 'seg' extension

2024-07-30 Thread Heikki Linnakangas
Replace static buf with a stack-allocated one in 'seg' extension The buffer is used only locally within the function. Also, the initialization to '0' characters was unnecessary, the initial content were always overwritten with sprintf(). I don't understand why it was done that way, but it's been l

pgsql: Remove leftover function declaration

2024-07-30 Thread Heikki Linnakangas
Remove leftover function declaration Commit 9d9b9d46f3 removed the function (or rather, moved it to a different source file and renamed it to SendCancelRequest), but forgot the declaration in the header file. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/47c98035c

Re: pgsql: Remove --disable-spinlocks.

2024-07-30 Thread Heikki Linnakangas
#ifndef guard around it. -- Heikki Linnakangas Neon (https://neon.tech)

pgsql: Detach syslogger from shared memory

2024-07-29 Thread Heikki Linnakangas
Detach syslogger from shared memory Commit aafc05de1b removed the calls to detach from shared memory from syslogger startup. That was not intentional, so put them back. Author: Rui Zhao Reviewed-by: Aleksander Alekseev Backpatch-through: 17 Discussion: https://www.postgresql.org/message-id/11505

pgsql: Detach syslogger from shared memory

2024-07-29 Thread Heikki Linnakangas
Detach syslogger from shared memory Commit aafc05de1b removed the calls to detach from shared memory from syslogger startup. That was not intentional, so put them back. Author: Rui Zhao Reviewed-by: Aleksander Alekseev Backpatch-through: 17 Discussion: https://www.postgresql.org/message-id/11505

pgsql: Remove dead generators for cyrillic encoding conversion tables

2024-07-29 Thread Heikki Linnakangas
Remove dead generators for cyrillic encoding conversion tables These tools were used to read the koi-iso.tab, koi-win.tab, and koi-alt.tab files, which contained the mappings between the single-byte cyrillic encodings. However, those data files were removed in commit 4c3c8c048d, back in 2003. Thes

Re: pgsql: Move cancel key generation to after forking the backend

2024-07-29 Thread Heikki Linnakangas
On 29/07/2024 17:30, Heikki Linnakangas wrote: On 29/07/2024 16:25, Heikki Linnakangas wrote: On 29/07/2024 16:23, Daniel Gustafsson wrote: On 29 Jul 2024, at 15:18, Heikki Linnakangas wrote: Move cancel key generation to after forking the backend longfin seems a tad sad about this one

pgsql: Fix double-release of spinlock

2024-07-29 Thread Heikki Linnakangas
Fix double-release of spinlock Commit 9d9b9d46f3 added spinlocks to protect the fields in ProcSignal flags, but in EmitProcSignalBarrier(), the spinlock was released twice. With most spinlock implementations, releasing a lock that's not held is not easy to notice, because most of the time it does

Re: pgsql: Move cancel key generation to after forking the backend

2024-07-29 Thread Heikki Linnakangas
On 29/07/2024 16:25, Heikki Linnakangas wrote: On 29/07/2024 16:23, Daniel Gustafsson wrote: On 29 Jul 2024, at 15:18, Heikki Linnakangas wrote: Move cancel key generation to after forking the backend longfin seems a tad sad about this one: procsignal.c:87:3: error: redefinition of typedef

Re: pgsql: Move cancel key generation to after forking the backend

2024-07-29 Thread Heikki Linnakangas
On 29/07/2024 16:23, Daniel Gustafsson wrote: On 29 Jul 2024, at 15:18, Heikki Linnakangas wrote: Move cancel key generation to after forking the backend longfin seems a tad sad about this one: procsignal.c:87:3: error: redefinition of typedef 'ProcSignalHeader' is a C11 featur

pgsql: Fix compiler warning/error about typedef redefinitions

2024-07-29 Thread Heikki Linnakangas
Fix compiler warning/error about typedef redefinitions Per buildfarm member 'sifaka': procsignal.c:87:3: error: redefinition of typedef 'ProcSignalHeader' is a C11 feature [-Werror,-Wtypedef-redefinition] Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/8bda213

pgsql: Move cancel key generation to after forking the backend

2024-07-29 Thread Heikki Linnakangas
Move cancel key generation to after forking the backend Move responsibility of generating the cancel key to the backend process. The cancel key is now generated after forking, and the backend advertises it in the ProcSignal array. When a cancel request arrives, the backend handling it scans the Pr

pgsql: Fix outdated comment in smgrtruncate()

2024-07-29 Thread Heikki Linnakangas
Fix outdated comment in smgrtruncate() Commit c5315f4f44 replaced smgr_fsm_nblocks and smgr_vm_nblocks with smgr_cached_nblocks, but forgot to update this comment. Author: Kirill Reshke Discussion: https://www.postgresql.org/message-id/caldssph9va6sdsvjrcmspeyramf%2brfisk7gqjo1dtrnd3vd...@mail.g

pgsql: Fallback to uuid for ossp-uuid with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to uuid for ossp-uuid with meson The upstream name for the ossp-uuid package / pkg-config file is "uuid". Many distributions change this to be "ossp-uuid" to not conflict with e2fsprogs. This lookup fails on distributions which don't change this name, for example NixOS / nixpkgs. Both "o

pgsql: Support absolute bindir/libdir in regression tests with meson

2024-07-27 Thread Heikki Linnakangas
Support absolute bindir/libdir in regression tests with meson Passing an absolute bindir/libdir will install the binaries and libraries to /tmp_install/ and /tmp_install/ respectively. This path is correctly passed to the regression test suite via configure/make, but not via meson, yet. This is b

pgsql: Fallback to clang in PATH with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to clang in PATH with meson Some distributions put clang into a different path than the llvm binary path. For example, this is the case on NixOS / nixpkgs, which failed to find clang with meson before this patch. Author: Wolfgang Walther Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, P

pgsql: Fallback to uuid for ossp-uuid with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to uuid for ossp-uuid with meson The upstream name for the ossp-uuid package / pkg-config file is "uuid". Many distributions change this to be "ossp-uuid" to not conflict with e2fsprogs. This lookup fails on distributions which don't change this name, for example NixOS / nixpkgs. Both "o

pgsql: Fallback to clang in PATH with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to clang in PATH with meson Some distributions put clang into a different path than the llvm binary path. For example, this is the case on NixOS / nixpkgs, which failed to find clang with meson before this patch. Author: Wolfgang Walther Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, P

pgsql: Support falling back to non-preferred readline implementation wi

2024-07-27 Thread Heikki Linnakangas
Support falling back to non-preferred readline implementation with meson To build with -Dreadline=enabled one can use either readline or libedit. The -Dlibedit_preferred flag is supposed to control the order of names to lookup. This works fine when either both libraries are present or -Dreadline

pgsql: Support falling back to non-preferred readline implementation wi

2024-07-27 Thread Heikki Linnakangas
Support falling back to non-preferred readline implementation with meson To build with -Dreadline=enabled one can use either readline or libedit. The -Dlibedit_preferred flag is supposed to control the order of names to lookup. This works fine when either both libraries are present or -Dreadline

pgsql: Support absolute bindir/libdir in regression tests with meson

2024-07-27 Thread Heikki Linnakangas
Support absolute bindir/libdir in regression tests with meson Passing an absolute bindir/libdir will install the binaries and libraries to /tmp_install/ and /tmp_install/ respectively. This path is correctly passed to the regression test suite via configure/make, but not via meson, yet. This is b

pgsql: Support absolute bindir/libdir in regression tests with meson

2024-07-27 Thread Heikki Linnakangas
Support absolute bindir/libdir in regression tests with meson Passing an absolute bindir/libdir will install the binaries and libraries to /tmp_install/ and /tmp_install/ respectively. This path is correctly passed to the regression test suite via configure/make, but not via meson, yet. This is b

pgsql: Fallback to uuid for ossp-uuid with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to uuid for ossp-uuid with meson The upstream name for the ossp-uuid package / pkg-config file is "uuid". Many distributions change this to be "ossp-uuid" to not conflict with e2fsprogs. This lookup fails on distributions which don't change this name, for example NixOS / nixpkgs. Both "o

pgsql: Support falling back to non-preferred readline implementation wi

2024-07-27 Thread Heikki Linnakangas
Support falling back to non-preferred readline implementation with meson To build with -Dreadline=enabled one can use either readline or libedit. The -Dlibedit_preferred flag is supposed to control the order of names to lookup. This works fine when either both libraries are present or -Dreadline

pgsql: Fallback to clang in PATH with meson

2024-07-27 Thread Heikki Linnakangas
Fallback to clang in PATH with meson Some distributions put clang into a different path than the llvm binary path. For example, this is the case on NixOS / nixpkgs, which failed to find clang with meson before this patch. Author: Wolfgang Walther Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, P

pgsql: Add test for early backend startup errors

2024-07-26 Thread Heikki Linnakangas
Add test for early backend startup errors The new test tests the libpq fallback behavior on an early error, which was fixed in the previous commit. This adds an IS_INJECTION_POINT_ATTACHED() macro, to allow writing injected test code alongside the normal source code. In principle, the new test co

pgsql: Add tests for errors during SSL or GSSAPI handshake

2024-07-26 Thread Heikki Linnakangas
Add tests for errors during SSL or GSSAPI handshake These test that libpq correctly falls back to a plaintext connection on handshake error, in the "prefer" modes. Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/CAOYmi%2Bnwvu21mJ4DYKUa98HdfM_KZJi7B1MhyXtnsyOO-PB6Ww

pgsql: Fix fallback behavior when server sends an ERROR early at startu

2024-07-26 Thread Heikki Linnakangas
Fix fallback behavior when server sends an ERROR early at startup With sslmode=prefer, the desired behavior is to completely fail the connection attempt, *not* fall back to a plaintext connection, if the server responds to the SSLRequest with an error ('E') response instead of rejecting SSL with a

pgsql: Fix fallback behavior when server sends an ERROR early at startu

2024-07-26 Thread Heikki Linnakangas
Fix fallback behavior when server sends an ERROR early at startup With sslmode=prefer, the desired behavior is to completely fail the connection attempt, *not* fall back to a plaintext connection, if the server responds to the SSLRequest with an error ('E') response instead of rejecting SSL with a

pgsql: Fix using injection points at backend startup in EXEC_BACKEND mo

2024-07-26 Thread Heikki Linnakangas
Fix using injection points at backend startup in EXEC_BACKEND mode Commit 86db52a506 changed the locking of injection points to use only atomic ops and spinlocks, to make it possible to define injection points in processes that don't have a PGPROC entry (yet). However, it didn't work in EXEC_BACKE

pgsql: Fix using injection points at backend startup in EXEC_BACKEND mo

2024-07-26 Thread Heikki Linnakangas
Fix using injection points at backend startup in EXEC_BACKEND mode Commit 86db52a506 changed the locking of injection points to use only atomic ops and spinlocks, to make it possible to define injection points in processes that don't have a PGPROC entry (yet). However, it didn't work in EXEC_BACKE

pgsql: Move resowner from common JitContext to LLVM specific

2024-07-19 Thread Heikki Linnakangas
Move resowner from common JitContext to LLVM specific Only the LLVM specific code uses it since resource owners were made extensible in commit b8bff07daa85c837a2747b4d35cd5a27e73fb7b2. This is new in v17, so backpatch there to keep the branches from diverging just yet. Author: Andreas Karlsson D

pgsql: Move resowner from common JitContext to LLVM specific

2024-07-19 Thread Heikki Linnakangas
Move resowner from common JitContext to LLVM specific Only the LLVM specific code uses it since resource owners were made extensible in commit b8bff07daa85c837a2747b4d35cd5a27e73fb7b2. This is new in v17, so backpatch there to keep the branches from diverging just yet. Author: Andreas Karlsson D

Re: pgsql: Replace BackendIds with 0-based ProcNumbers

2024-07-15 Thread Heikki Linnakangas
= InvalidBackendId; +static pid_t pq_mq_parallel_leader_proc_number = INVALID_PROC_NUMBER; I guess it was a historical mistake that this variable of type pid_t instead of BackendId, but now it should be ProcNumber? Yep, fixed thanks! -- Heikki Linnakangas Neon (https://neon.tech)

pgsql: Use correct type for pq_mq_parallel_leader_proc_number variable

2024-07-15 Thread Heikki Linnakangas
Use correct type for pq_mq_parallel_leader_proc_number variable It's a ProcNumber, not a process id. Both are integers, so it's harmless, but clearly wrong. It's been wrong since forever, the mistake has survived through a couple of refactorings already. Spotted-by: Thomas Munro Discussion: http

pgsql: Use atomics to avoid locking in InjectionPointRun()

2024-07-15 Thread Heikki Linnakangas
Use atomics to avoid locking in InjectionPointRun() This allows using injection points without having a PGPROC, like early at backend startup, or in the postmaster. The injection points facility is new in v17, so backpatch there. Reviewed-by: Michael Paquier Disussion: https://www.postgresql.o

pgsql: Use atomics to avoid locking in InjectionPointRun()

2024-07-15 Thread Heikki Linnakangas
Use atomics to avoid locking in InjectionPointRun() This allows using injection points without having a PGPROC, like early at backend startup, or in the postmaster. The injection points facility is new in v17, so backpatch there. Reviewed-by: Michael Paquier Disussion: https://www.postgresql.o

pgsql: Fix outdated comment after removal of direct SSL fallback

2024-07-08 Thread Heikki Linnakangas
Fix outdated comment after removal of direct SSL fallback The option to fall back from direct SSL to negotiated SSL or a plaintext connection was removed in commit fb5718f35f. Discussion: https://www.postgresql.org/message-id/c82ad227-e049-4e18-8898-475a748b5...@iki.fi Branch -- REL_17_STAB

pgsql: Fix outdated comment after removal of direct SSL fallback

2024-07-08 Thread Heikki Linnakangas
Fix outdated comment after removal of direct SSL fallback The option to fall back from direct SSL to negotiated SSL or a plaintext connection was removed in commit fb5718f35f. Discussion: https://www.postgresql.org/message-id/c82ad227-e049-4e18-8898-475a748b5...@iki.fi Branch -- master Det

pgsql: Lift limitation that PGPROC->links must be the first field

2024-07-05 Thread Heikki Linnakangas
Lift limitation that PGPROC->links must be the first field Since commit 5764f611e1, we've been using the ilist.h functions for handling the linked list. There's no need for 'links' to be the first element of the struct anymore, except for one call in InitProcess where we used a straight cast from

pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND

2024-07-03 Thread Heikki Linnakangas
Avoid 0-length memcpy to NULL with EXEC_BACKEND memcpy(NULL, src, 0) is forbidden by POSIX, even though every production version of libc allows it. Let's be tidy. Per report from Thomas Munro, running UBSan with EXEC_BACKEND. Backpatch to v17, where this code was added. Discussion: https://www.

pgsql: Tighten check for --forkchild argument when spawning child proce

2024-07-03 Thread Heikki Linnakangas
Tighten check for --forkchild argument when spawning child process Commit aafc05de1b removed all the other --fork* arguments. Altough this is inconsequential, backpatch to v17 since this is new. Author: Nathan Bossart Discussion: https://www.postgresql.org/message-id/ZnCCEN0l3qWv-XpW@nathan Bran

pgsql: Avoid 0-length memcpy to NULL with EXEC_BACKEND

2024-07-03 Thread Heikki Linnakangas
Avoid 0-length memcpy to NULL with EXEC_BACKEND memcpy(NULL, src, 0) is forbidden by POSIX, even though every production version of libc allows it. Let's be tidy. Per report from Thomas Munro, running UBSan with EXEC_BACKEND. Backpatch to v17, where this code was added. Discussion: https://www.

pgsql: Tighten check for --forkchild argument when spawning child proce

2024-07-03 Thread Heikki Linnakangas
Tighten check for --forkchild argument when spawning child process Commit aafc05de1b removed all the other --fork* arguments. Altough this is inconsequential, backpatch to v17 since this is new. Author: Nathan Bossart Discussion: https://www.postgresql.org/message-id/ZnCCEN0l3qWv-XpW@nathan Bran

pgsql: Move bgworker specific logic to bgworker.c

2024-07-02 Thread Heikki Linnakangas
Move bgworker specific logic to bgworker.c For clarity, we've been slowly moving functions that are not called from the postmaster process out of postmaster.c. Author: Xing Guo Discussion: https://www.postgresql.org/message-id/CACpMh%2BDBHVT4xPGimzvex%3DwMdMLQEu9PYhT%2BkwwD2x2nu9dU_Q%40mail.gma

pgsql: Remove redundant SetProcessingMode(InitProcessing) calls

2024-07-02 Thread Heikki Linnakangas
Remove redundant SetProcessingMode(InitProcessing) calls After several refactoring iterations, auxiliary processes are no longer initialized from the bootstrapper. Using the InitProcessing mode for initializing auxiliary processes is more appropriate. Since the global variable Mode is initialized

pgsql: Fix missing installation/uninstallation rules for BackgroundPsql

2024-07-01 Thread Heikki Linnakangas
Fix missing installation/uninstallation rules for BackgroundPsql.pm Commit d5fd7865 backported BackgroundPsql perl module module with helper functions for tests running interactive or background psql tasks to PG 12 to 15, but did not add installation/uninstallation rules of the build system, causi

pgsql: Fix missing installation/uninstallation rules for BackgroundPsql

2024-07-01 Thread Heikki Linnakangas
Fix missing installation/uninstallation rules for BackgroundPsql.pm Commit d5fd7865 backported BackgroundPsql perl module module with helper functions for tests running interactive or background psql tasks to PG 12 to 15, but did not add installation/uninstallation rules of the build system, causi

pgsql: Fix missing installation/uninstallation rules for BackgroundPsql

2024-07-01 Thread Heikki Linnakangas
Fix missing installation/uninstallation rules for BackgroundPsql.pm Commit d5fd7865 backported BackgroundPsql perl module module with helper functions for tests running interactive or background psql tasks to PG 12 to 15, but did not add installation/uninstallation rules of the build system, causi

pgsql: Fix missing installation/uninstallation rules for BackgroundPsql

2024-07-01 Thread Heikki Linnakangas
Fix missing installation/uninstallation rules for BackgroundPsql.pm Commit d5fd7865 backported BackgroundPsql perl module module with helper functions for tests running interactive or background psql tasks to PG 12 to 15, but did not add installation/uninstallation rules of the build system, causi

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

pgsql: tests: Trim newline from result returned by BackgroundPsql->quer

2024-06-27 Thread Heikki Linnakangas
tests: Trim newline from result returned by BackgroundPsql->query This went unnoticed, because only a few existing callers of BackgroundPsql->query used the result, and the ones that did were not bothered by an extra newline. I noticed because I was about to add a new test that checks the result.

pgsql: tests: Trim newline from result returned by BackgroundPsql->quer

2024-06-27 Thread Heikki Linnakangas
tests: Trim newline from result returned by BackgroundPsql->query This went unnoticed, because only a few existing callers of BackgroundPsql->query used the result, and the ones that did were not bothered by an extra newline. I noticed because I was about to add a new test that checks the result.

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

pgsql: tests: Trim newline from result returned by BackgroundPsql->quer

2024-06-27 Thread Heikki Linnakangas
tests: Trim newline from result returned by BackgroundPsql->query This went unnoticed, because only a few existing callers of BackgroundPsql->query used the result, and the ones that did were not bothered by an extra newline. I noticed because I was about to add a new test that checks the result.

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

pgsql: tests: Trim newline from result returned by BackgroundPsql->quer

2024-06-27 Thread Heikki Linnakangas
tests: Trim newline from result returned by BackgroundPsql->query This went unnoticed, because only a few existing callers of BackgroundPsql->query used the result, and the ones that did were not bothered by an extra newline. I noticed because I was about to add a new test that checks the result.

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

pgsql: tests: Trim newline from result returned by BackgroundPsql->quer

2024-06-27 Thread Heikki Linnakangas
tests: Trim newline from result returned by BackgroundPsql->query This went unnoticed, because only a few existing callers of BackgroundPsql->query used the result, and the ones that did were not bothered by an extra newline. I noticed because I was about to add a new test that checks the result.

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

pgsql: Fix MVCC bug with prepared xact with subxacts on standby

2024-06-27 Thread Heikki Linnakangas
Fix MVCC bug with prepared xact with subxacts on standby We did not recover the subtransaction IDs of prepared transactions when starting a hot standby from a shutdown checkpoint. As a result, such subtransactions were considered as aborted, rather than in-progress. That would lead to hint bits be

  1   2   3   4   5   6   7   8   >