pgsql: Remove publicationcmds.c's expr_allowed_in_node as a function

2022-09-28 Thread Alvaro Herrera
Remove publicationcmds.c's expr_allowed_in_node as a function Its API is quite strange, and since there's only one caller, there's no reason for it to be a separate function in the first place. Inline it instead. Discussion: https://postgr.es/m/20220927124249.4zdzzlz6had7k3x2@alvherre.pgsql Bra

pgsql: Remove publicationcmds.c's expr_allowed_in_node as a function

2022-09-28 Thread Alvaro Herrera
Remove publicationcmds.c's expr_allowed_in_node as a function Its API is quite strange, and since there's only one caller, there's no reason for it to be a separate function in the first place. Inline it instead. Discussion: https://postgr.es/m/20220927124249.4zdzzlz6had7k3x2@alvherre.pgsql Bra

pgsql: Fix alignment problems with SharedInvalSmgrMsg.

2022-09-28 Thread Robert Haas
Fix alignment problems with SharedInvalSmgrMsg. SharedInvalSmgrMsg can't require 8-byte alignment, because then SharedInvalidationMessage will require 8-byte alignment, which will then cause ParseCommitRecord to fail on machines that are picky about alignment, because it assumes that everything th

pgsql: Fix InitializeRelfilenumberMap for 05d4cbf9b6ba708858984b01ca0fc

2022-09-28 Thread Robert Haas
Fix InitializeRelfilenumberMap for 05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c Since relfilenodes are now 56-bits, we use bigint as the SQL type to represent them, which means F_INT8EQ must be used here rather than F_OIDEQ. On 64-bit machines this doesn't matter, but 32-bit machines are unhappy. Dil

pgsql: Revert 56-bit relfilenode change and follow-up commits.

2022-09-28 Thread Robert Haas
Revert 56-bit relfilenode change and follow-up commits. There are still some alignment-related failures in the buildfarm, which might or might not be able to be fixed quickly, but I've also just realized that it increased the size of many WAL records by 4 bytes because a block reference contains a

pgsql: Fix bug in DROP OWNED BY.

2022-09-28 Thread Robert Haas
Fix bug in DROP OWNED BY. Commit 6566133c5f52771198aca07ed18f84519fac1be7 broke the case where the role passed to DROP OWNED BY owns a database. Report by Rushabh Lathia, who also provided a patch, but this patch takes a slightly different approach to fixing the problem. Discussion: http://post

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Change some errdetail() to errdetail_internal()

2022-09-28 Thread Alvaro Herrera
Change some errdetail() to errdetail_internal() This prevents marking the argument string for translation for gettext, and it also prevents the given string (which is already translated) from being translated at runtime. Also, mark the strings used as arguments to check_rolespec_name for translat

pgsql: Allow callback functions to deregister themselves during a call.

2022-09-28 Thread Tom Lane
Allow callback functions to deregister themselves during a call. Fetch the next-item pointer before the call not after, so that we aren't dereferencing a dangling pointer if the callback deregistered itself during the call. The risky coding pattern appears in CallXactCallbacks, CallSubXactCallbac

pgsql: Doc: document bpchar, clarify relationship of text and varchar.

2022-09-28 Thread Tom Lane
Doc: document bpchar, clarify relationship of text and varchar. For some reason the "bpchar" type name was defined nowhere in our SGML docs, although several places refer to it in passing. Give it a proper mention under Character Types. While here, also provide an explanation of how the text and

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

pgsql: revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"

2022-09-28 Thread Bruce Momjian
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs" doc revert of commit 1703726488. Change was applied to irrelevant branches, and was not detailed enough to be helpful in relevant branches. Reported-by: Peter Eisentraut, Noah Misch Discussion: https://postgr.es/m/a2dc9de4-24fc-3

Re: pgsql: doc: clarify recursion internal behavior

2022-09-28 Thread Bruce Momjian
On Thu, Sep 8, 2022 at 11:30:04AM -0400, Tom Lane wrote: > Robert Haas writes: > > On Thu, Sep 8, 2022 at 7:24 AM Peter Eisentraut > > wrote: > >> On 03.09.22 03:58, Bruce Momjian wrote: > >>> +While RECURSIVE allows queries to be specified > >>> +recursively, internally all queries are

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_10_STABLE Details --- https://git.postgresql.org/pg/commitdiff/19815537632dd617721bf4f9dd4fc212b10bccd5 Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_11_STABLE Details --- https://git.postgresql.org/pg/commitdiff/86f2ee2e2731cda414b9c29b6ace82e2a8de536d Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/994c5ceabe1eef6dd490bc74244f4b4dd69db2c9 Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/517fab6a405628a7e4d2aad4cb19ab652adea720 Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/81c094bd93763f76190c2a78e13cae03e15b7432 Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/ce4e8606cabe20ce62c8c9d3d34321df43f626ae Mo

pgsql: doc: clarify internal behavior of RECURSIVE CTE queries

2022-09-28 Thread Bruce Momjian
doc: clarify internal behavior of RECURSIVE CTE queries Reported-by: Tom Lane Discussion: https://postgr.es/m/3976627.1662651...@sss.pgh.pa.us Backpatch-through: 10 Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/2a66b9bfb74e522d64c066dabe4fddde0fe7425c Modified

pgsql: Restrict Datum sort optimization to byval types only

2022-09-28 Thread David Rowley
Restrict Datum sort optimization to byval types only 91e9e89dc modified nodeSort.c so that it used datum sorts when the targetlist of the outer node contained only a single column. That commit failed to recognise that the Datum returned by tuplesort_getdatum() must be pfree'd when the type is a b

pgsql: Restrict Datum sort optimization to byval types only

2022-09-28 Thread David Rowley
Restrict Datum sort optimization to byval types only 91e9e89dc modified nodeSort.c so that it used datum sorts when the targetlist of the outer node contained only a single column. That commit failed to recognise that the Datum returned by tuplesort_getdatum() must be pfree'd when the type is a b

pgsql: Restore pg_pread and friends.

2022-09-28 Thread Thomas Munro
Restore pg_pread and friends. Commits cf112c12 and a0dc8271 were a little too hasty in getting rid of the pg_ prefixes where we use pread(), pwrite() and vectored variants. We dropped support for ancient Unixes where we needed to use lseek() to implement replacements for those, but it turns out t

pgsql: Map ERROR_INVALID_NAME to ENOENT in mapping table of win32error.

2022-09-28 Thread Michael Paquier
Map ERROR_INVALID_NAME to ENOENT in mapping table of win32error.c This error can be reached when sending an incorrect file name to open() on Windows, resulting in a confusing errno reported. This has been seen in the development of a different patch by the same author. Author: Bharath Rupireddy

pgsql: meson: windows: Normalize slashes in prefix

2022-09-28 Thread Andres Freund
meson: windows: Normalize slashes in prefix This fixes a build issue on windows, when the prefix is set to a path with forward slashes. Windows python defaults to a path with a backslash, but mingw ucrt python defaults to a forward slash. This in turn lead to a wrong PATH set during tests, causing

pgsql: meson: Implement getopt logic from autoconf

2022-09-28 Thread Andres Freund
meson: Implement getopt logic from autoconf Not replacing getopt/getopt_long definitely causes issues on mingw. It's not as clear whether the solaris & openbsd aspect is still needed, but if not, we should remove it from both autoconf and meson. Discussion: http://postgr.es/m/20220928022724.erzu

pgsql: meson: mingw: Allow multiple definitions

2022-09-28 Thread Andres Freund
meson: mingw: Allow multiple definitions I didn't carry this forward from the win32 template. It's not needed anymore for the reason stated therein, but it turns out to be required to e.g. override getopt. Possibly a better solution exists, but that's for later. Discussion: http://postgr.es/m/20

pgsql: meson: pg_regress: Define a HOST_TUPLE sufficient to make result

2022-09-28 Thread Andres Freund
meson: pg_regress: Define a HOST_TUPLE sufficient to make resultmap work This doesn't end up with a triple that's exactly the same as config.guess - it'd be hard to achieve that and it doesn't seem required. We can't rely on config.guess as we don't necessarily have a /bin/sh on windows, e.g., whe

pgsql: windows: Set UMDF_USING_NTSTATUS globally, include ntstatus.h

2022-09-28 Thread Andres Freund
windows: Set UMDF_USING_NTSTATUS globally, include ntstatus.h We'd like to use precompiled headers on windows to reduce compile times. Right now we rely on defining UMDF_USING_NTSTATUS before including postgres.h in a few select places - which doesn't work with precompiled headers. Instead define

pgsql: Mark sigint_interrupt_enabled as sig_atomic_t

2022-09-28 Thread Michael Paquier
Mark sigint_interrupt_enabled as sig_atomic_t This is a continuation of 78fdb1e, where this flag is set in the psql callback handler used for SIGINT. This was previously a boolean but the C standard recommends the use of sig_atomic_t. Note that this influences PromptInterruptContext in string.h,

pgsql: Introduce SYSTEM_USER

2022-09-28 Thread Michael Paquier
Introduce SYSTEM_USER SYSTEM_USER is a reserved keyword of the SQL specification that, roughly described, is aimed at reporting some information about the system user who has connected to the database server. It may include implementation-specific information about the means by the user connected