Michael Paquier [Fri, 10 Jan 2020 00:36:55 +0000 (09:36 +0900)]
doc: Fix naming of SELinux
Reported-by: Tham Nguyen
Discussion: https://postgr.es/m/
157851402876.29175.
12977878383183540468@wrigleys.postgresql.org
Backpatch-through: 9.4
Michael Paquier [Fri, 10 Jan 2020 00:02:25 +0000 (09:02 +0900)]
pgbench: Make more debug messages use common logging API
This is a follow-up of
30a3e772, making the output more consistent when
using --debug for meta-command execution.
Author: Michael Paquier
Reviewed-by: Fabien Coelho
Discussion: https://postgr.es/m/alpine.DEB.2.21.
1912241100390.3339@pseudo
Tom Lane [Thu, 9 Jan 2020 21:46:05 +0000 (16:46 -0500)]
Skip tab-completion tests if envar SKIP_READLINE_TESTS is defined.
Experience so far suggests that getting these tests to pass on
all libedit versions that are out there may be impossible, or
require dumbing down the tests to the point of uselessness.
So we need to provide a way to skip them when the user knows they'll
fail. An environment variable is probably the most convenient way
to deal with this; it's easy for, e.g., a buildfarm animal's
configuration to set up.
Discussion: https://postgr.es/m/9594.
1578586797@sss.pgh.pa.us
Tom Lane [Thu, 9 Jan 2020 16:56:59 +0000 (11:56 -0500)]
Reconsider the representation of join alias Vars.
The core idea of this patch is to make the parser generate join alias
Vars (that is, ones with varno pointing to a JOIN RTE) only when the
alias Var is actually different from any raw join input, that is a type
coercion and/or COALESCE is necessary to generate the join output value.
Otherwise just generate varno/varattno pointing to the relevant join
input column.
In effect, this means that the planner's flatten_join_alias_vars()
transformation is already done in the parser, for all cases except
(a) columns that are merged by JOIN USING and are transformed in the
process, and (b) whole-row join Vars. In principle that would allow
us to skip doing flatten_join_alias_vars() in many more queries than
we do now, but we don't have quite enough infrastructure to know that
we can do so --- in particular there's no cheap way to know whether
there are any whole-row join Vars. I'm not sure if it's worth the
trouble to add a Query-level flag for that, and in any case it seems
like fit material for a separate patch. But even without skipping the
work entirely, this should make flatten_join_alias_vars() faster,
particularly where there are nested joins that it previously had to
flatten recursively.
An essential part of this change is to replace Var nodes'
varnoold/varoattno fields with varnosyn/varattnosyn, which have
considerably more tightly-defined meanings than the old fields: when
they differ from varno/varattno, they identify the Var's position in
an aliased JOIN RTE, and the join alias is what ruleutils.c should
print for the Var. This is necessary because the varno change
destroyed ruleutils.c's ability to find the JOIN RTE from the Var's
varno.
Another way in which this change broke ruleutils.c is that it's no
longer feasible to determine, from a JOIN RTE's joinaliasvars list,
which join columns correspond to which columns of the join's immediate
input relations. (If those are sub-joins, the joinaliasvars entries
may point to columns of their base relations, not the sub-joins.)
But that was a horrid mess requiring a lot of fragile assumptions
already, so let's just bite the bullet and add some more JOIN RTE
fields to make it more straightforward to figure that out. I added
two integer-List fields containing the relevant column numbers from
the left and right input rels, plus a count of how many merged columns
there are.
This patch depends on the ParseNamespaceColumn infrastructure that
I added in commit
5815696bc. The biggest bit of code change is
restructuring transformFromClauseItem's handling of JOINs so that
the ParseNamespaceColumn data is propagated upward correctly.
Other than that and the ruleutils fixes, everything pretty much
just works, though some processing is now inessential. I grabbed
two pieces of low-hanging fruit in that line:
1. In find_expr_references, we don't need to recurse into join alias
Vars anymore. There aren't any except for references to merged USING
columns, which are more properly handled when we scan the join's RTE.
This change actually fixes an edge-case issue: we will now record a
dependency on any type-coercion function present in a USING column's
joinaliasvar, even if that join column has no references in the query
text. The odds of the missing dependency causing a problem seem quite
small: you'd have to posit somebody dropping an implicit cast between
two data types, without removing the types themselves, and then having
a stored rule containing a whole-row Var for a join whose USING merge
depends on that cast. So I don't feel a great need to change this in
the back branches. But in theory this way is more correct.
2. markRTEForSelectPriv and markTargetListOrigin don't need to recurse
into join alias Vars either, because the cases they care about don't
apply to alias Vars for USING columns that are semantically distinct
from the underlying columns. This removes the only case in which
markVarForSelectPriv could be called with NULL for the RTE, so adjust
the comments to describe that hack as being strictly internal to
markRTEForSelectPriv.
catversion bump required due to changes in stored rules.
Discussion: https://postgr.es/m/7115.
1577986646@sss.pgh.pa.us
Robert Haas [Thu, 9 Jan 2020 15:59:07 +0000 (10:59 -0500)]
Add pg_shmem_allocations view.
This tells you about allocations that have been made from the main
shared memory segment. The original patch also tried to show information
about dynamic shared memory allocation as well, but I decided to
leave that problem for another time.
Andres Freund and Robert Haas, reviewed by Michael Paquier, Marti
Raudsepp, Tom Lane, Álvaro Herrera, and Kyotaro Horiguchi.
Discussion: http://postgr.es/m/
20140504114417.GM12715@awork2.anarazel.de
Robert Haas [Thu, 9 Jan 2020 14:01:37 +0000 (09:01 -0500)]
Remove bogus 'return'.
Per the buildfarm, via Michael Paquier.
Discussion: http://postgr.es/m/
20200108032648.GE3413@paquier.xyz
Magnus Hagander [Thu, 9 Jan 2020 09:48:22 +0000 (10:48 +0100)]
Clarify that pg_trgm is used in example
Reported-by: Octopus ZHANG
Author: Daniel Gustafsson
Peter Eisentraut [Thu, 9 Jan 2020 08:54:47 +0000 (09:54 +0100)]
Add support for automatically updating Unicode derived files
We currently have several sets of files generated from data provided
by Unicode. These all have ad hoc rules and instructions for updating
when new Unicode versions appear, and it's not done consistently.
This patch centralizes and automates the process and makes it part of
the release checklist. The Unicode and CLDR versions are specified in
Makefile.global.in. There is a new make target "update-unicode" that
downloads all the relevant files and runs the generation script.
There is also a new script for generating the table of combining
characters for ucs_wcwidth(). That table is now in a separate include
file rather than hardcoded into the middle of other code. This is
based on the script that was used for generating
d8594d123c155aeecd47fc2450f62f5100b2fbf0, but the script itself wasn't
committed at that time.
Reviewed-by: John Naylor <john.naylor@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/
c8d05f42-443e-6c23-819b-
05b31759a37c@2ndquadrant.com
Andrew Dunstan [Thu, 9 Jan 2020 08:09:54 +0000 (18:39 +1030)]
Allow 'sslkey' and 'sslcert' in postgres_fdw user mappings
This allows different users to authenticate with different certificates.
Author: Craig Ringer
Peter Eisentraut [Wed, 8 Jan 2020 20:48:44 +0000 (21:48 +0100)]
Modernize Python exception syntax in tests
Change the exception syntax used in the tests to use the more current
except Exception as ex:
rather than the old
except Exception, ex:
Since support for Python <2.6 has been removed, all supported versions
now support the new style, and we can save one step in the Python 3
compatibility conversion.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
98b69261-298c-13d2-f34d-
836fd9c29b21%402ndquadrant.com
Peter Eisentraut [Wed, 8 Jan 2020 20:48:44 +0000 (21:48 +0100)]
Remove support for Python older than 2.6
Supporting very old Python versions is a maintenance burden,
especially with the several variant test files to maintain for Python
<2.6.
Since we have dropped support for older OpenSSL versions in
7b283d0e1d1d79bf1c962d790c94d2a53f3bb38a, RHEL 5 is now effectively
desupported, and that was also the only mainstream operating system
still using Python versions before 2.6, so it's a good time to drop
those as well.
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/
98b69261-298c-13d2-f34d-
836fd9c29b21%402ndquadrant.com
Alvaro Herrera [Wed, 8 Jan 2020 17:33:49 +0000 (14:33 -0300)]
Reimplement nullification of walsender timestamp
Make the value null only at pg_stat_activity-output time, as suggested
by Tom Lane, instead of messing with the internal state. This should
appease buildfarm members with force_parallel_mode=regress, which are
running parallel queries on logical replication walsenders.
The fact that walsenders can run parallel queries should perhaps be
studied more carefully, but for the moment let's get rid of the red
blots in buildfarm.
Backpatch to pg10, like the previous commit.
Discussion: https://postgr.es/m/30804.
1578438763@sss.pgh.pa.us
Tom Lane [Wed, 8 Jan 2020 16:07:53 +0000 (11:07 -0500)]
Improve the handling of result type coercions in SQL functions.
Use the parser's standard type coercion machinery to convert the
output column(s) of a SQL function's final SELECT or RETURNING
to the type(s) they should have according to the function's declared
result type. We'll allow any case where an assignment-level
coercion is available. Previously, we failed unless the required
coercion was a binary-compatible one (and the documentation ignored
this, falsely claiming that the types must match exactly).
Notably, the coercion now accounts for typmods, so that cases where
a SQL function is declared to return a composite type whose columns
are typmod-constrained now behave as one would expect. Arguably
this aspect is a bug fix, but the overall behavioral change here
seems too large to consider back-patching.
A nice side-effect is that functions can now be inlined in a
few cases where we previously failed to do so because of type
mismatches.
Discussion: https://postgr.es/m/18929.
1574895430@sss.pgh.pa.us
Stephen Frost [Wed, 8 Jan 2020 15:57:09 +0000 (10:57 -0500)]
Improve GSSAPI Encryption startup comment in libpq
The original comment was a bit confusing, pointed out by Alvaro Herrera.
Thread: https://postgr.es/m/
20191224151520.GA16435%40alvherre.pgsql
Tom Lane [Wed, 8 Jan 2020 14:42:53 +0000 (09:42 -0500)]
Fix handling of generated columns in ALTER TABLE.
ALTER TABLE failed if a column referenced in a GENERATED expression
had been added or changed in type earlier in the ALTER command.
That's because the GENERATED expression needs to be evaluated
against the table's updated tuples, but it was being evaluated
against the original tuples. (Fortunately the executor has adequate
cross-checks to notice the mismatch, so we just got an obscure error
message and not anything more dangerous.)
Per report from Andreas Joseph Krogh. Back-patch to v12 where
GENERATED was added.
Discussion: https://postgr.es/m/VisenaEmail.200.
231b0a41523275d0.
16ea7f800c7@tc7-visena
Peter Eisentraut [Wed, 8 Jan 2020 13:23:55 +0000 (14:23 +0100)]
pgbench: Use common logging API
Author: Fabien COELHO <coelho@cri.ensmp.fr>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/alpine.DEB.2.21.
1912241100390.3339@pseudo
Michael Paquier [Wed, 8 Jan 2020 01:36:12 +0000 (10:36 +0900)]
Revert "Forbid DROP SCHEMA on temporary namespaces"
This reverts commit
a052f6c, following complains from Robert Haas and
Tom Lane. Backpatch down to 9.4, like the previous commit.
Discussion: https://postgr.es/m/CA+TgmobL4npEX5=E5h=5Jm_9mZun3MT39Kq2suJFVeamc9skSQ@mail.gmail.com
Backpatch-through: 9.4
Michael Paquier [Wed, 8 Jan 2020 01:02:55 +0000 (10:02 +0900)]
Remove dependency to system calls for memory allocation in refint
Failures in allocations could lead to crashes with NULL pointer
dereferences . Memory context TopMemoryContext is used instead to keep
alive the plans allocated in the session. A more specific context could
be used here, but this is left for later.
Reported-by: Jian Zhang
Author: Michael Paquier
Reviewed-by: Tom Lane, Andres Freund
Discussion: https://postgr.es/m/16190-
70181c803641c3dc@postgresql.org
Alvaro Herrera [Tue, 7 Jan 2020 20:38:48 +0000 (17:38 -0300)]
pg_stat_activity: show NULL stmt start time for walsenders
Returning a non-NULL time is pointless, sinc a walsender is not a
process that would be running normal transactions anyway, but the code
was unintentionally exposing the process start time intermittently,
which was not only bogus but it also confused monitoring systems looking
for idle transactions. Fix by avoiding all updates in walsenders.
Backpatch to 11, where walsenders started appearing in pg_stat_activity.
Reported-by: Tomas Vondra
Discussion: https://postgr.es/m/
20191209234409.exe7osmyalwkt5j4@development
Robert Haas [Tue, 7 Jan 2020 19:35:48 +0000 (14:35 -0500)]
tableam: New callback relation_fetch_toast_slice.
Instead of always calling heap_fetch_toast_slice during detoasting,
invoke a table AM callback which, when the toast table is a heap
table, will be heap_fetch_toast_slice.
This makes it possible for a table AM other than heap to be used
as a TOAST table. It also completes the series of commits intended
to improve the interaction of tableam with TOAST that began with
commit
8b94dab06617ef80a0901ab103ebd8754427ef5a; detoast.c is
now, hopefully, fully AM-independent.
Patch by me, reviewed by Andres Freund and Peter Eisentraut.
Discussion: http://postgr.es/m/CA+TgmoZv-=2iWM4jcw5ZhJeL18HF96+W1yJeYrnGMYdkFFnEpQ@mail.gmail.com
Robert Haas [Tue, 7 Jan 2020 19:23:25 +0000 (14:23 -0500)]
tableam: Allow choice of toast AM.
Previously, the toast table had to be implemented by the same AM that
was used for the main table, which was bad, because the detoasting
code won't work with anything but heap. This commit doesn't fix the
latter problem, although there's another patch coming which does,
but it does let you pick something that works (i.e. heap, right now).
Patch by me, reviewed by Andres Freund.
Discussion: http://postgr.es/m/CA+TgmoZv-=2iWM4jcw5ZhJeL18HF96+W1yJeYrnGMYdkFFnEpQ@mail.gmail.com
Robert Haas [Tue, 7 Jan 2020 17:14:19 +0000 (12:14 -0500)]
Increase the maximum value of track_activity_query_size.
This one-line change provoked a lot of discussion, but ultimately
the consensus seems to be that allowing a larger value might be
useful to somebody, and probably won't hurt anyone who chooses
not to take advantage of the higher maximum limit.
Vyacheslav Makarov, reviewed by many people.
Discussion: http://postgr.es/m/
7b5ecc5a9991045e2f13c84e3047541d@postgrespro.ru
Tom Lane [Tue, 7 Jan 2020 01:56:32 +0000 (20:56 -0500)]
Clean up management of IP addresses in our SSL tests.
Instead of hard-wiring the netmask as /32, allow it to be specified
where we specify the server address. This will ease changing the
test to use IPv6, when/if somebody wants to do that.
Also remove the hard-wired pg_hba.conf entries for IPv6 (::1/128).
These have never had any usefulness, because the client side
of the tests has always explicitly connected to $SERVERHOSTADDR
which has always been set to IPv4 (127.0.0.1). All they accomplish
is to break the test on non-IPv6-supporting hosts, and besides
that they violate the express intent of the code to minimize the
server's range of allowed connections.
This could be back-patched, perhaps, but for now I don't see
a need to.
Discussion: https://postgr.es/m/1899.
1578356089@sss.pgh.pa.us
Tom Lane [Mon, 6 Jan 2020 21:42:20 +0000 (16:42 -0500)]
Reduce the number of GetFlushRecPtr() calls done by walsenders.
Since the WAL flush position only moves forward, it's safe to cache
its previous value within each walsender process, and update from
shared memory only once we've caught up to the previously-seen value.
When there are many active walsenders, this makes for a very significant
reduction in the amount of contention on the XLogCtl->info_lck spinlock.
This patch also adjusts the logic so that we update our idea of the
flush position after processing a WAL record, rather than beforehand.
This may cause us to realize we're not caught up when the preceding
coding would've thought that we were, but that seems all to the good;
it may avoid a useless sleep-and-wakeup cycle.
Back-patch to v12. The contention problem exists in prior branches,
but it's much less severe (due to inefficiencies elsewhere) so there
seems no need to take any risk of back-patching further.
Pierre Ducroquet, reviewed by Julien Rouhaud
Discussion: https://postgr.es/m/
2931018.Vxl9zapr77@pierred-pdoc
Tom Lane [Mon, 6 Jan 2020 17:13:53 +0000 (12:13 -0500)]
Add functions min_scale(numeric) and trim_scale(numeric).
These allow better control of trailing zeroes in numeric values.
Pavel Stehule, based on an old proposal of Marko Tiikkaja's;
review by Karl Pinc
Discussion: https://postgr.es/m/CAFj8pRDjs-navGASeF0Wk74N36YGFJ+v=Ok9_knRa7vDc-qugg@mail.gmail.com
Peter Eisentraut [Mon, 6 Jan 2020 07:21:14 +0000 (08:21 +0100)]
Have logical replication subscriber fire column triggers
The logical replication apply worker did not fire per-column update
triggers because the updatedCols bitmap in the RTE was not populated.
This fixes that.
Reviewed-by: Euler Taveira <euler@timbira.com.br>
Discussion: https://www.postgresql.org/message-id/flat/
21673e2d-597c-6afe-637e-
e8b10425b240%402ndquadrant.com
Michael Paquier [Mon, 6 Jan 2020 03:51:44 +0000 (12:51 +0900)]
Remove support for OpenSSL 0.9.8 and 1.0.0
Support is out of scope from all the major vendors for these versions
(for example RHEL5 uses a version based on 0.9.8, and RHEL6 uses 1.0.1),
and it created some extra maintenance work. Upstream has stopped
support of 0.9.8 in December 2015 and of 1.0.0 in February 2016.
Since
b1abfec, note that the default SSL protocol version set with
ssl_min_protocol_version is TLSv1.2, whose support was added in OpenSSL
1.0.1, so there is no point to enforce ssl_min_protocol_version to TLSv1
in the SSL tests.
Author: Michael Paquier
Reviewed-by: Daniel Gustafsson, Tom Lane
Discussion: https://postgr.es/m/
20191205083252.GE5064@paquier.xyz
Peter Geoghegan [Mon, 6 Jan 2020 01:42:13 +0000 (17:42 -0800)]
Remove redundant incomplete split assertion.
The fastpath insert optimization's incomplete split flag Assert() is
redundant. We'll reach the more general Assert() within
_bt_findinsertloc() in all cases. (Besides, Assert()'ing that the
rightmost page doesn't have the flag set never made much sense.)
Tom Lane [Sun, 5 Jan 2020 16:35:45 +0000 (11:35 -0500)]
Minor style improvements for tab-completion test.
Use qr// syntax for regex values.
Include the regex that failed to match in diagnostic reports.
Dagfinn Ilmari Mannsåker
Discussion: https://postgr.es/m/87k16610xk.fsf@wibble.ilmari.org
Tatsuo Ishii [Sun, 5 Jan 2020 10:45:37 +0000 (19:45 +0900)]
Docs: use more standard terminology "round-to-nearest-even" instead of "round-to-even".
Per suggestion from Tom Lane.
Discussion: https://postgr.es/m/flat/
20191230.093451.
1762483750956466101.t-ishii%40sraoss.co.jp
Tom Lane [Sun, 5 Jan 2020 02:33:34 +0000 (21:33 -0500)]
Avoid reading ~/.inputrc in tab-completion test, and revert other changes.
The true explanation for Peter Geoghegan's trouble report turns out
to be that he has a ~/.inputrc that affects readline's behavior
enough to break this test. Prevent readline from reading that file.
Also, the best way to prevent TERM from affecting the results seems
to be to unset it altogether, not to set it to "xterm". The latter
choice licenses readline to emit xterm escape sequences, and there's
a lot of variation in exactly what it will emit.
Revert changes that attempted to account exactly for xterm escape
sequences. We shouldn't need that with TERM unset, and it was not
looking like a maintainable solution anyway.
Discussion: https://postgr.es/m/23181.
1578167938@sss.pgh.pa.us
Tom Lane [Sat, 4 Jan 2020 21:40:56 +0000 (16:40 -0500)]
Don't try to force TERM to a fixed value in tab-completion test.
Right at the moment, this is making things worse not better in the
buildfarm. I'm not happy with anything about the current state,
but let's at least try to have a green buildfarm report while further
investigation continues.
Discussion: https://postgr.es/m/23181.
1578167938@sss.pgh.pa.us
Tom Lane [Sat, 4 Jan 2020 20:05:24 +0000 (15:05 -0500)]
In tab-completion test, print out the value of TERM before changing it.
I'm curious to see what values are prevailing in the buildfarm.
Discussion: https://postgr.es/m/23181.
1578167938@sss.pgh.pa.us
Noah Misch [Sat, 4 Jan 2020 19:31:42 +0000 (11:31 -0800)]
Skip memcpy(x, x) in qunique().
It has undefined behavior. Follow the precedent of commit
9a9473f3cce1a21c25d6cc7569710e832d2b180b. No back-patch, since the
master branch alone has this function.
Discussion: https://postgr.es/m/
20191229070221.GA13873@gust.leadboat.com
Tom Lane [Sat, 4 Jan 2020 19:29:28 +0000 (14:29 -0500)]
Make tab-completion tests more robust.
Depending on as-yet-incompletely-explained factors, readline/libedit
might choose to emit screen-control escape sequences as part of
repainting the display. I'd tried to make the test patterns avoid
matching parts of the output that are likely to contain such, but
it seems that there's really no way around matching them explicitly
in some places, unless we want to just give up testing some behaviors
such as display of alternatives.
Per report from Peter Geoghegan.
Discussion: https://postgr.es/m/CAH2-WznPzfWHu8PQwv1Qjpf4wQVPaaWpoO5NunFz9zsYKB4uJA@mail.gmail.com
Peter Eisentraut [Sat, 4 Jan 2020 10:56:58 +0000 (11:56 +0100)]
Make better use of ParseState in ProcessUtility
Pass ParseState into the functions called from
standard_ProcessUtility() instead passing the query string and query
environment separately. No functionality change, but it makes the
notation consistent. We had already started moving things into
that direction piece by piece, and this completes it.
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/
6e7aa4a1-be6a-1a75-b1f9-
83a678e5184a@2ndquadrant.com
Peter Geoghegan [Fri, 3 Jan 2020 20:18:13 +0000 (12:18 -0800)]
Add xl_btree_delete optimization.
Commit
558a9165e08 taught _bt_delitems_delete() to produce its own XID
horizon on the primary. Standbys no longer needed to generate their own
latestRemovedXid, since they could just use the explicitly logged value
from the primary instead. The deleted offset numbers array from the
xl_btree_delete WAL record was no longer used by the REDO routine for
anything other than deleting the items.
This enables a minor optimization: We now treat the array as buffer
state, not generic WAL data, following _bt_delitems_vacuum()'s example.
This should be a minor win, since it allows us to avoid including the
deleted items array in cases where XLogInsert() stores the whole buffer
anyway. The primary goal here is to make the code more maintainable,
though. Removing inessential differences between the two functions
highlights the fundamental differences that remain.
Also change xl_btree_delete to use uint32 for the size of the array of
item offsets being deleted. This brings xl_btree_delete closer to
xl_btree_vacuum. Furthermore, it seems like a good idea to use an
explicit-width integer type (the field was previously an "int").
Bump XLOG_PAGE_MAGIC because xl_btree_delete changed.
Discussion: https://postgr.es/m/CAH2-Wzkz4TjmezzfAbaV1zYrh=fr0bCpzuJTvBe5iUQ3aUPsCQ@mail.gmail.com
Tom Lane [Fri, 3 Jan 2020 17:54:13 +0000 (12:54 -0500)]
Further fixes for tab-completion TAP tests.
Escape non-printable characters in failure reports, by using Data::Dumper
in Useqq mode. Also, bump $Test::Builder::Level so the diagnostic
references the calling line, and use diag() instad of note(),
so it shows even in non-verbose mode (per request from Christoph Berg).
Also, give up on trying to test for the specific way that readline
chooses to overwrite existing text in the \DRD -> \drds test.
There are too many variants, it seems, at least on the libedit
side of things.
Dagfinn Ilmari Mannsåker and Tom Lane
Discussion: https://postgr.es/m/
20200103110128.GA28967@msg.df7cb.de
Tom Lane [Fri, 3 Jan 2020 16:15:26 +0000 (11:15 -0500)]
Add an ugly workaround for a bug in some recent libedit versions.
Debian unstable is shipping a broken version of libedit: it de-escapes
words before passing them to the application's tab completion function,
preventing us from recognizing backslash commands. Fortunately,
we have enough information available to dig the original text out of
rl_line_buffer, so ignore the string argument and do that.
I view this as a temporary workaround to get the affected buildfarm
members back to green in the wake of
7c015045b. I hope we can get
rid of it once somebody fixes Debian's libedit; hence, no back-patch,
at least for now.
Discussion: https://postgr.es/m/
20200103110128.GA28967@msg.df7cb.de
Peter Eisentraut [Fri, 3 Jan 2020 09:44:13 +0000 (10:44 +0100)]
pgbench: Improve test description
Author: Fabien COELHO <coelho@cri.ensmp.fr>
Amit Kapila [Fri, 3 Jan 2020 05:22:46 +0000 (10:52 +0530)]
Fix typos in parallel query docs.
Reported-by: Jon Jensen
Author: Jon Jensen
Reviewed-by: Amit Kapila and Robert Haas
Backpatch-through: 10
Discussion: https://postgr.es/m/nycvar.YSQ.7.76.
1912301807510.9899@ybpnyubfg
Peter Geoghegan [Fri, 3 Jan 2020 02:30:25 +0000 (18:30 -0800)]
Clear up btree_xlog_split() alignment comment.
Adjust a comment that describes how alignment of the new left page high
key works in btree_xlog_split(), the nbtree page split REDO routine.
The wording used before commit
2c03216d831 is much clearer, so go back
to that.
Tom Lane [Fri, 3 Jan 2020 00:44:43 +0000 (19:44 -0500)]
Minor portability fixes for new TAP script.
Satisfy perlcritic, mostly. Per buildfarm.
Peter Geoghegan [Thu, 2 Jan 2020 21:30:40 +0000 (13:30 -0800)]
Correct _bt_delitems_vacuum() lock comments.
The expectation within _bt_delitems_vacuum() is that caller has a
super-exclusive/cleanup buffer lock (not just a pin and a write lock).
Alvaro Herrera [Thu, 2 Jan 2020 20:04:24 +0000 (17:04 -0300)]
Fix cloning of row triggers to sub-partitions
When row triggers exist in partitioned partitions that are not either
part of FKs or deferred unique constraints, they are not correctly
cloned to their partitions. That's because they are marked "internal",
and those are purposefully skipped when doing the clone triggers dance.
Fix by relaxing the condition on which internal triggers are skipped.
Amit Langote initially diagnosed the problem and proposed a fix, but I
used a different approach.
Reported-by: Petr Fedorov
Discussion: https://postgr.es/m/
6b3f0646-ba8c-b3a9-c62d-
1c6651a1920f@phystech.edu
Tom Lane [Thu, 2 Jan 2020 20:02:21 +0000 (15:02 -0500)]
Add basic TAP tests for psql's tab-completion logic.
Up to now, psql's tab-complete.c has had exactly no regression test
coverage. This patch is an experimental attempt to add some.
This needs Perl's IO::Pty module, which isn't installed everywhere,
so the test script just skips all tests if that's not present.
There may be other portability gotchas too, so I await buildfarm
results with interest.
So far this just covers a few very basic keyword-completion and
query-driven-completion scenarios, which should be enough to let us
get a feel for whether this is practical at all from a portability
standpoint. If it is, there's lots more that can be done.
Discussion: https://postgr.es/m/10967.
1577562752@sss.pgh.pa.us
Tom Lane [Thu, 2 Jan 2020 19:02:46 +0000 (14:02 -0500)]
Fix typmod exposed for scalar function in FROM, too.
On further reflection about commit
4d02eb017, it occurs to me that
expandRTE() had better agree with what addRangeTableEntryForFunction()
is doing. So teach that about functions possibly having typmods, too.
Peter Geoghegan [Thu, 2 Jan 2020 18:57:15 +0000 (10:57 -0800)]
Reorder two nbtree.h function prototypes.
Make the function prototype order consistent with the definition order
in nbtpage.c.
Tom Lane [Thu, 2 Jan 2020 18:48:54 +0000 (13:48 -0500)]
Fix collation exposed for scalar function in FROM.
One code path in addRangeTableEntryForFunction() neglected to assign
a collation to the tupdesc entry it constructs (which is a bit odd
considering the other path did do so). This didn't matter before commit
5815696bc, because nothing would look at the type data in this tupdesc;
but now it does.
While at it, make sure we assign the correct typmod as well. Most
function expressions don't have a determinate typmod, but some do.
Per buildfarm, which showed failures in non-C collations, a case
I'd not thought to test for this patch :-(
Tom Lane [Thu, 2 Jan 2020 16:29:01 +0000 (11:29 -0500)]
Make parser rely more heavily on the ParseNamespaceItem data structure.
When I added the ParseNamespaceItem data structure (in commit
5ebaaa494),
it wasn't very tightly integrated into the parser's APIs. In the wake of
adding p_rtindex to that struct (commit
b541e9acc), there is a good reason
to make more use of it: by passing around ParseNamespaceItem pointers
instead of bare RTE pointers, we can get rid of various messy methods for
passing back or deducing the rangetable index of an RTE during parsing.
Hence, refactor the addRangeTableEntryXXX functions to build and return
a ParseNamespaceItem struct, not just the RTE proper; and replace
addRTEtoQuery with addNSItemToQuery, which is passed a ParseNamespaceItem
rather than building one internally.
Also, add per-column data (a ParseNamespaceColumn array) to each
ParseNamespaceItem. These arrays are built during addRangeTableEntryXXX,
where we have column type data at hand so that it's nearly free to fill
the data structure. Later, when we need to build Vars referencing RTEs,
we can use the ParseNamespaceColumn info to avoid the rather expensive
operations done in get_rte_attribute_type() or expandRTE().
get_rte_attribute_type() is indeed dead code now, so I've removed it.
This makes for a useful improvement in parse analysis speed, around 20%
in one moderately-complex test query.
The ParseNamespaceColumn structs also include Var identity information
(varno/varattno). That info isn't actually being used in this patch,
except that p_varno == 0 is a handy test for a dropped column.
A follow-on patch will make more use of it.
Discussion: https://postgr.es/m/2461.
1577764221@sss.pgh.pa.us
Peter Eisentraut [Thu, 2 Jan 2020 13:40:18 +0000 (14:40 +0100)]
Fix comment in test
The comment was apparently copy-and-pasted and did not reflect the
actual test outcome.
Amit Kapila [Sat, 14 Dec 2019 06:11:37 +0000 (11:41 +0530)]
Fix running out of file descriptors for spill files.
Currently while decoding changes, if the number of changes exceeds a
certain threshold, we spill those to disk. And this happens for each
(sub)transaction. Now, while reading all these files, we don't close them
until we read all the files. While reading these files, if the number of
such files exceeds the maximum number of file descriptors, the operation
errors out.
Use PathNameOpenFile interface to open these files as that internally has
the mechanism to release kernel FDs as needed to get us under the
max_safe_fds limit.
Reported-by: Amit Khandekar
Author: Amit Khandekar
Reviewed-by: Amit Kapila
Backpatch-through: 9.4
Discussion: https://postgr.es/m/CAJ3gD9c-sECEn79zXw4yBnBdOttacoE-6gAyP0oy60nfs_sabQ@mail.gmail.com
Peter Geoghegan [Thu, 2 Jan 2020 01:29:41 +0000 (17:29 -0800)]
Revise BTP_HAS_GARBAGE nbtree VACUUM comments.
_bt_delitems_vacuum() comments claimed that it isn't worth another scan
of the page to avoid falsely unsetting the BTP_HAS_GARBAGE page flag
hint (this happens to be the same wording that was removed from
_bt_delitems_delete() by my recent commit
fe97c61c). The comments made
little sense, though. The issue can't have much to do with performing a
second scan of the target leaf page, since an LP_DEAD test could easily
be performed in the first scan of the page anyway (the scan that takes
place in btvacuumpage() caller).
Revise the explanation. It makes much more sense to frame this as an
issue about recovery conflicts. _bt_delitems_vacuum() cannot easily
generate an XID cutoff in the same way that _bt_delitems_delete() is
designed to.
Falsely unsetting the page flag is not ideal, and is likely to happen
more often than was supposed by the original comments. Explain why it
usually isn't a problem in practice. There may be an argument for
_bt_delitems_vacuum() not clearing the BTP_HAS_GARBAGE bit, removing the
question of it being falsely unset by VACUUM (there may even be an
argument for not using a page level hint at all). This can be revisited
later.
Tom Lane [Thu, 2 Jan 2020 00:31:41 +0000 (19:31 -0500)]
Test GROUP BY matching of join columns that are type-coerced by USING.
If we have, say, an int column that is left-joined to a bigint column
with USING, the merged column is the int column promoted to bigint.
GROUP BY's tests for whether grouping on the merged column allows a
reference to the underlying column, or vice versa, should know about
that relationship --- and they do. But I nearly broke this case with
an ill-advised optimization, so the lack of any test coverage for it
seems like a bad idea.
Peter Geoghegan [Wed, 1 Jan 2020 19:32:07 +0000 (11:32 -0800)]
Update btree_xlog_delete() comments.
Commit
fe97c61c updated LP_DEAD item deletion comments, but missed a
minor discrepancy on the REDO side. Fix it now.
In passing, don't talk about the btree_xlog_vacuum() behavior within
btree_xlog_delete(). The reliance on XLOG_HEAP2_CLEANUP_INFO records
for recovery conflicts is already discussed within btvacuumpage() and
mentioned again in passing above btree_xlog_vacuum(), which seems
sufficient.
Bruce Momjian [Wed, 1 Jan 2020 17:21:45 +0000 (12:21 -0500)]
Update copyrights for 2020
Backpatch-through: update all files in master, backpatch legal files through 9.4
Peter Eisentraut [Tue, 31 Dec 2019 09:35:16 +0000 (10:35 +0100)]
Modernize Python exception syntax in documentation
Change the exception syntax used in the documentation to use the more
current
except Exception as ex:
rather than the old
except Exception, ex:
We keep the old syntax in the test code since Python <2.6 is still
supported there, but the documentation might as well use the modern
syntax.
Tom Lane [Sat, 28 Dec 2019 22:21:17 +0000 (17:21 -0500)]
Micro-optimize AllocSetFreeIndex() by reference to pg_bitutils code.
Use __builtin_clz() where available. Where it isn't, we can still win
a little by using the pg_leftmost_one_pos[] lookup table instead of
having a private table.
Also drop the initial right shift by ALLOC_MINBITS in favor of
subtracting ALLOC_MINBITS from the leftmost-one-pos result. This
is a win because the compiler can fold that adjustment into other
constants it'd have to add anyway, making the shift-removal free.
Also, we can explain this coding as an unrolled form of
pg_leftmost_one_pos32(), even though that's a bit ahistorical
since it long predates pg_bitutils.h.
John Naylor, with some cosmetic adjustments by me
Discussion: https://postgr.es/m/CACPNZCuNUGMxjK7WTn_=WZnRbfASDdBxmjsVf2+m9MdmeNw_sg@mail.gmail.com
Alvaro Herrera [Fri, 27 Dec 2019 21:34:30 +0000 (18:34 -0300)]
Add pg_dump test for triggers on partitioned tables
This currently works, but add this test to ensure it continues to work.
Lack of this test became evident after a recent bugfix submission that
would have inadvertently broken it, in
https://postgr.es/m/CA+HiwqFM2=i+uHB9o4OkLbE2S3sjPHoVe2wXuAD1GLJ4+Pk9eg@mail.gmail.com
Bruce Momjian [Fri, 27 Dec 2019 19:49:08 +0000 (14:49 -0500)]
doc: add examples of creative use of unique expression indexes
Unique expression indexes can constrain data in creative ways, so show
two examples.
Reported-by: Tuomas Leikola
Discussion: https://postgr.es/m/
156760275564.1127.
12321702656456074572@wrigleys.postgresql.org
Backpatch-through: 9.4
Bruce Momjian [Fri, 27 Dec 2019 19:33:30 +0000 (14:33 -0500)]
docs: clarify infinite range values from data-type infinities
The previous docs referenced these distinct ideas confusingly.
Reported-by: Eugen Konkov
Discussion: https://postgr.es/m/
376945611.
20191026161529@yandex.ru
Backpatch-through: 9.4
Michael Paquier [Fri, 27 Dec 2019 08:58:43 +0000 (17:58 +0900)]
Forbid DROP SCHEMA on temporary namespaces
This operation was possible for the owner of the schema or a superuser.
Down to 9.4, doing this operation would cause inconsistencies in a
session whose temporary schema was dropped, particularly if trying to
create new temporary objects after the drop. A more annoying
consequence is a crash of autovacuum on an assertion failure when
logging information about an orphaned temp table dropped. Note that
because of
246a6c8 (present in v11~), which has made the removal of
orphaned temporary tables more aggressive, the failure could be
triggered more easily, but it is possible to reproduce down to 9.4.
Reported-by: Mahendra Singh, Prabhat Sahu
Author: Michael Paquier
Reviewed-by: Kyotaro Horiguchi, Mahendra Singh
Discussion: https://postgr.es/m/CAKYtNAr9Zq=1-ww4etHo-VCC-k120YxZy5OS01VkaLPaDbv2tg@mail.gmail.com
Backpatch-through: 9.4
Michael Paquier [Thu, 26 Dec 2019 23:09:00 +0000 (08:09 +0900)]
Revert "Rename files and headers related to index AM"
This follows multiple complains from Peter Geoghegan, Andres Freund and
Alvaro Herrera that this issue ought to be dug more before actually
happening, if it happens.
Discussion: https://postgr.es/m/
20191226144606.GA5659@alvherre.pgsql
Tom Lane [Thu, 26 Dec 2019 20:19:39 +0000 (15:19 -0500)]
Fix possible loss of sync between rectypeid and underlying PLpgSQL_type.
When revalidate_rectypeid() acts to update a stale record type OID
in plpgsql's data structures, it fixes the active PLpgSQL_rec struct
as well as the PLpgSQL_type struct it references. However, the latter
is shared across function executions while the former is not. In a
later function execution, the PLpgSQL_rec struct would be reinitialized
by copy_plpgsql_datums and would then contain a stale type OID,
typically leading to "could not open relation with OID NNNN" errors.
revalidate_rectypeid() can easily fix this, fortunately, just by
treating typ->typoid as authoritative.
Per report and diagnosis from Ashutosh Sharma, though this is not his
suggested fix. Back-patch to v11 where this code came in.
Discussion: https://postgr.es/m/CAE9k0Pkd4dZwt9J5pS9xhJFWpUtqs05C9xk_GEwPzYdV=GxwWg@mail.gmail.com
Tom Lane [Thu, 26 Dec 2019 16:20:05 +0000 (11:20 -0500)]
Improve comments in utils/rel.h.
Mark the fields that should be accessed via partitioning-related
functions, as we already did for some other fields.
Amit Langote
Discussion: https://postgr.es/m/CA+HiwqFnK6LbVMACMCaqwWrvoSFTecZzufKRahg2qGvLPYMX=g@mail.gmail.com
Tom Lane [Thu, 26 Dec 2019 16:16:42 +0000 (11:16 -0500)]
Refactor parser's generation of Var nodes.
Instead of passing around a pointer to the RangeTblEntry that
provides the desired column, pass a pointer to the associated
ParseNamespaceItem. The RTE is trivially reachable from the nsitem,
and having the ParseNamespaceItem allows access to additional
information. As proof of concept for that, add the rangetable index
to ParseNamespaceItem, and use that to get rid of RTERangeTablePosn
searches.
(I have in mind to teach the parser to generate some different
representation for Vars that are nullable by outer joins, and
keeping the necessary information in ParseNamespaceItems seems
like a reasonable approach to that. But whether that ever
happens or not, this seems like good cleanup.)
Also refactor the code around scanRTEForColumn so that the
"fuzzy match" stuff does not leak out of parse_relation.c.
Discussion: https://postgr.es/m/26144.
1576858373@sss.pgh.pa.us
Michael Paquier [Thu, 26 Dec 2019 13:26:09 +0000 (22:26 +0900)]
Fix some comments related to logical repslot advancing
confirmed_flush is part of a replication slot's information, but not
confirmed_lsn.
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/
20191226.175919.
17237335658671970.horikyota.ntt@gmail.com
Backpatch-through: 11
Michael Paquier [Thu, 26 Dec 2019 08:01:23 +0000 (17:01 +0900)]
Refactor code dedicated to index vacuuming in vacuumlazy.c
The part in charge of doing the vacuum on all the indexes of a relation
was duplicated, with the same handling for progress reporting done.
While on it, update the progress reporting for heap vacuuming in the
subroutine doing the actual work, keeping the status update local. This
way, any future caller of lazy_vacuum_heap() does not have to worry
about doing any progress reporting update.
Author: Justin Pryzby, Michael Paquier
Discussion: https://postgr.es/m/
20191120210600.GC30362@telsasoft.com
Fujii Masao [Thu, 26 Dec 2019 06:07:43 +0000 (15:07 +0900)]
Add note about how each partition's default value is treated, into the doc.
Column defaults may be specified separately for each partition.
But INSERT via a partitioned table ignores those partition's default values.
The former is documented, but the latter restriction not.
This commit adds the note about that restriction into the document.
Author: Fujii Masao
Reviewed-by: Amit Langote
Discussion: https://postgr.es/m/CAHGQGwEs-59omrfGF7hOHz9iMME3RbKy5ny+iftDx3LHTEn9sA@mail.gmail.com
Tom Lane [Wed, 25 Dec 2019 20:44:15 +0000 (15:44 -0500)]
Allow whole-row Vars to be used in partitioning expressions.
In the wake of commit
5b9312378, there's no particular reason
for this restriction (previously, it was problematic because of
the implied rowtype reference). A simple constraint on a whole-row
Var probably isn't that useful, but conceivably somebody would want
to pass one to a function that extracts a partitioning key. Besides
which, we're expending much more code to enforce the restriction than
we save by having it, since the latter quantity is now zero.
So drop the restriction.
Amit Langote
Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Tom Lane [Wed, 25 Dec 2019 19:45:57 +0000 (14:45 -0500)]
Remove equalPartitionDescs().
This is dead code in the wake of the previous commit.
We can always add it back if we need it again someday.
Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Tom Lane [Wed, 25 Dec 2019 19:43:13 +0000 (14:43 -0500)]
Load relcache entries' partitioning data on-demand, not immediately.
Formerly the rd_partkey and rd_partdesc data structures were always
populated immediately when a relcache entry was built or rebuilt.
This patch changes things so that they are populated only when they
are first requested. (Hence, callers *must* now always use
RelationGetPartitionKey or RelationGetPartitionDesc; just fetching
the pointer directly is no longer acceptable.)
This seems to have some performance benefits, but the main reason to do
it is that it eliminates a recursive-reload failure that occurs if the
partkey or partdesc expressions contain any references to the relation's
rowtype (as discovered by Amit Langote). In retrospect, since loading
these data structures might result in execution of nearly-arbitrary code
via eval_const_expressions, it was a dumb idea to require that to happen
during relcache entry rebuild.
Also, fix things so that old copies of a relcache partition descriptor
will be dropped when the cache entry's refcount goes to zero. In the
previous coding it was possible for such copies to survive for the
lifetime of the session, as I'd complained of in a previous discussion.
(This management technique still isn't perfect, but it's better than
before.) Improve the commentary explaining how that works and why
it's safe to hand out direct pointers to these relcache substructures.
In passing, improve RelationBuildPartitionDesc by using the same
memory-context-parent-swap approach used by RelationBuildPartitionKey,
thereby making it less dependent on strong assumptions about what
partition_bounds_copy does. Avoid doing get_rel_relkind in the
critical section, too.
Patch by Amit Langote and Tom Lane; Robert Haas deserves some credit
for prior work in the area, too. Although this is a pre-existing
problem, no back-patch: the patch seems too invasive to be safe to
back-patch, and the bug it fixes is a corner case that seems
relatively unlikely to cause problems in the field.
Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Discussion: https://postgr.es/m/CA+TgmoY3bRmGB6-DUnoVy5fJoreiBJ43rwMrQRCdPXuKt4Ykaw@mail.gmail.com
Michael Paquier [Wed, 25 Dec 2019 01:23:39 +0000 (10:23 +0900)]
Rename files and headers related to index AM
The following renaming is done so as source files related to index
access methods are more consistent with table access methods (the
original names used for index AMs ware too generic, and could be
confused as including features related to table AMs):
- amapi.h -> indexam.h.
- amapi.c -> indexamapi.c. Here we have an equivalent with
backend/access/table/tableamapi.c.
- amvalidate.c -> indexamvalidate.c.
- amvalidate.h -> indexamvalidate.h.
- genam.c -> indexgenam.c.
- genam.h -> indexgenam.h.
This has been discussed during the development of v12 when table AM was
worked on, but the renaming never happened.
Author: Michael Paquier
Reviewed-by: Fabien Coelho, Julien Rouhaud
Discussion: https://postgr.es/m/
20191223053434.GF34339@paquier.xyz
Alvaro Herrera [Tue, 24 Dec 2019 15:37:13 +0000 (12:37 -0300)]
Avoid splitting C string literals with \-newline
Using \ is unnecessary and ugly, so remove that. While at it, stitch
the literals back into a single line: we've long discouraged splitting
error message literals even when they go past the 80 chars line limit,
to improve greppability.
Leave contrib/tablefunc alone.
Discussion: https://postgr.es/m/
20191223195156.GA12271@alvherre.pgsql
Michael Paquier [Tue, 24 Dec 2019 03:14:08 +0000 (12:14 +0900)]
Replace use of strerror() with %s by %m in pg_waldump
Since
d6c55de1, src/port/snprintf.c is able to use %m instead of
strerror(). A couple of utilities in src/bin/ have already done the
switch, and do it now for pg_waldump as this reduces the workload for
translators.
Note that more could be done, particularly with pgbench. Thanks to
Kyotaro Horiguchi for the discussion.
Discussion: https://postgr.es/m/
20191129065115.GM2505@paquier.xyz
Thomas Munro [Mon, 23 Dec 2019 22:31:24 +0000 (11:31 +1300)]
Rotate instead of shifting hash join batch number.
Our algorithm for choosing batch numbers turned out not to work
effectively for multi-billion key inner relations. We would use
more hash bits than we have, and effectively concentrate all tuples
into a smaller number of batches than we intended. While ideally
we should switch to wider hashes, for now, change the algorithm to
one that effectively gives up bits from the bucket number when we
don't have enough bits. That means we'll finish up with longer
bucket chains than would be ideal, but that's better than having
batches that don't fit in work_mem and can't be divided.
Batch-patch to all supported releases.
Author: Thomas Munro
Reviewed-by: Tom Lane, thanks also to Tomas Vondra, Alvaro Herrera, Andres Freund for testing and discussion
Reported-by: James Coleman
Discussion: https://postgr.es/m/16104-
dc11ed911f1ab9df%40postgresql.org
Joe Conway [Mon, 23 Dec 2019 18:33:25 +0000 (13:33 -0500)]
Disallow null category in crosstab_hash
While building a hash map of categories in load_categories_hash,
resulting category names have not thus far been checked to ensure
they are not null. Prior to pg12 null category names worked to the
extent that they did not crash on some platforms. This is because
those system libraries have an snprintf which can deal with being
passed a null pointer argument for a string. But even in those cases
null categories did nothing useful. And on some platforms it crashed.
As of pg12, our own version of snprintf gets called, and it does
not deal with null pointer arguments at all, and crashes consistently.
Fix that by disallowing null categories. They never worked usefully,
and no one has ever asked for them to work previously. Back-patch to
all supported branches.
Reported-By: Ireneusz Pluta
Discussion: https://postgr.es/m/16176-
7489719b05e4303c@postgresql.org
Tom Lane [Mon, 23 Dec 2019 17:53:12 +0000 (12:53 -0500)]
Disallow partition key expressions that return pseudo-types.
This wasn't checked originally, but it should have been, because
in general pseudo-types can't be stored to and retrieved from disk.
Notably, partition bound values of type "record" would not be
interpretable by another session.
In v12 and HEAD, add another flag to CheckAttributeType's repertoire
so that it can produce a specific error message for this case. That's
infeasible in older branches without an ABI break, so fall back to
a slightly-less-nicely-worded error message in v10 and v11.
Problem noted by Amit Langote, though this patch is not his initial
solution. Back-patch to v10 where partitioning was introduced.
Discussion: https://postgr.es/m/CA+HiwqFUzjfj9HEsJtYWcr1SgQ_=iCAvQ=O2Sx6aQxoDu4OiHw@mail.gmail.com
Tom Lane [Mon, 23 Dec 2019 17:08:23 +0000 (12:08 -0500)]
Prevent a rowtype from being included in itself via a range.
We probably should have thought of this case when ranges were added,
but we didn't. (It's not the fault of commit
eb51af71f, because
ranges didn't exist then.)
It's an old bug, so back-patch to all supported branches.
Discussion: https://postgr.es/m/7782.
1577051475@sss.pgh.pa.us
Alvaro Herrera [Mon, 23 Dec 2019 15:47:36 +0000 (12:47 -0300)]
GetPublicationByName: Don't repeat ourselves
Use get_publication_oid() instead of reimplementing it.
Discussion: https://postgr.es/m/
20191220201017.GA17292@alvherre.pgsql
Peter Geoghegan [Mon, 23 Dec 2019 04:07:45 +0000 (20:07 -0800)]
Normalize _bt_finish_split() argument names.
Make a function prototype argument's name match the function
definition's argument name.
Peter Geoghegan [Mon, 23 Dec 2019 03:57:35 +0000 (19:57 -0800)]
Update nbtree LP_DEAD item deletion comments.
Comments about the consequences of clearing the BTP_HAS_GARBAGE page
flag bit that apply only to VACUUM were added to code that deals with
opportunistic deletion of LP_DEAD items by commit
a760893d. The same
comment block was added to both _bt_delitems_vacuum() and
_bt_delitems_delete(). Correct _bt_delitems_delete()'s copy of the
comment block.
_bt_delitems_delete() reliably deletes items that were found by caller
to have their LP_DEAD bit set. There is no question about whether or
not unsetting the BTP_HAS_GARBAGE bit can miss some LP_DEAD items that
were set recently.
Also tweak a related section of the nbtree README.
Tom Lane [Sun, 22 Dec 2019 23:00:17 +0000 (18:00 -0500)]
Avoid low-probability regression test failures in timestamp[tz] tests.
If the first transaction block in these tests were entered exactly
at midnight (California time), they'd report a bogus failure due
to 'now' and 'midnight' having the same values. Commit
8c2ac75c5
had dismissed this as being of negligible probability, but we've
now seen it happen in the buildfarm, so let's prevent it. We can
get pretty much the same test coverage without an it's-not-midnight
assumption by moving the does-'now'-work cases into their own test step.
While here, apply commit
47169c255's s/DELETE/TRUNCATE/ change to
timestamptz as well as timestamp (not sure why that didn't
occur to me at the time; the risk of failure is the same).
Back-patch to all supported branches, since the main point is
to get rid of potential buildfarm failures.
Discussion: https://postgr.es/m/14821.
1577031117@sss.pgh.pa.us
Peter Eisentraut [Sun, 22 Dec 2019 22:20:00 +0000 (23:20 +0100)]
Fix compiler warning for ppoll() on Cygwin
_GNU_SOURCE is required to get the prototype, so just define that
globally, as was already done in the linux template.
Discussion: https://www.postgresql.org/message-id/flat/
6b467edc-4018-521f-ab18-
171f098557ca%402ndquadrant.com
Tom Lane [Sat, 21 Dec 2019 22:39:36 +0000 (17:39 -0500)]
In pgwin32_open, loop after ERROR_ACCESS_DENIED only if we can't stat.
This fixes a performance problem introduced by commit
6d7547c21.
ERROR_ACCESS_DENIED is returned in some other cases besides the
delete-pending case considered by that commit; notably, if the
given path names a directory instead of a plain file. In that
case we'll uselessly loop for 1 second before returning the
failure condition. That slows down some usage scenarios enough
to cause test timeout failures on our Windows buildfarm critters.
To fix, try to stat() the file, and sleep/loop only if that fails.
It will fail in the delete-pending case, and also in the case where
the deletion completed before we could stat(), so we have the cases
where we want to loop covered. In the directory case, the stat()
should succeed, letting us exit without a wait.
One case where we'll still wait uselessly is if the access-denied
problem pertains to a directory in the given pathname. But we don't
expect that to happen in any performance-critical code path.
There might be room to refine this further, but I'll push it now
in hopes of making the buildfarm green again.
Back-patch, like the preceding commit.
Alexander Lakhin and Tom Lane
Discussion: https://postgr.es/m/23073.
1576626626@sss.pgh.pa.us
Bruce Momjian [Sat, 21 Dec 2019 22:02:38 +0000 (17:02 -0500)]
C comment: clarify why psql's help/exit/quit must alone
Document why no indentation and why no non-whitespace postfix is
supported.
Backpatch-through: master
Bruce Momjian [Sat, 21 Dec 2019 17:44:38 +0000 (12:44 -0500)]
docs: clarify handling of column lists in COPY TO/FROM
Previously it was unclear how COPY FROM handled cases where not all
columns were specified, or if the order didn't match.
Reported-by: pavlo.golub@gmail.com
Discussion: https://postgr.es/m/
157487729344.7213.
14245726713444755296@wrigleys.postgresql.org
Backpatch-through: 9.4
Tom Lane [Fri, 20 Dec 2019 20:45:37 +0000 (15:45 -0500)]
Adjust test case added by commit
6136e94dc.
Per project policy, transient roles created by regression test cases
should be named "regress_something", to reduce the risks of running
such cases against installed servers. And no such role should ever
be left behind after running a test.
Discussion: https://postgr.es/m/11297.
1576868677@sss.pgh.pa.us
Tom Lane [Fri, 20 Dec 2019 20:34:07 +0000 (15:34 -0500)]
libpq should expose GSS-related parameters even when not implemented.
We realized years ago that it's better for libpq to accept all
connection parameters syntactically, even if some are ignored or
restricted due to lack of the feature in a particular build.
However, that lesson from the SSL support was for some reason never
applied to the GSSAPI support. This is causing various buildfarm
members to have problems with a test case added by commit
6136e94dc,
and it's just a bad idea from a user-experience standpoint anyway,
so fix it.
While at it, fix some places where parameter-related infrastructure
was added with the aid of a dartboard, or perhaps with the aid of
the anti-pattern "add new stuff at the end". It should be safe
to rearrange the contents of struct pg_conn even in released
branches, since that's private to libpq (and we'd have to move
some fields in some builds to fix this, anyway).
Back-patch to all supported branches.
Discussion: https://postgr.es/m/11297.
1576868677@sss.pgh.pa.us
Peter Eisentraut [Fri, 20 Dec 2019 11:26:01 +0000 (12:26 +0100)]
Clean up inconsistent backslash use in paths
Most of the MSVC Perl code uses forward slashes for file paths. Make
the few places that use backslashes the same. This also helps running
that code on non-Windows.
Peter Eisentraut [Fri, 20 Dec 2019 07:54:42 +0000 (08:54 +0100)]
Generate pg_config.h from pg_config.h.in on Windows
Previously, the Windows MSVC build generated pg_config.h from a
hard-coded pg_config.h.win32 with some ad hoc postprocessing. The
pg_config.h.win32 file required manual maintenance and was as a result
frequently out of date.
Instead, have the MSVC build scripts emulate what configure and
config.status do: collect a list of defines and then create
pg_config.h from pg_config.h.in by changing the appropriate lines.
The previous setup was made to support old Windows build systems that
didn't have any text processing capabilities, but the current system
has Perl, so it's not a problem. pg_config.h.win32 is removed.
In order to try to keep the Windows side of things more up to date in
the future, we now also require that all symbols found in
pg_config.h.in are defined in the MSVC build system. So if there is a
change in configure that results in a new symbol, an update in
Solution.pm will be required.
The other headers managed by AC_CONFIG_HEADERS in configure, namely
src/include/pg_config_ext.h and
src/interfaces/ecpg/include/ecpg_config.h, get the same treatment, so
this removes even more ad hoc code in the MSVC build scripts.
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://www.postgresql.org/message-id/flat/
1441b834-f434-e0bf-46ed-
9c4d5c29c2d4%402ndquadrant.com
Peter Eisentraut [Fri, 20 Dec 2019 07:25:43 +0000 (08:25 +0100)]
Disallow dropping rules on system tables by default
This was previously not covered by allow_system_table_mods, but now it
is. The impact in practice is probably low, but this makes it
consistent with most other DDL commands.
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/
ee9df1af-c0d8-7c82-5be7-
39ce4e3b0a9d%402ndquadrant.com
Peter Eisentraut [Fri, 20 Dec 2019 07:04:24 +0000 (08:04 +0100)]
Fix compiler warnings on MSYS2
The PS_USE_NONE case in ps_status.c left a couple of unused variables
exposed.
Discussion: https://www.postgresql.org/message-id/flat/
6b467edc-4018-521f-ab18-
171f098557ca%402ndquadrant.com
Andrew Dunstan [Fri, 20 Dec 2019 05:53:34 +0000 (16:23 +1030)]
Superuser can permit passwordless connections on postgres_fdw
Currently postgres_fdw doesn't permit a non-superuser to connect to a
foreign server without specifying a password, or to use an
authentication mechanism that doesn't use the password. This is to avoid
using the settings and identity of the user running Postgres.
However, this doesn't make sense for all authentication methods. We
therefore allow a superuser to set "password_required 'false'" for user
mappings for the postgres_fdw. The superuser must ensure that the
foreign server won't try to rely solely on the server identity (e.g.
trust, peer, ident) or use an authentication mechanism that relies on the
password settings (e.g. md5, scram-sha-256).
This feature is a prelude to better support for sslcert and sslkey
settings in user mappings.
Author: Craig Ringer.
Discussion: https://postgr.es/m/
075135da-545c-f958-fed0-
5dcb462d6dae@2ndQuadrant.com
Robert Haas [Thu, 19 Dec 2019 19:56:20 +0000 (14:56 -0500)]
Extend the ProcSignal mechanism to support barriers.
A new function EmitProcSignalBarrier() can be used to emit a global
barrier which all backends that participate in the ProcSignal
mechanism must absorb, and a new function WaitForProcSignalBarrier()
can be used to wait until all relevant backends have in fact
absorbed the barrier.
This can be used to coordinate global state changes, such as turning
checksums on while the system is running.
There's no real client of this mechanism yet, although two are
proposed, but an enum has to have at least one element, so this
includes a placeholder type (PROCSIGNAL_BARRIER_PLACEHOLDER) which
should be replaced by the first real client of this mechanism to
get committed.
Andres Freund and Robert Haas, reviewed by Daniel Gustafsson and,
in earlier versions, by Magnus Hagander.
Discussion: http://postgr.es/m/CA+TgmoZwDk=BguVDVa+qdA6SBKef=PKbaKDQALTC_9qoz1mJqg@mail.gmail.com
Peter Geoghegan [Thu, 19 Dec 2019 19:35:55 +0000 (11:35 -0800)]
Remove unneeded "pin scan" nbtree VACUUM code.
The REDO routine for nbtree's xl_btree_vacuum record type hasn't
performed a "pin scan" since commit
3e4b7d87 went in, so clearly there
isn't any point in VACUUM WAL-logging information that won't actually be
used. Finish off the work of commit
3e4b7d87 (and the closely related
preceding commit
687f2cd7) by removing the code that generates this
unused information. Also remove the REDO routine code disabled by
commit
3e4b7d87.
Replace the unneeded lastBlockVacuumed field in xl_btree_vacuum with a
new "ndeleted" field. The new field isn't actually needed right now,
since we could continue to infer the array length from the overall
record length. However, an upcoming patch to add deduplication to
nbtree needs to add an "items updated" field to xl_btree_vacuum, so we
might as well start being explicit about the number of items now.
(Besides, it doesn't seem like a good idea to leave the xl_btree_vacuum
struct without any fields; the C standard says that that's undefined.)
nbtree VACUUM no longer forces writing a WAL record for the last block
in the index. Writing out a WAL record with no items for the final
block was supposed to force processing of a lastBlockVacuumed field by a
pin scan.
Bump XLOG_PAGE_MAGIC because xl_btree_vacuum changed.
Discussion: https://postgr.es/m/CAH2-WzmY_mT7UnTzFB5LBQDBkKpdV5UxP3B5bLb7uP%3D%3D6UQJRQ%40mail.gmail.com
Bruce Momjian [Thu, 19 Dec 2019 16:19:10 +0000 (11:19 -0500)]
revert: Remove meaningless assignments in nbtree code
Reverts commit
05684c8255.
Reported-by: Tom Lane
Discussion: https://postgr.es/m/404.
1576770942@sss.pgh.pa.us
Backpatch-through: master
Bruce Momjian [Thu, 19 Dec 2019 15:33:48 +0000 (10:33 -0500)]
Remove meaningless assignments in nbtree code
Reported-by: Ranier Vilela
Discussion: https://postgr.es/m/MN2PR18MB2927BB876D12A70FDBE8F35AE3450@MN2PR18MB2927.namprd18.prod.outlook.com
Backpatch-through: master
Alvaro Herrera [Thu, 19 Dec 2019 15:08:30 +0000 (12:08 -0300)]
makeArrayTypeName: Remove pointless relation open/close
Discussion: https://postgr.es/m/
20191218221326.GA25537@alvherre.pgsql
Tom Lane [Thu, 19 Dec 2019 14:42:39 +0000 (09:42 -0500)]
Doc: add a short summary of available authentication methods.
The "auth-methods" <sect1> used to include descriptions of all our
authentication methods. Commit
56811e573 promoted its child <sect2>'s
to <sect1>'s, which has advantages but also created some issues:
* The auth-methods page itself is essentially empty/useless.
* Links that pointed to "auth-methods" as a placeholder for all
auth methods were rendered a bit nonsensical.
* DocBook no longer provides a subsection table-of-contents here,
which formerly was a useful if terse summary of available auth methods.
To improve matters, add a handwritten list of all the auth methods.
Per gripe from Dave Cramer. Back-patch to v11 where the previous
commit came in.
Discussion: https://postgr.es/m/CADK3HH+xQLhcPgg=kWqfogtXGGZr-JdSo=x=WQC0PkAVyxUWyQ@mail.gmail.com