pgsql: Update obsolete comment about pg_usleep() accuracy.

2023-03-14 Thread Thomas Munro
Update obsolete comment about pg_usleep() accuracy. There are still some systems that use traditional tick-based sleep timing, but many including Linux, FreeBSD and macOS started using high resolution timer hardware more directly a decade or two ago. Update our comment about that. Also highlight

pgsql: Use nanosleep() to implement pg_usleep().

2023-03-14 Thread Thomas Munro
Use nanosleep() to implement pg_usleep(). The previous coding based on select() had commentary about historical portability concerns. Use POSIX nanosleep() instead. This has independently been suggested a couple of times before, but never managed to stick. Since recent and proposed work removes

pgsql: Add the testcases for 89e46da5e5.

2023-03-14 Thread Amit Kapila
Add the testcases for 89e46da5e5. Forgot to add new testcases in commit 89e46da5e5. Author: Onder Kalaci, Amit Kapila Reviewed-by: Peter Smith, Shi yu, Hou Zhijie, Vignesh C, Kuroda Hayato, Amit Kapila Discussion: https://postgr.es/m/[email protected]

pgsql: Improve WIN32 port of fstat() to detect more file types

2023-03-14 Thread Michael Paquier
Improve WIN32 port of fstat() to detect more file types The current implementation of _pgfstat64() is ineffective in detecting a terminal handle or an anonymous named pipe. This commit improves our port of fstat() to detect more efficiently such cases by relying on GetFileType(), and returning mo

pgsql: Improve WIN32 port of fstat() to detect more file types

2023-03-14 Thread Michael Paquier
Improve WIN32 port of fstat() to detect more file types The current implementation of _pgfstat64() is ineffective in detecting a terminal handle or an anonymous named pipe. This commit improves our port of fstat() to detect more efficiently such cases by relying on GetFileType(), and returning mo

pgsql: Improve WIN32 port of fstat() to detect more file types

2023-03-14 Thread Michael Paquier
Improve WIN32 port of fstat() to detect more file types The current implementation of _pgfstat64() is ineffective in detecting a terminal handle or an anonymous named pipe. This commit improves our port of fstat() to detect more efficiently such cases by relying on GetFileType(), and returning mo

Re: pgsql: Allow the use of indexes other than PK and REPLICA IDENTITY on t

2023-03-14 Thread Amit Kapila
On Wed, Mar 15, 2023 at 9:08 AM Amit Kapila wrote: > > Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber. > Sorry, this commit leads to failures in subscription tests because I forgot to add a new test file. I am doing it now. -- With Regards, Amit Kapila.

pgsql: Allow the use of indexes other than PK and REPLICA IDENTITY on t

2023-03-14 Thread Amit Kapila
Allow the use of indexes other than PK and REPLICA IDENTITY on the subscriber. Using REPLICA IDENTITY FULL on the publisher can lead to a full table scan per tuple change on the subscription when REPLICA IDENTITY or PK index is not available. This makes REPLICA IDENTITY FULL impractical to use apa

pgsql: Fix fractional vacuum_cost_delay.

2023-03-14 Thread Thomas Munro
Fix fractional vacuum_cost_delay. Commit 4753ef37 changed vacuum_delay_point() to use the WaitLatch() API, to fix the problem that vacuum could keep running for a very long time after the postmaster died. Unfortunately, that broke commit caf626b2's support for fractional vacuum_cost_delay, which

pgsql: Fix fractional vacuum_cost_delay.

2023-03-14 Thread Thomas Munro
Fix fractional vacuum_cost_delay. Commit 4753ef37 changed vacuum_delay_point() to use the WaitLatch() API, to fix the problem that vacuum could keep running for a very long time after the postmaster died. Unfortunately, that broke commit caf626b2's support for fractional vacuum_cost_delay, which

pgsql: Fix fractional vacuum_cost_delay.

2023-03-14 Thread Thomas Munro
Fix fractional vacuum_cost_delay. Commit 4753ef37 changed vacuum_delay_point() to use the WaitLatch() API, to fix the problem that vacuum could keep running for a very long time after the postmaster died. Unfortunately, that broke commit caf626b2's support for fractional vacuum_cost_delay, which

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix waitpid() emulation on Windows.

2023-03-14 Thread Thomas Munro
Fix waitpid() emulation on Windows. Our waitpid() emulation didn't prevent a PID from being recycled by the OS before the call to waitpid(). The postmaster could finish up tracking more than one child process with the same PID, and confuse them. Fix, by moving the guts of pgwin32_deadchild_callb

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Fix corner case bug in numeric to_char() some more.

2023-03-14 Thread Tom Lane
Fix corner case bug in numeric to_char() some more. The band-aid applied in commit f0bedf3e4 turns out to still need some work: it made sure we didn't set Np->last_relevant too small (to the left of the decimal point), but it didn't prevent setting it too large (off the end of the partially-conver

pgsql: Allow pg_dump to include/exclude child tables automatically.

2023-03-14 Thread Tom Lane
Allow pg_dump to include/exclude child tables automatically. This patch adds new pg_dump switches --table-and-children=pattern --exclude-table-and-children=pattern --exclude-table-data-and-children=pattern which act the same as the existing --table, --exclude-table, and --exclude-table

pgsql: Remove unnecessary code in dependency_is_compatible_expression()

2023-03-14 Thread Tom Lane
Remove unnecessary code in dependency_is_compatible_expression(). Scanning the expression for compatible Vars isn't really necessary, because the subsequent match against StatisticExtInfo entries will eliminate expressions containing other Vars just fine. Moreover, this code hadn't stopped to thi

pgsql: Remove unnecessary code in dependency_is_compatible_expression()

2023-03-14 Thread Tom Lane
Remove unnecessary code in dependency_is_compatible_expression(). Scanning the expression for compatible Vars isn't really necessary, because the subsequent match against StatisticExtInfo entries will eliminate expressions containing other Vars just fine. Moreover, this code hadn't stopped to thi

pgsql: Remove unnecessary code in dependency_is_compatible_expression()

2023-03-14 Thread Tom Lane
Remove unnecessary code in dependency_is_compatible_expression(). Scanning the expression for compatible Vars isn't really necessary, because the subsequent match against StatisticExtInfo entries will eliminate expressions containing other Vars just fine. Moreover, this code hadn't stopped to thi

pgsql: doc: spell out full productname

2023-03-14 Thread Daniel Gustafsson
doc: spell out full productname Use PostgreSQL consistently for referring to the productname rather than Postgres. This also adds markup. Reviewed-by: Alvaro Herrera Reviewed-by: "Jonathan S. Katz" Discussion: https://postgr.es/m/[email protected] Branch -- ma

pgsql: Rework design of functions in pg_walinspect

2023-03-14 Thread Michael Paquier
Rework design of functions in pg_walinspect This commit reworks a bit the set-returning functions of pg_walinspect, making them more flexible regarding their end LSN: - pg_get_wal_records_info() - pg_get_wal_stats() - pg_get_wal_block_info() The end LSNs given to these functions is now handled so

pgsql: Add support for the error functions erf() and erfc().

2023-03-14 Thread Dean Rasheed
Add support for the error functions erf() and erfc(). Expose the standard error functions as SQL-callable functions. These are expected to be useful to people working with normal distributions, and we use them here to test the distribution from random_normal(). Since these functions are defined i