pgsql: libpq: Use modern socket flags, if available.

2023-03-17 Thread Thomas Munro
libpq: Use modern socket flags, if available. Since commit 7627b91cd5d, libpq has used FD_CLOEXEC so that sockets wouldn't be leaked to subprograms. With enough bad luck, a multi-threaded program might fork in between the socket() and fcntl() calls. We can close that tiny gap by using SOCK_CLOEX

pgsql: postgres_fdw: Remove useless if-test in GetConnection().

2023-03-17 Thread Etsuro Fujita
postgres_fdw: Remove useless if-test in GetConnection(). Checking whether entry->conn is NULL after doing disconnect_pg_server() for that entry is pointless, as that function ensures that it is NULL. Thinko in commit 7fc1a81e4; this would be harmless, so patch HEAD only. Reviewed-by: Richard Guo

pgsql: Improve several permission-related error messages.

2023-03-17 Thread Peter Eisentraut
Improve several permission-related error messages. Mainly move some detail from errmsg to errdetail, remove explicit mention of superuser where appropriate, since that is implied in most permission checks, and make messages more uniform. Author: Nathan Bossart Discussion: https://www.postgresql

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Fix pg_dump for hash partitioning on enum columns.

2023-03-17 Thread Tom Lane
Fix pg_dump for hash partitioning on enum columns. Hash partitioning on an enum is problematic because the hash codes are derived from the OIDs assigned to the enum values, which will almost certainly be different after a dump-and-reload than they were before. This means that some rows probably en

pgsql: Simplify and speed up pg_dump's creation of parent-table links.

2023-03-17 Thread Tom Lane
Simplify and speed up pg_dump's creation of parent-table links. Instead of trying to optimize this by skipping creation of the links for tables we don't plan to dump, just create them all in bulk with a single scan over the pg_inherits data. The previous approach was more or less O(N^2) in the nu

pgsql: Fix t_isspace(), etc., when datlocprovider=i and datctype=C.

2023-03-17 Thread Jeff Davis
Fix t_isspace(), etc., when datlocprovider=i and datctype=C. Check whether the datctype is C to determine whether t_isspace() and related functions use isspace() or iswspace(). Previously, t_isspace() checked whether the database default collation was C; which is incorrect when the default collat

pgsql: Fix t_isspace(), etc., when datlocprovider=i and datctype=C.

2023-03-17 Thread Jeff Davis
Fix t_isspace(), etc., when datlocprovider=i and datctype=C. Check whether the datctype is C to determine whether t_isspace() and related functions use isspace() or iswspace(). Previously, t_isspace() checked whether the database default collation was C; which is incorrect when the default collat

pgsql: Fix typo

2023-03-17 Thread Peter Eisentraut
Fix typo Introduced in de4d456b40. Reported-by: Erik Rijkers Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/cc1392d4aa5206d6b4dcc1b036f7a001bcac4197 Modified Files -- src/backend/commands/user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

pgsql: Refactor datetime functions' timezone lookup code to reduce dupl

2023-03-17 Thread Tom Lane
Refactor datetime functions' timezone lookup code to reduce duplication. We already had five copies of essentially the same logic, and an upcoming patch introduces yet another use-case. That's past my threshold of pain, so introduce a common subroutine. There's not that much net code savings, bu