pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Disallow partitionwise grouping when collations don't match

2024-11-07 Thread Amit Langote
Disallow partitionwise grouping when collations don't match If the collation of any grouping column doesn’t match the collation of the corresponding partition key, partitionwise grouping can yield incorrect results. For example, rows that would be grouped under the grouping collation may end up in

pgsql: Message style improvement

2024-11-07 Thread Peter Eisentraut
Message style improvement Backpatch the part of edee0c621de that applies to a90bdd7a44d, which was also backpatched. That way, the message is consistent in all branches. Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/57c8b87262681a9d53e691fa3d1edc5efc1574e3

pgsql: Message style improvement

2024-11-07 Thread Peter Eisentraut
Message style improvement Backpatch the part of edee0c621de that applies to a90bdd7a44d, which was also backpatched. That way, the message is consistent in all branches. Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/cae459d11dcd9e0bca73bd59cf1b4c1718a47aa0

pgsql: Message style improvement

2024-11-07 Thread Peter Eisentraut
Message style improvement Backpatch the part of edee0c621de that applies to a90bdd7a44d, which was also backpatched. That way, the message is consistent in all branches. Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/38f506470f3faebb00bbb352ec2ea25d1f6c33a2

pgsql: Message style improvement

2024-11-07 Thread Peter Eisentraut
Message style improvement Backpatch the part of edee0c621de that applies to a90bdd7a44d, which was also backpatched. That way, the message is consistent in all branches. Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/a54a5c426bb5a3e216d715437a9a043aa82b6ec4

pgsql: Message style improvement

2024-11-07 Thread Peter Eisentraut
Message style improvement Backpatch the part of edee0c621de that applies to a90bdd7a44d, which was also backpatched. That way, the message is consistent in all branches. Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/ebbfa2ae34ce85d09fe9ea87b41f9186864c7075

pgsql: Fix inconsistent RestrictInfo serial numbers

2024-11-07 Thread Richard Guo
Fix inconsistent RestrictInfo serial numbers When we generate multiple clones of the same qual condition to cope with outer join identity 3, we need to ensure that all the clones get the same serial number. To achieve this, we reset the root->last_rinfo_serial counter each time we produce Restric

pgsql: Fix inconsistent RestrictInfo serial numbers

2024-11-07 Thread Richard Guo
Fix inconsistent RestrictInfo serial numbers When we generate multiple clones of the same qual condition to cope with outer join identity 3, we need to ensure that all the clones get the same serial number. To achieve this, we reset the root->last_rinfo_serial counter each time we produce Restric

pgsql: Provide lstat() for Windows.

2024-11-07 Thread Andrew Dunstan
Provide lstat() for Windows. Junction points will be reported with S_ISLNK(x.st_mode), simulating POSIX lstat(). stat() will follow pseudo-symlinks, like in POSIX (but only one level before giving up, unlike in POSIX). This completes a TODO left by commit bed90759fcb. Tested-by: Andrew Dunstan

pgsql: Fix lstat() for broken junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Fix lstat() for broken junction points on Windows. When using junction points to emulate symlinks on Windows, one edge case was not handled correctly by commit c5cb8f3b: if a junction point is broken (pointing to a non-existent path), we'd report ENOENT. This doesn't break any known use case, but

pgsql: Provide lstat() for Windows.

2024-11-07 Thread Andrew Dunstan
Provide lstat() for Windows. Junction points will be reported with S_ISLNK(x.st_mode), simulating POSIX lstat(). stat() will follow pseudo-symlinks, like in POSIX (but only one level before giving up, unlike in POSIX). This completes a TODO left by commit bed90759fcb. Tested-by: Andrew Dunstan

pgsql: Check for STATUS_DELETE_PENDING on Windows.

2024-11-07 Thread Andrew Dunstan
Check for STATUS_DELETE_PENDING on Windows. 1. Update our open() wrapper to check for NT's STATUS_DELETE_PENDING and translate it to Unix-like errors. This is done with RtlGetLastNtStatus(), which is dynamically loaded from ntdll. A new file win32ntdll.c centralizes lookup of NT functions, in c

pgsql: Fix issues with Windows' stat() for files pending on deletion

2024-11-07 Thread Andrew Dunstan
Fix issues with Windows' stat() for files pending on deletion The code introduced by bed9075 to enhance the stat() implementation on Windows for file sizes larger than 4GB fails to properly detect files pending for deletion with its method based on NtQueryInformationFile() or GetFileInformationByH

pgsql: Replace pgwin32_is_junction() with lstat().

2024-11-07 Thread Andrew Dunstan
Replace pgwin32_is_junction() with lstat(). Now that lstat() reports junction points with S_IFLNK/S_ISLINK(), and unlink() can unlink them, there is no need for conditional code for Windows in a few places. That was expressed by testing for WIN32 or S_ISLNK, which we can now constant-fold. The c

pgsql: Make unlink() work for junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Make unlink() work for junction points on Windows. To support harmonization of Windows and Unix code, teach our unlink() wrapper that junction points need to be unlinked with rmdir() on Windows. Tested-by: Andrew Dunstan Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgi

pgsql: Make unlink() work for junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Make unlink() work for junction points on Windows. To support harmonization of Windows and Unix code, teach our unlink() wrapper that junction points need to be unlinked with rmdir() on Windows. Tested-by: Andrew Dunstan Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgi

pgsql: Add missing include guard to win32ntdll.h.

2024-11-07 Thread Andrew Dunstan
Add missing include guard to win32ntdll.h. Oversight in commit e2f0f8ed. Also add this file to the exclusion lists in headerscheck and cpluscpluscheck, because Unix systems don't have a header it includes. Reported-by: Tom Lane Discussion: https://postgr.es/m/2760528.1641929756%40sss.pgh.pa.us

pgsql: Fix lstat() for broken junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Fix lstat() for broken junction points on Windows. When using junction points to emulate symlinks on Windows, one edge case was not handled correctly by commit c5cb8f3b: if a junction point is broken (pointing to a non-existent path), we'd report ENOENT. This doesn't break any known use case, but

pgsql: Provide lstat() for Windows.

2024-11-07 Thread Andrew Dunstan
Provide lstat() for Windows. Junction points will be reported with S_ISLNK(x.st_mode), simulating POSIX lstat(). stat() will follow pseudo-symlinks, like in POSIX (but only one level before giving up, unlike in POSIX). This completes a TODO left by commit bed90759fcb. Tested-by: Andrew Dunstan

pgsql: Add missing include guard to win32ntdll.h.

2024-11-07 Thread Andrew Dunstan
Add missing include guard to win32ntdll.h. Oversight in commit e2f0f8ed. Also add this file to the exclusion lists in headerscheck and cpluscpluscheck, because Unix systems don't have a header it includes. Reported-by: Tom Lane Discussion: https://postgr.es/m/2760528.1641929756%40sss.pgh.pa.us

pgsql: Fix -Wcast-function-type warnings

2024-11-07 Thread Andrew Dunstan
Fix -Wcast-function-type warnings Three groups of issues needed to be addressed: load_external_function() and related functions returned PGFunction, even though not necessarily all callers are looking for a function of type PGFunction. Since these functions are really just wrappers around dlsym(

pgsql: Disable clang 16's -Wcast-function-type-strict.

2024-11-07 Thread Andrew Dunstan
Disable clang 16's -Wcast-function-type-strict. Clang 16 is still in development, but seawasp reveals that it has started warning about many of our casts of function pointers (those introduced by commit 1c27d16e, and some older ones). Disable the new warning for now, since otherwise buildfarm ani

pgsql: Check for STATUS_DELETE_PENDING on Windows.

2024-11-07 Thread Andrew Dunstan
Check for STATUS_DELETE_PENDING on Windows. 1. Update our open() wrapper to check for NT's STATUS_DELETE_PENDING and translate it to Unix-like errors. This is done with RtlGetLastNtStatus(), which is dynamically loaded from ntdll. A new file win32ntdll.c centralizes lookup of NT functions, in c

pgsql: Replace pgwin32_is_junction() with lstat().

2024-11-07 Thread Andrew Dunstan
Replace pgwin32_is_junction() with lstat(). Now that lstat() reports junction points with S_IFLNK/S_ISLINK(), and unlink() can unlink them, there is no need for conditional code for Windows in a few places. That was expressed by testing for WIN32 or S_ISLNK, which we can now constant-fold. The c

pgsql: Make unlink() work for junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Make unlink() work for junction points on Windows. To support harmonization of Windows and Unix code, teach our unlink() wrapper that junction points need to be unlinked with rmdir() on Windows. Tested-by: Andrew Dunstan Discussion: https://postgr.es/m/CA%2BhUKGLfOOeyZpm5ByVcAt7x5Pn-%3DxGRNCvgi

pgsql: Fix our Windows stat() emulation to handle file sizes > 4GB.

2024-11-07 Thread Andrew Dunstan
Fix our Windows stat() emulation to handle file sizes > 4GB. Hack things so that our idea of "struct stat" is equivalent to Windows' struct __stat64, allowing it to have a wide enough st_size field. Instead of relying on native stat(), use GetFileInformationByHandle(). This avoids a number of iss

pgsql: Fix lstat() for broken junction points on Windows.

2024-11-07 Thread Andrew Dunstan
Fix lstat() for broken junction points on Windows. When using junction points to emulate symlinks on Windows, one edge case was not handled correctly by commit c5cb8f3b: if a junction point is broken (pointing to a non-existent path), we'd report ENOENT. This doesn't break any known use case, but

pgsql: Fix __attribute__((target(...))) usage.

2024-11-07 Thread Nathan Bossart
Fix __attribute__((target(...))) usage. The commonly supported way to specify multiple target options is to surround the entire list with quotes and to use a comma (with no extra spaces) as the delimiter. Oversight in commit f78667bd91. Discussion: https://postgr.es/m/Zy0jya8nF8CPpv3B%40nathan

pgsql: Use __attribute__((target(...))) for AVX-512 support.

2024-11-07 Thread Nathan Bossart
Use __attribute__((target(...))) for AVX-512 support. Presently, we check for compiler support for the required intrinsics both with and without extra compiler flags (e.g., -mxsave), and then depending on the results of those checks, we pick which files to compile with which flags. This is tediou

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constra

2024-11-07 Thread Álvaro Herrera
doc: Reword ALTER TABLE ATTACH restriction on NO INHERIT constraints The previous wording is easy to read incorrectly; this change makes it simpler, less ambiguous, and less prominent. Backpatch to all live branches. Reviewed-by: Amit Langote Discussion: https://postgr.es/m/202411051201.zody6ml

pgsql: Clarify a foreign key error message

2024-11-07 Thread Peter Eisentraut
Clarify a foreign key error message Clarify the message about type mismatch in foreign key definition to indicate which column the referencing and which is the referenced one. Reported-by: Jian He Discussion: https://www.postgresql.org/message-id/CACJufxEL82ao-aXOa=d_-xip0bix-qdsync9fcwxodkezfk