Michael Paquier [Mon, 3 Oct 2022 07:42:25 +0000 (16:42 +0900)]
Add authentication TAP test for peer authentication
This commit introduces an authentication test for the peer method, as of
a set of scenarios with and without a user name map. The script is
automatically skipped if peer is not supported in the environment where
this test is run, checking this behavior by attempting a connection
first on a cluster up and running.
Author: Bertrand Drouvot
Discussion: https://postgr.es/m/
aa60994b-1c66-ca7a-dab9-
9a200dbac3d2@amazon.com
Andres Freund [Sun, 2 Oct 2022 00:04:13 +0000 (17:04 -0700)]
ci: enable various runtime checks on FreeBSD and macOS
Increase likelihood of discovering problems during CI rather the buildfarm by
defining -DRELCACHE_FORCE_RELEASE -DCOPY_PARSE_PLAN_TREES
-DWRITE_READ_PARSE_PLAN_TREES -DRAW_EXPRESSION_COVERAGE_TEST on FreeBSD, and
-DRANDOMIZE_ALLOCATED_MEMORY on macOS.
FreeBSD and macoS are currently not CI bottlenecks, so we can afford to
increase their test times a bit.
Author: Justin Pryzby <pryzbyj@telsasoft.com>
Discussion: https://postgr.es/m/
20220910200542.GX31833@telsasoft.com
Andres Freund [Sat, 1 Oct 2022 23:55:16 +0000 (16:55 -0700)]
ci: macos: Reduce test concurrency
Test performance regresses noticably when using all cores. This is more
pronounced with meson than with autoconf, presumably because meson will
schedule the "full number" of tests more consistently. 8 seems to work
OK.
Discussion: https://postgr.es/m/
20220927040208.l3shfcidovpzqxfh@awork3.anarazel.de
Backpatch: 15-, where CI was introduced
Andres Freund [Sat, 1 Oct 2022 19:39:12 +0000 (12:39 -0700)]
meson: Add prefix=/usr/local/pgsql to default_options
autoconf set PREFIX to /usr/local/pgsql, so using the same default for meson
makes sense. The effect on windows is that installation defaults to installing
to C:/usr/local/pgsql rather than meson's default of C:/, which doesn't seem
perfect, but OK enough.
Signed-off-by: Junwang Zhao <zhjwpku@gmail.com>
Author: Junwang Zhao <zhjwpku@gmail.com>
Discussion: https://postgr.es/CAEG8a3LGWE-gG6vuddmH91RORhi8gWs0mMB-hcTmP3_NVgM7dg@mail.gmail.com
Andres Freund [Sat, 1 Oct 2022 19:39:12 +0000 (12:39 -0700)]
meson: windows: Determine path to tmp_install + prefix using meson
Previously some paths (like c:\ or d:/) worked, but plenty others (like
/path/to or //computer/share/path) didn't. As we'd like to change the default
prefix to /usr/local/pgsql, that's a problem.
Instead of trying to do this in meson.build, call out to the implementation
meson install uses. This isn't pretty, but it's more reliable than what we had
before.
Discussion: https://postgr.es/CAEG8a3LGWE-gG6vuddmH91RORhi8gWs0mMB-hcTmP3_NVgM7dg@mail.gmail.com
Peter Eisentraut [Sat, 1 Oct 2022 10:48:24 +0000 (12:48 +0200)]
Fix tiny memory leaks
Both check_application_name() and check_cluster_name() use
pg_clean_ascii() but didn't release the memory. Depending on when the
GUC is set, this might be cleaned up at some later time or it would
leak postmaster memory once. In any case, it seems better not to have
to rely on such analysis and make the code locally robust. Also, this
makes Valgrind happier.
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Reviewed-by: Jacob Champion <jchampion@timescale.com>
Discussion: https://www.postgresql.org/message-id/CAD21AoBmFNy9MPfA0UUbMubQqH3AaK5U3mrv6pSeWrwCk3LJ8g@mail.gmail.com
Michael Paquier [Sat, 1 Oct 2022 06:28:02 +0000 (15:28 +0900)]
doc: Fix some grammar and typos
This fixes some areas related to logical replication and custom RMGRs.
Author: Ekaterina Kiryanova
Discussion: https://postgr.es/m/
fa4773f1-1396-384a-bcd7-
85b5e013f399@postgrespro.ru
Backpatch-through: 15
Andres Freund [Wed, 28 Sep 2022 17:19:00 +0000 (10:19 -0700)]
meson: mingw: Add -Wl,--disable-auto-import, enable when linking with readline
I hadn't ported -Wl,--disable-auto-import over from the win32 template as I
had focused on msvc for windows. The flag is desirable as it makes it easier
to find problems one would have with msvc, particularly useful during cross
compilation.
This turned out to be a somewhat happy accident, as it allowed me to realize
that readline actually works on windows these days, as long as auto imports to
enable. Therefore enable auto-import again as part of linking to readline.
We perhaps can come up with a better solution for the readline issue, but this
seems good enough for now.
Discussion: http://postgr.es/m/
20220928022724.erzuk5v4ai4b53do@awork3.anarazel.de
Tom Lane [Fri, 30 Sep 2022 23:36:46 +0000 (19:36 -0400)]
Avoid improbable PANIC during heap_update, redux.
Commit
34f581c39 intended to ensure that RelationGetBufferForTuple
would acquire a visibility-map page pin in case the otherBuffer's
all-visible bit had become set since we last had lock on that page.
But I missed a case: when we're extending the relation, VM concerns
were dealt with only in the relatively-less-likely case that we
fail to conditionally lock the otherBuffer. I think I'd believed
that we couldn't need to worry about it if the conditional lock
succeeds, which is true for the target buffer; but the otherBuffer
was unlocked for awhile so its bit might be set anyway. So we need
to do the GetVisibilityMapPins dance, and then also recheck the
page's free space, in both cases.
Per report from Jaime Casanova. Back-patch to v12 as the previous
patch was (although there's still no evidence that the bug is
reachable pre-v14).
Discussion: https://postgr.es/m/E1lWLjP-00006Y-Ml@gemulon.postgresql.org
Andres Freund [Wed, 28 Sep 2022 17:16:49 +0000 (10:16 -0700)]
mingw: Define PGDLLEXPORT as __declspec (dllexport) as done for msvc
While mingw would otherwise fall back to
__attribute__((visibility("default"))), that appears to only work as long as
no symbols are declared with __declspec(dllexport). But we can end up with
some, e.g. plpython's Py_Init.
It's quite possible we should do the same for cygwin, but I don't have a test
environment for that...
Discussion: http://postgr.es/m/
20220928022724.erzuk5v4ai4b53do@awork3.anarazel.de
Discussion: http://postgr.es/m/
20220928025242.ugf7t5ugxxgmkraa@awork3.anarazel.de
Tom Lane [Fri, 30 Sep 2022 14:26:47 +0000 (10:26 -0400)]
Adjust PQsslAttributeNames() to match PQsslAttribute().
Currently, PQsslAttributeNames() returns the same list of attribute
names regardless of its conn parameter. This patch changes it to
have behavior parallel to what
80a05679d installed for PQsslAttribute:
you get OpenSSL's attributes if conn is NULL or is an SSL-encrypted
connection, or an empty list if conn is a non-encrypted connection.
The point of this is to have sensible connection-dependent behavior
in case we ever support multiple SSL libraries. The behavior for
NULL can be defined as "the attributes for the default SSL library",
parallel to what PQsslAttribute(NULL, "library") does.
Since this is mostly just future-proofing, no back-patch.
Discussion: https://postgr.es/m/17625-
fc47c78b7d71b534@postgresql.org
Alvaro Herrera [Fri, 30 Sep 2022 10:53:31 +0000 (12:53 +0200)]
Fix tab-completion after commit
790bf615ddba
I (Álvaro) broke tab-completion for GRANT .. ALL TABLES IN SCHEMA while
removing ALL from the publication syntax for schemas in the
aforementioned commit. I also missed to update a bunch of
tab-completion rules for ALTER/CREATE PUBLICATION that match each
individual piece of ALL TABLES IN SCHEMA. Repair those bugs.
While fixing up that commit, update a couple of outdated comments
related to the same change.
Backpatch to 15.
Author: Shi yu <shiy.fnst@fujitsu.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Discussion: https://postgr.es/m/OSZPR01MB6310FCE8609185A56344EED2FD559@OSZPR01MB6310.jpnprd01.prod.outlook.com
Daniel Gustafsson [Fri, 30 Sep 2022 10:03:48 +0000 (12:03 +0200)]
doc: Fix PQsslAttribute docs for compression
The compression parameter to PQsslAttribute has never returned the
compression method used, it has always returned "on" or "off since
it was added in commit
91fa7b4719ac. Backpatch through v10.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/
B9EC60EC-F665-47E8-A221-
398C76E382C9@yesql.se
Backpatch-through: v10
Michael Paquier [Fri, 30 Sep 2022 06:57:47 +0000 (15:57 +0900)]
Remove useless argument from UnpinBuffer()
The last caller of UnpinBuffer() that did not want to adjust
CurrentResourceOwner was removed in
2d115e4, and nothing has been
introduced in bufmgr.c to do the same thing since. This simplifies 10
code paths.
Author: Aleksander Alekseev
Reviewed-by: Nathan Bossart, Zhang Mingli, Bharath Rupireddy
Discussion: https://postgr.es/m/CAJ7c6TOmmFpb6ohurLhTC7hKNJWGzdwf8s4EAtAZxD48g-e6Jw@mail.gmail.com
Andres Freund [Thu, 29 Sep 2022 23:09:09 +0000 (16:09 -0700)]
ci: Add 32bit build and test
It's easy enough to make changes that break on 32bit platforms and few people
test that locally. Add a test for that to CI. LLVM is disabled on 32bit
because installing it would bloat the image size further.
The debian w/ meson task is fast enough that we can afford to test both.
Use the occasion of a separate run of the tests to run them under LANG=C,
we've recently discovered there's not a lot of testing in the buildfarm for
the case.
Discussion: https://postgr.es/m/
4033181.
1664395633@sss.pgh.pa.us
Tom Lane [Thu, 29 Sep 2022 21:28:09 +0000 (17:28 -0400)]
Fix bogus behavior of PQsslAttribute(conn, "library").
Commit
ebc8b7d44 intended to change the behavior of
PQsslAttribute(NULL, "library"), but accidentally also changed
what happens with a non-NULL conn pointer. Undo that so that
only the intended behavior change happens. Clarify some
associated documentation.
Per bug #17625 from Heath Lord. Back-patch to v15.
Discussion: https://postgr.es/m/17625-
fc47c78b7d71b534@postgresql.org
Tom Lane [Thu, 29 Sep 2022 17:27:48 +0000 (13:27 -0400)]
Improve wording of log messages triggered by max_slot_wal_keep_size.
The one about "terminating process to release replication slot" told
you nothing about why that was happening. The one about "invalidating
slot because its restart_lsn exceeds max_slot_wal_keep_size" told you
what was happening, but violated our message style guideline about
keeping the primary message short. Add DETAIL/HINT lines to carry
the appropriate detail and make the two cases more uniform.
While here, fix bogus test logic in 019_replslot_limit.pl: if it timed
out without seeing the expected log message, no test failure would be
reported. This is flat broken since commit
549ec201d removed the test
counts; even before that it was horribly bad style, since you'd only
get told that not all tests had been run.
Kyotaro Horiguchi, reviewed by Bertrand Drouvot; test fixes by me
Discussion: https://postgr.es/m/
20211214.130456.
2233153190058148084.horikyota.ntt@gmail.com
Tom Lane [Thu, 29 Sep 2022 16:14:39 +0000 (12:14 -0400)]
Use actual backend IDs in pg_stat_get_backend_idset() and friends.
Up to now, the ID values returned by pg_stat_get_backend_idset() and
used by pg_stat_get_backend_activity() and allied functions were just
indexes into a local array of sessions seen by the last stats refresh.
This is problematic for a few reasons. The "ID" of a session can vary
over its existence, which is surprising. Also, while these numbers
often match the "backend ID" used for purposes like temp schema
assignment, that isn't reliably true. We can fairly cheaply switch
things around to make these numbers actually be the sessions' backend
IDs. The added test case illustrates that with this definition, the
temp schema used by a given session can be obtained given its PID.
While here, delete some dead code that guarded against getting
a NULL return from pgstat_fetch_stat_local_beentry(). That can't
happen as long as the caller is careful to pass an in-range array
index, as all the callers are. (This code may not have been dead
when written, but it surely is now.)
Nathan Bossart
Discussion: https://postgr.es/m/
20220815205811.GA250990@nathanxps13
Etsuro Fujita [Thu, 29 Sep 2022 07:55:00 +0000 (16:55 +0900)]
Update comment in ExecInsert() regarding batch insertion.
Remove the stale text that is a leftover from an earlier version of the
patch to add support for batch insertion, and adjust the wording in the
remaining text.
Back-patch to v14 where batch insertion came in.
Review and wording adjustment by Tom Lane.
Discussion: https://postgr.es/m/CAPmGK14goatHPHQv2Aeu_UTKqZ%2BBO%2BP%2Bzd3HKv5D%2BdyyfWKDSw%40mail.gmail.com
Michael Paquier [Thu, 29 Sep 2022 06:05:40 +0000 (15:05 +0900)]
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, like an authentication method.
This commit implements SYSTEM_USER as of auth_method:identity, where
"auth_method" is a keyword about the authentication method used to log
into the server (like peer, md5, scram-sha-256, gss, etc.) and
"identity" is the authentication identity as introduced by
9afffcb (peer
sets authn to the OS user name, gss to the user principal, etc.). This
format has been suggested by Tom Lane.
Note that thanks to
d951052, SYSTEM_USER is available to parallel
workers.
Bump catalog version.
Author: Bertrand Drouvot
Reviewed-by: Jacob Champion, Joe Conway, Álvaro Herrera, Michael Paquier
Discussion: https://postgr.es/m/
7e692b8c-0b11-45db-1cad-
3afc5b57409f@amazon.com
Michael Paquier [Thu, 29 Sep 2022 05:28:13 +0000 (14:28 +0900)]
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, where the same flag is
tracked.
Author: Hayato Kuroda
Discussion: https://postgr.es/m/TYAPR01MB58669A9EC96AA3078C2CD938F5549@TYAPR01MB5866.jpnprd01.prod.outlook.com
Andres Freund [Thu, 29 Sep 2022 04:59:15 +0000 (21:59 -0700)]
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
it globally.
When UMDF_USING_NTSTATUS is defined we need to explicitly include ntstatus.h,
winternl.h to get a comparable set of symbols. Right now these includes would
be required in a number of non-platform-specific .c files - to avoid that,
include them in win32_port.h. Based on my measurements that doesn't increase
compile times measurably.
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/
20220927011951.j3h4o7n6bhf7dwau@awork3.anarazel.de
Andres Freund [Wed, 28 Sep 2022 21:21:43 +0000 (14:21 -0700)]
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.erzuk5v4ai4b53do@awork3.anarazel.de
Andres Freund [Wed, 28 Sep 2022 16:48:09 +0000 (09:48 -0700)]
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/
20220928022724.erzuk5v4ai4b53do@awork3.anarazel.de
Andres Freund [Tue, 27 Sep 2022 19:01:35 +0000 (12:01 -0700)]
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., when
building on windows with msvc.
This isn't perfect, e.g., clang works on windows as well. But I suspect we'd
need a bunch of other changes to make clang on windows work, and we haven't
supported it historically.
Discussion: http://postgr.es/m/
20220928022724.erzuk5v4ai4b53do@awork3.anarazel.de
Andres Freund [Tue, 27 Sep 2022 18:55:00 +0000 (11:55 -0700)]
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 tests to fail.
Reported-by: Melih Mutlu <m.melihmutlu@gmail.com>
Discussion: http://postgr.es/m/
20220928022724.erzuk5v4ai4b53do@awork3.anarazel.de
Michael Paquier [Thu, 29 Sep 2022 01:14:47 +0000 (10:14 +0900)]
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
Discussion: https://postgr.es/m/CALj2ACWet-b8Juba0DiXwfGCyyOcohzwksahE5ebB9rcbLZKCQ@mail.gmail.com
Thomas Munro [Thu, 29 Sep 2022 00:12:11 +0000 (13:12 +1300)]
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 that Windows also
changes the current position even when you pass in an offset to
ReadFile() and WriteFile() if the file handle is synchronous, despite
its documentation saying otherwise.
Switching to asynchronous file handles would fix that, but have other
complications. For now let's just put back the pg_ prefix and add some
comments to highlight the non-standard side-effect, which we can now
describe as Windows-only.
Reported-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/
20220923202439.GA1156054%40nathanxps13
David Rowley [Wed, 28 Sep 2022 22:43:00 +0000 (11:43 +1300)]
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 byref type. Ronan Dunklau did originally
propose the patch with that restriction, but that, probably through my own
fault, got lost during further development work.
Due to the timing of this report (PG15 RC1 is almost out the door), let's
just restrict the datum sort optimization to apply for byval types only.
We might want to look harder into making this work for byref types in
PG16.
Reported-by: Önder Kalacı
Diagnosis-by: Tom Lane
Discussion: https://postgr.es/m/CACawEhVxe0ufR26UcqtU7GYGRuubq3p6ZWPGXL4cxy_uexpAAQ@mail.gmail.com
Backpatch-through: 15, where
91e9e89dc was introduced.
Bruce Momjian [Wed, 28 Sep 2022 17:14:38 +0000 (13:14 -0400)]
doc: clarify internal behavior of RECURSIVE CTE queries
Reported-by: Tom Lane
Discussion: https://postgr.es/m/
3976627.
1662651004@sss.pgh.pa.us
Backpatch-through: 10
Bruce Momjian [Wed, 28 Sep 2022 17:05:21 +0000 (13:05 -0400)]
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-3222-87d3-
0def8057d7d8@enterprisedb.com
Backpatch-through: 10
Tom Lane [Wed, 28 Sep 2022 16:31:36 +0000 (12:31 -0400)]
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 varchar
types relate. The previous wording seemed to be doing its best
to sweep text under the rug, which doesn't seem very appropriate
given its prominence in other parts of the docs.
Minor rearrangements and word-smithing for clarity, too.
Laurenz Albe and Tom Lane, per gripe from Yanliang Lei
Discussion: https://postgr.es/m/
120b3084.56b6.
1833b5ffe4b.Coremail.msdnchina@163.com
Tom Lane [Wed, 28 Sep 2022 15:23:14 +0000 (11:23 -0400)]
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, CallSubXactCallbacks, and
ResourceOwnerReleaseInternal. (There are some other places that
might be at hazard if they offered deregistration functionality,
but they don't.)
I (tgl) considered back-patching this, but desisted because it
wouldn't be very safe for extensions to rely on this working in
pre-v16 branches.
Hao Wu
Discussion: https://postgr.es/m/CAH+9SWXTiERkmhRke+QCcc+jRH8d5fFHTxh8ZK0-Yn4BSpyaAg@mail.gmail.com
Alvaro Herrera [Wed, 28 Sep 2022 15:14:53 +0000 (17:14 +0200)]
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
translation.
Backpatch all the way back as appropriate. None of this is caught by
any tests (necessarily so), so I verified it manually.
Robert Haas [Wed, 28 Sep 2022 14:42:07 +0000 (10:42 -0400)]
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://postgr.es/m/CAGPqQf2vO+nbo=3yAdZ8v26Rbug7bY4YjPaPLZx=L1NZ9-CC3w@mail.gmail.com
Robert Haas [Wed, 28 Sep 2022 13:45:27 +0000 (09:45 -0400)]
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 RelFileLocator. The effect of that
hasn't been studied or discussed, so revert for now.
Robert Haas [Wed, 28 Sep 2022 12:02:30 +0000 (08:02 -0400)]
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.
Dilip Kumar
Discussion: http://postgr.es/m/CAFiTN-t71ciSckMzixAhrF9py7oRO6xszKi4mTRwjuucXr5tpw@mail.gmail.com
Robert Haas [Wed, 28 Sep 2022 11:51:48 +0000 (07:51 -0400)]
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 that gets
packed into a commit record requires only 4-byte alignment.
Another problem with
05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c.
Discussion: http://postgr.es/m/
3825454.
1664310917@sss.pgh.pa.us
Alvaro Herrera [Wed, 28 Sep 2022 11:47:25 +0000 (13:47 +0200)]
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
Michael Paquier [Wed, 28 Sep 2022 00:58:44 +0000 (09:58 +0900)]
Fix some comments of do_pg_backup_start() and do_pg_backup_stop()
Both functions referred to an incorrect variable name, so make the whole
more consistent.
Oversight in
7d70809.
Author: Kyotaro Horiguchi, Bharath Rupireddy
Discussion: https://postgr.es/m/
20220927.172427.
467118514018439476.horikyota.ntt@gmail.com
Robert Haas [Tue, 27 Sep 2022 20:12:43 +0000 (16:12 -0400)]
In BufTagGetForkNum, cast to the correct type.
Another defect in
05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c.
Per CI, via Justin Pryzby.
Discussion: http://postgr.es/m/
20220927200712.GH6256@telsasoft.com
Robert Haas [Tue, 27 Sep 2022 19:31:36 +0000 (15:31 -0400)]
Update pg_buffercache's meson.build.
Commit
05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c needed to do this,
but didn't.
Per Justin Pryzby.
Discussion:
20220927191710.GG6256@telsasoft.com
Robert Haas [Tue, 27 Sep 2022 19:13:34 +0000 (15:13 -0400)]
Fix typos in commit
05d4cbf9b6ba708858984b01ca0fc56d59d4ec7c.
Reported by Justin Pryzby.
Discussion: http://postgr.es/m/
20220927185121.GE6256@telsasoft.com
Peter Eisentraut [Tue, 27 Sep 2022 18:47:07 +0000 (20:47 +0200)]
Convert *GetDatum() and DatumGet*() macros to inline functions
The previous macro implementations just cast the argument to a target
type but did not check whether the input type was appropriate. The
function implementation can do better type checking of the input type.
For the *GetDatumFast() macros, converting to an inline function
doesn't work in the !USE_FLOAT8_BYVAL case, but we can use
AssertVariableIsOfTypeMacro() to get a similar level of type checking.
Reviewed-by: Aleksander Alekseev <aleksander@timescale.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
8528fb7e-0aa2-6b54-85fb-
0c0886dbd6ed%40enterprisedb.com
Robert Haas [Tue, 27 Sep 2022 17:34:23 +0000 (13:34 -0400)]
Include common/relpath.h in utils/relfilenumbermap.h
Buildfarm member crake ran headerscheck, which complained about
a missing include here.
Defect introduced by commit
2f47715cc8649f854b1df28dfc338af9801db217.
Robert Haas [Tue, 27 Sep 2022 17:25:21 +0000 (13:25 -0400)]
Increase width of RelFileNumbers from 32 bits to 56 bits.
RelFileNumbers are now assigned using a separate counter, instead of
being assigned from the OID counter. This counter never wraps around:
if all 2^56 possible RelFileNumbers are used, an internal error
occurs. As the cluster is limited to 2^64 total bytes of WAL, this
limitation should not cause a problem in practice.
If the counter were 64 bits wide rather than 56 bits wide, we would
need to increase the width of the BufferTag, which might adversely
impact buffer lookup performance. Also, this lets us use bigint for
pg_class.relfilenode and other places where these values are exposed
at the SQL level without worrying about overflow.
This should remove the need to keep "tombstone" files around until
the next checkpoint when relations are removed. We do that to keep
RelFileNumbers from being recycled, but now that won't happen
anyway. However, this patch doesn't actually change anything in
this area; it just makes it possible for a future patch to do so.
Dilip Kumar, based on an idea from Andres Freund, who also reviewed
some earlier versions of the patch. Further review and some
wordsmithing by me. Also reviewed at various points by Ashutosh
Sharma, Vignesh C, Amul Sul, Álvaro Herrera, and Tom Lane.
Discussion: http://postgr.es/m/CA+Tgmobp7+7kmi4gkq7Y+4AM9fTvL+O1oQ4-5gFTT+6Ng-dQ=g@mail.gmail.com
Robert Haas [Tue, 27 Sep 2022 16:01:57 +0000 (12:01 -0400)]
Move RelFileNumber declarations to common/relpath.h.
Previously, these were declared in postgres_ext.h, but they are not
needed nearly so widely as the OID declarations, so that doesn't
necessarily make sense. Also, because postgres_ext.h is included
before most of c.h has been processed, the previous location creates
some problems for a pending patch.
Patch by me, reviewed by Dilip Kumar.
Discussion: http://postgr.es/m/CA+TgmoYc8oevMqRokZQ4y_6aRn-7XQny1JBr5DyWR_jiFtONHw@mail.gmail.com
Tom Lane [Tue, 27 Sep 2022 15:51:06 +0000 (11:51 -0400)]
Renumber GUC flags for a bit more sanity.
Push the units fields over to the left so that all the single-bit
flags can be together. I considered rearranging the single-bit
flags to try to group flags with similar purposes, but eventually
decided that that involved too many judgment calls.
Discussion: https://postgr.es/m/17385-
9ee529fb091f0ce5@postgresql.org
Tom Lane [Tue, 27 Sep 2022 15:47:12 +0000 (11:47 -0400)]
Introduce GUC_NO_RESET flag.
Previously, the transaction-property GUCs such as transaction_isolation
could be reset after starting a transaction, because we marked them
as GUC_NO_RESET_ALL but still allowed a targeted RESET. That leads to
assertion failures or worse, because those properties aren't supposed
to change after we've acquired a transaction snapshot.
There are some NO_RESET_ALL variables for which RESET is okay, so
we can't just redefine the semantics of that flag. Instead introduce
a separate GUC_NO_RESET flag. Mark "seed", as well as the transaction
property GUCs, as GUC_NO_RESET.
We have to disallow GUC_ACTION_SAVE as well as straight RESET, because
otherwise a function having a "SET transaction_isolation" clause can
still break things: the end-of-function restore action is equivalent
to a RESET.
No back-patch, as it's conceivable that someone is doing something
this patch will forbid (like resetting one of these GUCs at transaction
start, or "CREATE FUNCTION ... SET transaction_read_only = 1") and not
running into problems with it today. Given how long we've had this
issue and not noticed, the side effects in non-assert builds can't be
too serious.
Per bug #17385 from Andrew Bille.
Masahiko Sawada
Discussion: https://postgr.es/m/17385-
9ee529fb091f0ce5@postgresql.org
Alvaro Herrera [Tue, 27 Sep 2022 12:11:31 +0000 (14:11 +0200)]
Improve some publication-related error messages
While at it, remove an unused queryString parameter from
CheckPubRelationColumnList() and make other minor stylistic changes.
Backpatch to 15.
Reported by Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Co-authored-by: Hou zj <houzj.fnst@fujitsu.com>
Discussion: https://postgr.es/m/
20220926.160426.
454497059203258582.horikyota.ntt@gmail.com
Alvaro Herrera [Tue, 27 Sep 2022 08:44:42 +0000 (10:44 +0200)]
Fix pg_stat_statements for MERGE
We weren't jumbling the merge action list, so wildly different commands
would be considered to use the same query ID. Add that, mention it in
the docs, and some test lines.
Backpatch to 15.
Author: Tatsu <bt22nakamorit@oss.nttdata.com>
Reviewed-by: Julien Rouhaud <rjuju123@gmail.com>
Discussion: https://postgr.es/m/
d87e391694db75a038abc3b2597828e8@oss.nttdata.com
Andres Freund [Tue, 27 Sep 2022 03:02:26 +0000 (20:02 -0700)]
ci: Add hint about downloadable logs to README
I (Andres) chose to backpatch this to 15, as it seems better to keep the
README the same.
Author: James Coleman <jtc331@gmail.com>
Discussion: https://postgr.es/m/CAAaqYe_7BXDjpk0Ks_eqf1r6LZpC_rfB7kjhb_T3+eC4t6yiGQ@mail.gmail.com
Backpatch: 15-, where CI came in
Andres Freund [Tue, 27 Sep 2022 02:44:05 +0000 (19:44 -0700)]
meson: Set up absolute rpaths to libdir
While I (Andres) had planned to use relative rpaths, it looks like agreeing on
the precise path might take a bit. So set up absolute rpaths for now.
I'm pushing this fairly quickly after posting the patch as several hackers
fought with this issue.
Discussion: https://postgr.es/m/
20220927011951.j3h4o7n6bhf7dwau@awork3.anarazel.de
Andres Freund [Tue, 27 Sep 2022 02:36:24 +0000 (19:36 -0700)]
meson: Include CFLAGS/c_args in summary and pg_config output
Previously arguments passed in via CFLAGS/-Dc_args were neither displayed in
meson's summary, nor in pg_config's output.
Reported-by: "wangw.fnst@fujitsu.com" <wangw.fnst@fujitsu.com>
Discussion: https://postgr.es/m/OS3PR01MB62751847BC9CD2DB7B29AC129E529@OS3PR01MB6275.jpnprd01.prod.outlook.com
Michael Paquier [Tue, 27 Sep 2022 00:29:56 +0000 (09:29 +0900)]
Mark ParallelMessagePending as sig_atomic_t
ParallelMessagePending was previously marked as a boolean which should
be fine on modern platforms, but the C standard recommends the use of
sig_atomic_t for variables manipulated in signal handlers.
Author: Hayato Kuroda
Discussion: https://postgr.es/m/TYAPR01MB58667C15A95A234720F4F876F5529@TYAPR01MB5866.jpnprd01.prod.outlook.com
Michael Paquier [Tue, 27 Sep 2022 00:15:07 +0000 (09:15 +0900)]
Remove dependency to StringInfo in xlogbackup.{c.h}
This was used as the returned result type of the generated contents for
the backup_label and backup history files. This is replaced by a simple
string, reducing the cleanup burden of all the callers of
build_backup_content().
Reviewed-by: Bharath Rupireddy
Discussion: https://postgr.es/m/YzERvNPaZivHEKZJ@paquier.xyz
Andres Freund [Mon, 26 Sep 2022 18:38:02 +0000 (11:38 -0700)]
windows: remove date from version number in win32ver.rc
This may have served a purpose at some point, but these days it just
contributes to a non-reproducible build.
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/
c5736f70-bb6d-8d25-e35c-
e3d886e4e905@enterprisedb.com
Discussion: https://postgr.es/m/
1cef5b48-32bd-5cbf-fb62-
fb648860f5ef@enterprisedb.com
Tom Lane [Mon, 26 Sep 2022 18:19:21 +0000 (14:19 -0400)]
Doc: further adjust notes about pg_upgrade_output.d.
I'd misunderstood how it worked in
5f1048881.
Discussion: https://postgr.es/m/
20220925215009.GC21938@telsasoft.com
Tom Lane [Mon, 26 Sep 2022 14:32:16 +0000 (16:32 +0200)]
Enable WRITE_READ_PARSE_PLAN_TREES of rewritten utility statements
This was previously disabled because we lacked outfuncs/readfuncs
support for most utility statement types.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Tom Lane [Mon, 26 Sep 2022 14:32:16 +0000 (16:32 +0200)]
Implement WRITE_READ_PARSE_PLAN_TREES for raw parse trees
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Peter Eisentraut [Mon, 26 Sep 2022 14:02:09 +0000 (16:02 +0200)]
Don't lose precision for float fields of Nodes.
Historically we've been more worried about making the output of
float fields look pretty than whether they'd be read back exactly.
That won't work if we're to compare the read-back nodes for
equality, so switch to using the Ryu code for float output.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Peter Eisentraut [Mon, 26 Sep 2022 13:56:47 +0000 (15:56 +0200)]
Peter Eisentraut [Mon, 26 Sep 2022 13:25:59 +0000 (15:25 +0200)]
Fix write/read of empty string fields in Nodes.
Historically, outToken has represented both NULL and empty-string
strings as "<>", which readfuncs.c then read as NULL, thus failing
to preserve empty-string fields accurately. Remarkably, this has
not caused any serious problems yet, but let's fix it.
We'll keep the "<>" notation for NULL, and use """" for empty string,
because that matches other notational choices already in use.
An actual input string of """" is converted to "\""" (this was true
already, apparently as a hangover from an ancient time when string
quoting was handled directly by pg_strtok).
CHAR fields also use "<>", but for '\0'.
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Amit Kapila [Mon, 26 Sep 2022 03:17:00 +0000 (08:47 +0530)]
Remove unused xid parameter.
Commit
6c2003f8a1 removes the use of transaction id's for exporting
snapshots. This commit removes one unused xid parameter left behind in
SnapBuildGetOrBuildSnapshot.
Author: Melih Mutlu
Reviewed-By: Zhang Mingli
Discussion: https://postgr.es/m/CAGPVpCTqZRoDKgCycw+eYi+Gq41rN9pU-gntgTd7wfsNDpPL3Q@mail.gmail.com
Michael Paquier [Mon, 26 Sep 2022 02:15:47 +0000 (11:15 +0900)]
Refactor creation of backup_label and backup history files
This change simplifies some of the logic related to the generation and
creation of the backup_label and backup history files, which has become
unnecessarily complicated since the removal of the exclusive backup mode
in commit
39969e2. The code was previously generating the contents of
these files as a string (start phase for the backup_label and stop phase
for the backup history file), one problem being that the contents of the
backup_label string were scanned to grab some of its internal contents
at the stop phase.
This commit changes the logic so as we store the data required to build
these files in an intermediate structure named BackupState. The
backup_label file and backup history file strings are generated when
they are ready to be sent back to the client. Both files are now
generated with the same code path. While on it, this commit renames
some variables for clarity.
Two new files named xlogbackup.{c,h} are introduced in this commit, to
remove from xlog.c some of the logic around base backups. Note that
more could be moved to this new set of files.
Author: Bharath Rupireddy, Michael Paquier
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/CALj2ACXWwTDgJqCjdaPyfR7djwm6SrybGcrZyrvojzcsmt4FFw@mail.gmail.com
Tom Lane [Sun, 25 Sep 2022 21:10:58 +0000 (17:10 -0400)]
Fix tupdesc lifespan bug with AfterTriggersTableData.storeslot.
Commit
25936fd46 adjusted things so that the "storeslot" we use
for remapping trigger tuples would have adequate lifespan, but it
neglected to consider the lifespan of the tuple descriptor that
the slot depends on. It turns out that in at least some cases, the
tupdesc we are passing is a refcounted tupdesc, and the refcount for
the slot's reference can get assigned to a resource owner having
different lifespan than the slot does. That leads to an error like
"tupdesc reference 0x7fdef236a1b8 is not owned by resource owner
SubTransaction". Worse, because of a second oversight in the same
commit, we'd try to free the same tupdesc refcount again while
cleaning up after that error, leading to recursive errors and an
"ERRORDATA_STACK_SIZE exceeded" PANIC.
To fix the initial problem, let's just make a non-refcounted copy
of the tupdesc we're supposed to use. That seems likely to guard
against additional problems, since there's no strong reason for
this code to assume that what it's given is a refcounted tupdesc;
in which case there's an independent hazard of the tupdesc having
shorter lifespan than the slot does. (I didn't bother trying to
free said copy, since it should go away anyway when the (sub)
transaction context is cleaned up.)
The other issue can be fixed by making the code added to
AfterTriggerFreeQuery work like the rest of that function, ie be
sure that it doesn't try to free the same slot twice in the event
of recursive error cleanup.
While here, also clean up minor stylistic issues in the test case
added by
25936fd46: don't use "create or replace function", as any
name collision within the tests is likely to have ill effects
that that won't mask; and don't use function names as generic as
trigger_function1, especially if you're not going to drop them
at the end of the test stanza.
Per bug #17607 from Thomas Mc Kay. Back-patch to v12, as the
previous fix was.
Discussion: https://postgr.es/m/17607-
bd8ccc81226f7f80@postgresql.org
Tom Lane [Sun, 25 Sep 2022 17:10:10 +0000 (13:10 -0400)]
Avoid loss of code coverage with unlogged-index test cases.
Commit
4fb5c794e intended to add coverage of some ambuildempty
methods that were not getting reached, without removing any
test coverage. However, by changing a temp table to unlogged
it managed to negate the intent of
4c51a2d1e, which means that
we didn't have reliable test coverage of ginvacuum.c anymore.
As things stand, much of that file might or might not get reached
depending on timing, which seems pretty undesirable.
Although this is only clearly broken for the GIN test, it seems
best to revert
4fb5c794e altogether and instead add bespoke test
cases covering unlogged indexes for these four AMs. We don't
need to do very much with them, so the extra tests are cheap.
(Note that btree, hash, and bloom already have similar test cases,
so they need no additional work.)
We can also undo
dec8ad367. Since the testing deficiency that that
hacked around was later fixed by
2f2e24d90, let's intentionally leave
an unlogged table behind to improve test coverage in the modules that
use the regression database for other test purposes. (The case I used
also leaves an unlogged sequence behind.)
Per report from Alex Kozhemyakin. Back-patch to v15 where the
faulty test came in.
Discussion: https://postgr.es/m/
b00c8ee096ee46cd25c183125562a1a7@postgrespro.ru
Alvaro Herrera [Sun, 25 Sep 2022 15:48:03 +0000 (17:48 +0200)]
Add missing source files to pg_waldump/nls.mk
Peter Eisentraut [Sat, 24 Sep 2022 22:38:35 +0000 (18:38 -0400)]
Message style improvements
Peter Eisentraut [Sat, 24 Sep 2022 22:18:33 +0000 (18:18 -0400)]
Add read support for some missing raw parse nodes
The node types A_Const, Constraint, and A_Expr had custom output
functions, but no read functions were implemented so far.
The A_Expr output format had to be tweaked a bit to make it easier to
parse.
Be a bit more cautious about applying strncmp to unterminated strings.
Also error out if an unrecognized enum value is found in each case,
instead of just printing a placeholder value. That was maybe ok for
debugging but won't work if we want to have robust round-tripping.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Peter Eisentraut [Sat, 24 Sep 2022 22:10:52 +0000 (18:10 -0400)]
Fix reading of BitString nodes
The node tokenizer went out of its way to store BitString node values
without the leading 'b'. But everything else in the system stores the
leading 'b'. This would break if a BitString node is
read-printed-read.
Also, the node tokenizer didn't know that BitString node tokens could
also start with 'x'.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Peter Eisentraut [Sat, 24 Sep 2022 22:10:11 +0000 (18:10 -0400)]
Fix reading of most-negative integer value nodes
The main parser checks whether a literal fits into an int when
deciding whether it should be put into an Integer or Float node. The
parser processes integer literals without signs. So a most-negative
integer literal will not fit into Integer and will end up as a Float
node.
The node tokenizer did this differently. It included the sign when
checking whether the literal fit into int. So a most-negative integer
would indeed fit that way and end up as an Integer node.
In order to preserve the node structure correctly, we need the node
tokenizer to also analyze integer literals without sign.
There are a number of test cases in the regression tests that have a
most-negative integer argument of some utility statement, so this
issue is easily reproduced under WRITE_READ_PARSE_PLAN_TREES.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
4159834.
1657405226@sss.pgh.pa.us
Andres Freund [Sat, 24 Sep 2022 19:01:06 +0000 (12:01 -0700)]
Remove uses of register due to incompatibility with C++17 and up
The use in regexec.c could remain, since we only try to keep headers C++
clean. But there really doesn't seem to be a good reason to use register in
that spot.
Discussion: https://postgr.es/m/
20220308185902.ibdqmasoaunzjrfc@alap3.anarazel.de
Andres Freund [Sat, 24 Sep 2022 19:04:56 +0000 (12:04 -0700)]
De-special-case pgevent's rc file handling
There's really no need to build win32ver.rc as part of building
pgmsgevent.rc. This will make it sligthly easier to add rc file generation to
the meson build.
Andres Freund [Sat, 24 Sep 2022 18:29:29 +0000 (11:29 -0700)]
meson: Remove non-binary targets accidentally added to bin_targets
Peter Eisentraut [Sat, 24 Sep 2022 01:16:08 +0000 (21:16 -0400)]
Improve terminology
Use "prepared transaction" instead of "two-phrase transaction". This
is in line with
0e60a50e0bf158bead247731e00cee95bcf64daf.
Tom Lane [Fri, 23 Sep 2022 22:20:11 +0000 (18:20 -0400)]
Doc: minor cleanups.
Improve a couple of things I noticed while working on v15
release notes.
Andres Freund [Fri, 23 Sep 2022 20:00:55 +0000 (13:00 -0700)]
pgstat: Fix transactional stats dropping for indexes
Because index creation does not go through heap_create_with_catalog() we
didn't call pgstat_create_relation(), leading to index stats of a newly
created realtion not getting dropped during rollback. To fix, move the
pgstat_create_relation() to heap_create(), which indexes do use.
Similarly, because dropping an index does not go through
heap_drop_with_catalog(), we didn't drop index stats when the transaction
dropping an index committed. Here there's no convenient common path for
indexes and relations, so index_drop() now calls pgstat_drop_relation().
Add tests for transactional index stats handling.
Author: "Drouvot, Bertrand" <bdrouvot@amazon.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/
51bbf286-2b4a-8998-bd12-
eaae4b765d99@amazon.com
Backpatch: 15-, like
8b1dccd37c71, which introduced the bug
Alvaro Herrera [Fri, 23 Sep 2022 16:21:22 +0000 (18:21 +0200)]
Remove PQsendQuery support in pipeline mode
The extended query protocol implementation I added in commit
acb7e4eb6b1c has bugs when used in pipeline mode. Rather than spend
more time trying to fix it, remove that code and make the function rely
on simple query protocol only, meaning it can no longer be used in
pipeline mode.
Users can easily change their applications to use PQsendQueryParams
instead. We leave PQsendQuery in place for Postgres 14, just in case
somebody is using it and has not hit the mentioned bugs; but we should
recommend that it not be used.
Backpatch to 15.
Per bug report from Gabriele Varrazzo.
Discussion: https://postgr.es/m/CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
Alvaro Herrera [Fri, 23 Sep 2022 16:11:48 +0000 (18:11 +0200)]
Stop using PQsendQuery in libpq_pipeline
The "emulation" I wrote for PQsendQuery in pipeline mode to use extended
query protocol, in commit
acb7e4eb6b1c, is problematic. Due to numerous
bugs we'll soon remove it. As a first step and for all branches back to
14, stop using PQsendQuery in libpq_pipeline. Also remove a few test
lines that will no longer be relevant.
Backpatch to 14.
Discussion: https://postgr.es/m/CA+mi_8ZGSQNmW6-mk_iSR4JZB_LJ4ww3suOF+1vGNs3MrLsv4g@mail.gmail.com
Andres Freund [Fri, 23 Sep 2022 03:36:28 +0000 (20:36 -0700)]
ci: freebsd: Set extra_{lib,include}_dirs to /usr/local/...
Ommitted in
e6b6ea025cc, but necessary for libintl to be found. All other
dependencies can be found via pkg-config (which searches in /usr/local/...)
and thus worked even without adding the directories.
Amit Kapila [Fri, 23 Sep 2022 02:51:26 +0000 (08:21 +0530)]
Allow publications with schema and table of the same schema.
We previously thought that allowing such cases can confuse users when they
specify DROP TABLES IN SCHEMA but that doesn't seem to be the case based
on discussion. This helps to uplift the restriction during
ALTER TABLE ... SET SCHEMA which used to ensure that we couldn't end up
with a publication having both a schema and the same schema's table.
To allow this, we need to forbid having any schema on a publication if
column lists on a table are specified (and vice versa). This is because
otherwise we still need a restriction during ALTER TABLE ... SET SCHEMA to
forbid cases where it could lead to a publication having both a schema and
the same schema's table with column list.
Based on suggestions by Peter Eisentraut.
Author: Hou Zhijie and Vignesh C
Reviewed-By: Peter Smith, Amit Kapila
Backpatch-through: 15, where it was introduced
Discussion: https://postgr.es/m/
2729c9e2-9aac-8cda-f2f4-
34f2bcc18f4e@enterprisedb.com
Tom Lane [Fri, 23 Sep 2022 02:05:09 +0000 (22:05 -0400)]
Doc: adjust misleading phrasing of a few cross-references.
The pg_dump and pg_dumpall man pages referred to app-psql-patterns
as appearing "below", which I suspect was copied-and-pasted from
equivalent text in psql-ref.sgml rather than being actually thought
through. At least to me, that phrasing means "later in this same
web page/section", which this link target is not. Drop the
misleading and unnecessary-in-any-case adjective.
Peter Geoghegan [Thu, 22 Sep 2022 23:41:23 +0000 (16:41 -0700)]
Harmonize parameter names in pg_dump/pg_dumpall.
Make sure that function declarations use names that exactly match the
corresponding names from function definitions in pg_dump/pg_dumpall
related code.
Affected code happens to be inconsistent in how it applies conventions
around how Archive and Archive Handle variables are named. Significant
code churn is required to fully fix those inconsistencies, so take the
least invasive approach possible: treat function definition names as
authoritative, and mechanically adjust corresponding names from function
definitions to match.
Like other recent commits that cleaned up function parameter names, this
commit was written with help from clang-tidy.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAH2-Wzmma+vzcO6gr5NYDZ+sx0G14aU-UrzFutT2FoRaisVCUQ@mail.gmail.com
Peter Geoghegan [Thu, 22 Sep 2022 20:59:20 +0000 (13:59 -0700)]
Harmonize parameter names in contrib code.
Make sure that function declarations use names that exactly match the
corresponding names from function definitions in contrib code.
Like other recent commits that cleaned up function parameter names, this
commit was written with help from clang-tidy.
Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
Peter Geoghegan [Thu, 22 Sep 2022 20:27:16 +0000 (13:27 -0700)]
Harmonize more lexer function parameter names.
Make sure that function declarations use names that exactly match the
corresponding names from function definitions for several "lexer
adjacent" backend functions. These were missed by commit
aab06442.
Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
Peter Geoghegan [Thu, 22 Sep 2022 19:53:20 +0000 (12:53 -0700)]
Harmonize parameter names in ecpg code.
Make ecpg function declarations consistently use named parameters. Also
make sure that the declarations use names that match corresponding names
from function definitions.
Like other recent commits that cleaned up function parameter names, this
commit was written with help from clang-tidy.
Author: Peter Geoghegan <pg@bowt.ie>
Reviewed-By: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/CAH2-WznJt9CMM9KJTMjJh_zbL5hD9oX44qdJ4aqZtjFi-zA3Tg@mail.gmail.com
Jeff Davis [Thu, 22 Sep 2022 17:58:49 +0000 (10:58 -0700)]
Fix race condition where heap_delete() fails to pin VM page.
Similar to
5f12bc94dc, the code must re-check PageIsAllVisible() after
buffer lock is re-acquired. Backpatching to the same version, 12.
Discussion: https://postgr.es/m/CAEP4nAw9jYQDKd_5Y+-s2E4YiUJq1vqiikFjYGpLShtp-K3gag@mail.gmail.com
Reported-by: Robins Tharakan
Reviewed-by: Robins Tharakan
Backpatch-through: 12
Alvaro Herrera [Thu, 22 Sep 2022 17:02:25 +0000 (19:02 +0200)]
Remove ALL keyword from TABLES IN SCHEMA for publication
This may be a bit too subtle, but removing that word from there makes
this clause no longer a perfect parallel of the GRANT variant "ALL
TABLES IN SCHEMA": indeed, for publications what we record is the schema
itself, not the tables therein, which means that any tables added to the
schema in the future are also published. This is completely different
to what GRANT does, which is affect only the tables that exist when the
command is executed.
There isn't resounding support for this change, but there are a few
positive votes and no opposition. Because the time to 15 RC1 is very
short, let's get this out now.
Backpatch to 15.
Discussion: https://postgr.es/m/
2729c9e2-9aac-8cda-f2f4-
34f2bcc18f4e
Peter Eisentraut [Sat, 17 Sep 2022 09:34:20 +0000 (11:34 +0200)]
Restore archive_command documentation
Commit
5ef1eefd76f404ddc59b885d50340e602b70f05f, which added
archive_library, purged most mentions of archive_command from the
documentation. This is inappropriate, since archive_command is still
a feature in use and users will want to see information about it.
This restores all the removed mentions and rephrases things so that
archive_command and archive_library are presented as alternatives of
each other.
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Discussion: https://www.postgresql.org/message-id/
9366d634-a917-85a9-4991-
b2a4859edaf9@enterprisedb.com
Michael Paquier [Thu, 22 Sep 2022 11:02:40 +0000 (20:02 +0900)]
Use min/max bounds defined by Zstd for compression level
The bounds hardcoded in compression.c since
ffd5365 (minimum at 1 and
maximum at 22) do not match the reality of what zstd is able to
handle, these values being available via ZSTD_maxCLevel() and
ZSTD_minCLevel() at run-time. The maximum of 22 is actually correct
in recent versions, but the minimum was not as the library can go down
to -131720 by design. This commit changes the code to use the run-time
values in the code instead of some hardcoded ones.
Zstd seems to assume that these bounds could change in the future, and
Postgres will be able to adapt automatically to such changes thanks to
what's being done in this commit.
Reported-by: Justin Prysby
Discussion: https://postgr.es/m/
20220922033716.GL31833@telsasoft.com
Backpatch-through: 15
Etsuro Fujita [Thu, 22 Sep 2022 06:55:00 +0000 (15:55 +0900)]
Fix thinko in comment.
This comment has been wrong since its introduction in commit
0d5f05cde;
backpatch to v12 where that came in.
Discussion: https://postgr.es/m/CAPmGK14VGf-xQjGQN4o1QyAbXAaxugU5%3DqfcmTDh1iufUDnV_w%40mail.gmail.com
Andres Freund [Thu, 22 Sep 2022 04:53:18 +0000 (21:53 -0700)]
meson: ci: Convert some tasks to use meson
The Windows task is changed to use meson as there currently is no way to run
all tests in the old MSVC build system (only ninja is covered for now, we
don't have enough CI resources to test msbuild as well).
To maintain autoconf coverage, the Linux task is duplicated to test both meson
and autoconf builds (linux is currently the fastest task). FreeBSD and macOS
are also converted to meson, as it seems more important to have coverage for
meson than autoconf.
Author: Andres Freund <andres@anarazel.de>
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Justin Pryzby <pryzby@telsasoft.com>
Andres Freund [Thu, 22 Sep 2022 04:53:12 +0000 (21:53 -0700)]
meson: Add initial version of meson based build system
Autoconf is showing its age, fewer and fewer contributors know how to wrangle
it. Recursive make has a lot of hard to resolve dependency issues and slow
incremental rebuilds. Our home-grown MSVC build system is hard to maintain for
developers not using Windows and runs tests serially. While these and other
issues could individually be addressed with incremental improvements, together
they seem best addressed by moving to a more modern build system.
After evaluating different build system choices, we chose to use meson, to a
good degree based on the adoption by other open source projects.
We decided that it's more realistic to commit a relatively early version of
the new build system and mature it in tree.
This commit adds an initial version of a meson based build system. It supports
building postgres on at least AIX, FreeBSD, Linux, macOS, NetBSD, OpenBSD,
Solaris and Windows (however only gcc is supported on aix, solaris). For
Windows/MSVC postgres can now be built with ninja (faster, particularly for
incremental builds) and msbuild (supporting the visual studio GUI, but
building slower).
Several aspects (e.g. Windows rc file generation, PGXS compatibility, LLVM
bitcode generation, documentation adjustments) are done in subsequent commits
requiring further review. Other aspects (e.g. not installing test-only
extensions) are not yet addressed.
When building on Windows with msbuild, builds are slower when using a visual
studio version older than 2019, because those versions do not support
MultiToolTask, required by meson for intra-target parallelism.
The plan is to remove the MSVC specific build system in src/tools/msvc soon
after reaching feature parity. However, we're not planning to remove the
autoconf/make build system in the near future. Likely we're going to keep at
least the parts required for PGXS to keep working around until all supported
versions build with meson.
Some initial help for postgres developers is at
https://wiki.postgresql.org/wiki/Meson
With contributions from Thomas Munro, John Naylor, Stone Tickle and others.
Author: Andres Freund <andres@anarazel.de>
Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
Author: Peter Eisentraut <peter@eisentraut.org>
Reviewed-By: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/
20211012083721.hvixq4pnh2pixr3j@alap3.anarazel.de
Michael Paquier [Thu, 22 Sep 2022 05:25:09 +0000 (14:25 +0900)]
Clear ps display of startup process at the end of recovery
If the ps display is not cleared at this point, the process could
continue displaying "recovering NNN" even if handling end-of-recovery
steps.
df9274a has tackled that by providing some information with the
end-of-recovery checkpoint but
7ff23c6 has nullified the effect of the
first commit.
Per a suggestion from Justin, just clear the ps display when we are done
with recovery, so as no incorrect information is displayed. This may
get extended in the future, but for now restore the pre-
7ff23c6
behavior.
Author: Justin Prysby
Discussion: https://postgr.es/m/
20220913223954.GU31833@telsasoft.com
Backpatch-through: 15
Fujii Masao [Thu, 22 Sep 2022 03:54:26 +0000 (12:54 +0900)]
docs: Fix snapshot name in SET TRANSACTION docs.
Commit
6c2003f8a1 changed the snapshot names mentioned in
SET TRANSACTION docs, however, there was one place that
the commit missed updating the name.
Back-patch to all supported versions.
Author: Japin Li
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/MEYP282MB1669BD4280044501165F8B07B64F9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Michael Paquier [Thu, 22 Sep 2022 00:47:28 +0000 (09:47 +0900)]
Used optimized linear search in more code paths
This commit updates two code paths to use pg_lfind32() introduced by
b6ef167 with TransactionId arrays:
- At the end of TransactionIdIsInProgress(), when checking for the case
of still running but overflowed subxids.
- XidIsConcurrent(), when checking for a serializable conflict.
These cases are less impactful than
37a6e5d, but a bit of
micro-benchmarking of this API shows that linear search speeds up by
~20% depending on the number of items involved (x86_64 and amd64 looked
at here).
Author: Nathan Bossart
Reviewed-by: Richard Guo, Michael Paquier
Discussion: https://postgr.es/m/
20220901185153.GA783106@nathanxps13
Fujii Masao [Thu, 22 Sep 2022 00:25:29 +0000 (09:25 +0900)]
psql: Improve tab-completion for MERGE.
Commit
7103ebb7aa added the tab-completion for MERGE accidentally
in the middle of that for LOCK TABLE. This commit fixes this issue.
This also adds some tab-completion for MERGE.
Back-patch to v15 where MERGE was introduced.
Author: Kotaro Kawamoto, Fujii Masao
Reviewed-by: Shinya Kato, Álvaro Herrera
Discussion: https://postgr.es/m/
9f1ad2a87a58cd5e7d64f3993130958d@oss.nttdata.com
Andres Freund [Thu, 22 Sep 2022 00:15:54 +0000 (17:15 -0700)]
ci: windows: set error mode to not include SEM_NOGPFAULTERRORBOX
Cirrus defaults to SetErrorMode(SEM_NOGPFAULTERRORBOX | ...). That prevents
crash reporting from working unless binaries do SetErrorMode()
themselves. Furthermore, it appears that either python or, more likely, the C
runtime has a bug where SEM_NOGPFAULTERRORBOX can very occasionally *trigger*
a crash on process exit - which is hard to debug, given that it explicitly
prevents crash dumps from working...
Discussion: https://postgr.es/m/
20220909235836.lz3igxtkcjb5w7zb%40awork3.anarazel.de
Backpatch: 15-, where CI was added
Thomas Munro [Wed, 21 Sep 2022 23:35:46 +0000 (11:35 +1200)]
ci: Increase requested memory size.
CI builds recently started failing with:
"Memory size for 4.0 vCPU instance should be between 3840MiB and
26624MiB, while 2048MiB is requested."
Ok then, let's ask for 4G instead of 2G.
This may be due to a change in the type of instance used to work around
an outage, per:
https://twitter.com/cirrus_labs/status/
1572657320093712384