Robert Haas [Thu, 1 Aug 2019 18:56:54 +0000 (14:56 -0400)] Dummy AM for experimentation.
Robert Haas [Tue, 18 Jun 2019 17:43:43 +0000 (13:43 -0400)] Allow TOAST tables to be implemented using table AMs other than heap.
toast_fetch_datum, toast_save_datum, and toast_delete_datum are
adjusted to use tableam rather than heap-specific functions. This
might have some performance impact, but this attempts to
mitigate that by restructuring things so that we don't open and close
the toast table and indexes multiple times per tuple.
tableam now exposes an integer value (not a callback) for the
maximum TOAST chunk size, and has a new callback allowing table
AMs to specify the AM that should be used to implement the TOAST
table. Previously, the toast AM was always the same as the table AM.
Robert Haas [Tue, 14 May 2019 21:11:28 +0000 (17:11 -0400)] Create an API for inserting and deleting rows in TOAST tables.
This moves much of the non-heap-specific logic from toast_delete and
toast_insert_or_update into a helper functions accessible via a new
header, toast_helper.h. Using the functions in this module, a table
AM can implement creation and deletion of TOAST table rows with
much less code duplication than was possible heretofore. Some
table AMs won't want to use the TOAST logic at all, but for those
that do this will make that easier.
Robert Haas [Wed, 15 May 2019 17:33:16 +0000 (13:33 -0400)] Split tuptoaster.c into three separate files.
detoast.c/h contain functions required to detoast a datum, partially
or completely, plus a few other utility functions for examining the
size of toasted datums.
toast_internals.c/h contain functions that are used internally to the
TOAST subsystem but which (mostly) do not need to be accessed from
outside.
heaptoast.c/h contains code that is intrinsically specific to the
heap AM, either because it operates on HeapTuples or is based on the
layout of a heap page.
detoast.c and toast_internals.c are placed in
src/backend/access/common rather than src/backend/access/heap. At
present, both files still have dependencies on the heap, but that will
be improved in a future commit.
Amit Kapila [Thu, 13 Jun 2019 10:33:49 +0000 (16:03 +0530)] Allow execution and discard of undo by background workers.
Undo launcher is responsible for launching the workers iff there is some
work available in one of the work queues and there are more workers
available. The worker is launched to handle requests for a particular
database.
The discard worker is responsible for discarding the undo log of
transactions that are committed and all-visible or are rolled-back. It
also registers the request for aborted transactions in the work queues.
It iterates through all the active logs one-by-one and tries to discard the
transactions that are old enough to matter.
We don't allow any transaction older than 2^31 to have pending undo actions.
Also, we have a hard limit on the number of transactions that can have
pending undo which is proportional to pending_undo_queue_size.
Amit Kapila, Dilip Kumar and Kuntal Ghosh with inputs from Andres Freund,
Robert Haas and Thomas Munro.
Amit Kapila [Thu, 13 Jun 2019 10:12:46 +0000 (15:42 +0530)] Allow foreground transactions to perform undo actions on abort.
We always perform rollback actions after cleaning up the current
(sub)transaction. This will ensure that we perform the actions immediately
after an error (and release the locks) rather than when the user issues
Rollback command at some later point of time. We are releasing the locks
after the undo actions are applied. The reason to delay lock release is
that if we release locks before applying undo actions, then the parallel
session can acquire the lock before us which can lead to deadlock.
Amit Kapila and Dilip Kumar with inputs from Robert Haas
Amit Kapila [Thu, 13 Jun 2019 09:57:58 +0000 (15:27 +0530)] Infrastructure to execute pending undo actions.
To apply the undo actions, we collect the undo records in bulk and try to
process them together. We ensure to update the transaction's progress at
regular intervals so that after a crash we can skip already applied undo.
This provides a way for users to register a callback for processing the
undo records based on resource manager.
Dilip Kumar, Amit Kapila, Thomas Munro and Kuntal Ghosh with inputs from
Robert Haas
Amit Kapila [Thu, 13 Jun 2019 09:40:06 +0000 (15:10 +0530)] Infrastructure to register and fetch undo action requests.
This infrasture provides a way to allow execution of undo actions. One
might think that we can always execute undo actions on error or explicit
rollabck by user, however there are cases when that is not posssible.
For example, (a) if the system crash while doing operation, then after
startup, we need a way to perform undo actions; (b) If we get error while
performing undo actions.
Apart from this, when there are large rollback requests, then it is quite
inefficient to perform all the undo actions and then return control to
user.
To allow efficient execution of the undo actions, we create three queues
and a hash table for the rollback requests. A Xid based priority queue
which will allow us to process the requests of older transactions and help
us to move oldesdXidHavingUnappliedUndo (this is a xid-horizon below which
all the transactions are visible) forward. A size-based queue which will
help us to perform the rollbacks of larger aborts in a timely fashion so
that we don't get stuck while processing them during discard of the logs.
An error queue to hold the requests for transactions that failed to apply
its undo. The rollback hash table is used to avoid duplicate undo requests
by backends and discard worker.
Amit Kapila and Kuntal Ghosh, design idea by Andres Freund.
Amit Kapila [Mon, 27 May 2019 08:32:23 +0000 (14:02 +0530)] Extend binary heap functionality.
Add the routines to allocate binary heap in shared memory and to remove
nth element from binray heap. This routines will be used by latter commit
to add support for undo workers.
Author: Kuntal Ghosh and Amit Kapila
Dilip Kumar [Thu, 4 Jul 2019 06:22:55 +0000 (11:52 +0530)] undo page consistency checker
provide a mechanism for masking the cid bit in undo pages so that
consistecy checker function can compared the undo pages. Actual consistency
check should be called under the RM's consistency checker function who is
writing the undo because undo pages will be registered under that RM's WAL
Dilip Kumar with help from Amit Khandekar and Rafia Sabih
Dilip Kumar [Thu, 2 May 2019 05:58:13 +0000 (11:28 +0530)] Provide interfaces to store and fetch undo records.
Add the capability to form undo records and store them in undo logs. We
also provide the capability to fetch the undo records. This layer will use
undo-log-storage to reserve the space for the undo records and buffer
management routines to write and read the undo records.
Undo records are stored in sequential order in the undo log. Each undo
record consists of a variable length header, tuple data, and payload
information. The undo records are stored without any sort of alignment
padding and a undo record can span across multiple pages. The undo records
for a transaction can span across multiple undo logs.
Author: Dilip Kumar with contributions from Robert Haas, Amit Kapila,
Thomas Munro, Vignesh C and Rafia Sabih
Reviewed-by: Earlier version of this is reviewed by Amit Kapila
Tested-by: Neha Sharma
Discussion: https://www.postgresql.org/message-id/CAFiTN-uVxxopn0UZ64%3DF-sydbETBbGjWapnBikNo1%3DXv78UeFw%40mail.gmail.com
Dilip Kumar [Fri, 7 Jun 2019 09:33:37 +0000 (15:03 +0530)] Defect and enhancement in multi-log support
Dilip Kumar [Wed, 24 Apr 2019 09:06:28 +0000 (14:36 +0530)] Add prefetch support for the undo log
Add prefetching function for undo smgr and also provide mechanism
to prefetch without relcache.
Dilip Kumar
Thomas Munro [Fri, 11 Jan 2019 13:17:02 +0000 (02:17 +1300)] Allow WAL record data on first modification after a checkpoint.
Provide a way to attach data to WAL record conditionally, so that it is
included only if this turns out to the be first modification to a given
block after a checkpoint.
This will be used to record undo log meta-data, to avoid a data
synchronization problem with online checkpoints.
Author: Thomas Munro
Reviewed-by:
Discussion:
Thomas Munro [Wed, 6 Mar 2019 03:46:04 +0000 (16:46 +1300)] Add undo log manager.
Add a new subsystem to manage undo logs. Undo logs allow data to be appended
efficiently, like logs. They also allow data to be discarded efficiently from
the other end, like a queue. Thirdly, they allow efficient buffered random
access, like a relation.
Undo logs physically consist of a set of 1MB segment files under
$PGDATA/base/undo (or per-tablespace equivalent) that are created, deleted or
renamed as required, similarly to the way that WAL segments are managed.
Meta-data about the set of undo logs is stored in shared memory, and written
to per-checkpoint files under $PGDATA/pg_undo.
Provide access to the undo files managed by undolog.c through bufmgr.c.
A new SMGR implementation allows bufmgr.c to access files created by
undolog.c.
Author: Thomas Munro, with contributions from Dilip Kumar, Rafia Sabih,
Robert Haas and Amit Kapila
Reviewed-by:
Discussion: https://postgr.es/m/CAEepm%3D2EqROYJ_xYz4v5kfr4b0qw_Lq_6Pe8RTEC8rx3upWsSQ%40mail.gmail.com
Thomas Munro [Wed, 17 Jul 2019 02:15:27 +0000 (14:15 +1200)] Prepare to support multiple SMGR implementations.
Move the "which" decision into a function that later es can add
to.
Author: Thomas Munro
Thomas Munro [Wed, 17 Jul 2019 00:14:08 +0000 (12:14 +1200)] Move some md.c-specific logic from smgr.c to md.c.
Potential future SMGR implementations may not want to create
tablespace directories when creating an SMGR relation. Move that
logic to mdcreate(). Move the initialization of md-specific
data structures from smgropen() to a new callback mdopen().
Author: Thomas Munro
Reviewed-by: Shawn Debnath (as part of an earlier set)
Discussion: https://postgr.es/m/CA%2BhUKG%2BOZqOiOuDm5tC5DyQZtJ3FH4%2BFSVMqtdC4P1atpJ%2Bqhg%40mail.gmail.com
Tom Lane [Tue, 16 Jul 2019 22:17:47 +0000 (18:17 -0400)] Fix thinko in construction of old_conpfeqop list.
This should lappend the OIDs, not lcons them; the existing code produced
a list in reversed order. This is harmless for single-key FKs or FKs
where all the key columns are of the same type, which probably explains
how it went unnoticed. But if those conditions are not met,
ATAddForeignKeyConstraint would make the wrong decision about whether an
existing FK needs to be revalidated. I think it would almost always err
in the safe direction by revalidating a constraint that didn't need it.
You could imagine scenarios where the pfeqop check was fooled by
swapping the types of two FK columns in one ALTER TABLE, but that case
would probably be rejected by other tests, so it might be impossible to
get to the worst-case scenario where an FK should be revalidated and
isn't. (And even then, it's likely to be fine, unless there are weird
inconsistencies in the equality behavior of the replacement types.)
However, this is a performance bug at least.
Noted while poking around to see whether lcons calls could be converted
to lappend.
This bug is old, dating to commit
cb3a7c2b9, so back- to all
supported branches.
Tom Lane [Tue, 16 Jul 2019 17:12:24 +0000 (13:12 -0400)] Remove lappend_cell...() family of List functions.
It seems worth getting rid of these functions because they require the
caller to retain a ListCell pointer into a List that it's modifying,
which is a dangerous practice with the new List implementation.
(The only other List-modifying function that takes a ListCell pointer
as input is list_delete_cell, which nowadays is preferentially used
via the constrained API foreach_delete_current.)
There was only one remaining caller of these functions after commit
2f5b8eb5a, and that was some fairly ugly GEQO code that can be much
more clearly expressed using a list-index variable and list_insert_nth.
Hence, rewrite that code, and remove the functions.
Discussion: https://postgr.es/m/26193.
1563228600@sss.pgh.pa.us
Tom Lane [Tue, 16 Jul 2019 16:04:06 +0000 (12:04 -0400)] Clean up some ad-hoc code for sorting and de-duplicating Lists.
heap.c and relcache.c contained nearly identical copies of logic
to insert OIDs into an OID list while preserving the list's OID
ordering (and rejecting duplicates, in one case but not the other).
The comments argue that this is faster than qsort for small numbers
of OIDs, which is at best unproven, and seems even less likely to be
true now that lappend_cell_oid has to move data around. In any case
it's ugly and hard-to-follow code, and if we do have a lot of OIDs
to consider, it's O(N^2).
Hence, replace with simply lappend'ing OIDs to a List, then list_sort
the completed List, then remove adjacent duplicates if necessary.
This is demonstrably O(N log N) and it's much simpler for the
callers. It's possible that this would be somewhat inefficient
if there were a very large number of duplicates, but that seems
unlikely in the existing usage.
This adds list_deduplicate_oid and list_oid_cmp infrastructure
to list.c. I didn't bother with equivalent functionality for
integer or pointer Lists, but such could always be added later
if we find a use for it.
Discussion: https://postgr.es/m/26193.
1563228600@sss.pgh.pa.us
Tom Lane [Tue, 16 Jul 2019 15:51:44 +0000 (11:51 -0400)] Redesign the API for list sorting (list_qsort becomes list_sort).
In the wake of commit
1cff1b95a, the obvious way to sort a List
is to apply qsort() directly to the array of ListCells. list_qsort
was building an intermediate array of pointers-to-ListCells, which
we no longer need, but getting rid of it forces an API change:
the comparator functions need to do one less level of indirection.
Since we're having to touch the callers anyway, let's do two additional
changes: sort the given list in-place rather than making a copy (as
none of the existing callers have any use for the copying behavior),
and rename list_qsort to list_sort. It was argued that the old name
exposes more about the implementation than it should, which I find
pretty questionable, but a better reason to rename it is to be sure
we get the attention of any external callers about the need to fix
their comparator functions.
While we're at it, change four existing callers of qsort() to use
list_sort instead; previously, they all had local reinventions
of list_qsort, ie build-an-array-from-a-List-and-qsort-it.
(There are some other places where changing to list_sort perhaps
would be worthwhile, but they're less obviously wins.)
Discussion: https://postgr.es/m/29361.
1563220190@sss.pgh.pa.us
Michael Paquier [Tue, 16 Jul 2019 04:23:53 +0000 (13:23 +0900)] Fix inconsistencies and typos in the tree
This is numbered take 7, and addresses a set of issues around:
- Fixes for typos and incorrect reference names.
- Removal of unneeded comments.
- Removal of unreferenced functions and structures.
- Fixes regarding variable name consistency.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/
10bfd4ac-3e7c-40ab-2b2e-
355ed15495e8@gmail.com
Tom Lane [Tue, 16 Jul 2019 03:27:13 +0000 (23:27 -0400)] Remove dead code.
These memory context switches are useless in the wake of commit
1cff1b95a. Noted by Jesper Pedersen.
Discussion: https://postgr.es/m/
f078ce63-9e04-0f3e-d200-
d7ee66279abe@redhat.com
Bruce Momjian [Tue, 16 Jul 2019 00:57:24 +0000 (20:57 -0400)] doc: mention pg_reload_conf() for reloading the config file
Reported-by: Ian BarwickDiscussion: https://postgr.es/m/
538950ec-b86a-1650-6078-
beb7091c09c2@2ndquadrant.com
Back-through: 9.4
Thomas Munro [Mon, 15 Jul 2019 23:53:12 +0000 (11:53 +1200)] Provide pgbench --show-script to dump built-in scripts.
Author: Fabien Coelho
Reviewed-by: Ibrar AhmedDiscussion: https://postgr.es/m/alpine.DEB.2.21.
1904081737390.5867%40lancre
Thomas Munro [Mon, 15 Jul 2019 23:31:44 +0000 (11:31 +1200)] Report the time taken by pgbench initialization steps.
Author: Fabien Coelho
Reviewed-by: Ibrar AhmedDiscussion: https://postgr.es/m/alpine.DEB.2.21.
1904061810510.3678%40lancre
Peter Geoghegan [Mon, 15 Jul 2019 21:35:06 +0000 (14:35 -0700)] Correct nbtsplitloc.c comment.
The logic just added by commit
e3899ffd falls back on a 50:50 page split
in the event of a new item that's just to the right of our provisional
"many duplicates" split point. Fix a comment that incorrectly claimed
that the new item had to be just to the left of our provisional split
point.
Back: 12-, just like commit
e3899ffd.
Peter Geoghegan [Mon, 15 Jul 2019 20:19:13 +0000 (13:19 -0700)] Fix pathological nbtree split point choice issue.
Specific ever-decreasing insertion patterns could cause successive
unbalanced nbtree page splits. Problem cases involve a large group of
duplicates to the left, and ever-decreasing insertions to the right.
To fix, detect the situation by considering the newitem offset before
performing a split using nbtsplitloc.c's "many duplicates" strategy. If
the new item was inserted just to the right of our provisional "many
duplicates" split point, infer ever-decreasing insertions and fall back
on a 50:50 (space delta optimal) split. This seems to barely affect
cases that already had acceptable space utilization.
An alternative fix also seems possible. Instead of changing
nbtsplitloc.c split choice logic, we could instead teach _bt_truncate()
to generate a new value for new high keys by interpolating from the
lastleft and firstright key values. That would certainly be a more
elegant fix, but it isn't suitable for backing.
Discussion: https://postgr.es/m/CAH2-WznCNvhZpxa__GqAa1fgQ9uYdVc=_apArkW2nc-K3O7_NA@mail.gmail.com
Back: 12-, where the nbtree page split enhancements were introduced.
Tom Lane [Mon, 15 Jul 2019 17:41:58 +0000 (13:41 -0400)] Represent Lists as expansible arrays, not chains of cons-cells.
Originally, Postgres Lists were a more or less exact reimplementation of
Lisp lists, which consist of chains of separately-allocated cons cells,
each having a value and a next-cell link. We'd hacked that once before
(commit
d0b4399d8) to add a separate List header, but the data was still
in cons cells. That makes some operations -- notably list_nth() -- O(N),
and it's bulky because of the next-cell pointers and per-cell palloc
overhead, and it's very cache-unfriendly if the cons cells end up
scattered around rather than being adjacent.
In this rewrite, we still have List headers, but the data is in a
resizable array of values, with no next-cell links. Now we need at
most two palloc's per List, and often only one, since we can allocate
some values in the same palloc call as the List header. (Of course,
extending an existing List may require repalloc's to enlarge the array.
But this involves just O(log N) allocations not O(N).)
Of course this is not without downsides. The key difficulty is that
addition or deletion of a list entry may now cause other entries to
move, which it did not before.
For example, that breaks foreach() and sister macros, which historically
used a pointer to the current cons-cell as loop state. We can repair
those macros transparently by making their actual loop state be an
integer list index; the exposed "ListCell *" pointer is no longer state
carried across loop iterations, but is just a derived value. (In
practice, modern compilers can optimize things back to having just one
loop state value, at least for simple cases with inline loop bodies.)
In principle, this is a semantics change for cases where the loop body
inserts or deletes list entries ahead of the current loop index; but
I found no such cases in the Postgres code.
The change is not at all transparent for code that doesn't use foreach()
but chases lists "by hand" using lnext(). The largest share of such
code in the backend is in loops that were maintaining "prev" and "next"
variables in addition to the current-cell pointer, in order to delete
list cells efficiently using list_delete_cell(). However, we no longer
need a previous-cell pointer to delete a list cell efficiently. Keeping
a next-cell pointer doesn't work, as explained above, but we can improve
matters by changing such code to use a regular foreach() loop and then
using the new macro foreach_delete_current() to delete the current cell.
(This macro knows how to update the associated foreach loop's state so
that no cells will be missed in the traversal.)
There remains a nontrivial risk of code assuming that a ListCell *
pointer will remain good over an operation that could now move the list
contents. To help catch such errors, list.c can be compiled with a new
define symbol DEBUG_LIST_MEMORY_USAGE that forcibly moves list contents
whenever that could possibly happen. This makes list operations
significantly more expensive so it's not normally turned on (though it
is on by default if USE_VALGRIND is on).
There are two notable API differences from the previous code:
* lnext() now requires the List's header pointer in addition to the
current cell's address.
* list_delete_cell() no longer requires a previous-cell argument.
These changes are somewhat unfortunate, but on the other hand code using
either function needs inspection to see if it is assuming anything
it shouldn't, so it's not all bad.
Programmers should be aware of these significant performance changes:
* list_nth() and related functions are now O(1); so there's no
major access-speed difference between a list and an array.
* Inserting or deleting a list element now takes time proportional to
the distance to the end of the list, due to moving the array elements.
(However, it typically *doesn't* require palloc or pfree, so except in
long lists it's probably still faster than before.) Notably, lcons()
used to be about the same cost as lappend(), but that's no longer true
if the list is long. Code that uses lcons() and list_delete_first()
to maintain a stack might usefully be rewritten to push and pop at the
end of the list rather than the beginning.
* There are now list_insert_nth...() and list_delete_nth...() functions
that add or remove a list cell identified by index. These have the
data-movement penalty explained above, but there's no search penalty.
* list_concat() and variants now copy the second list's data into
storage belonging to the first list, so there is no longer any
sharing of cells between the input lists. The second argument is
now declared "const List *" to reflect that it isn't changed.
This just does the minimum needed to get the new implementation
in place and fix bugs exposed by the regression tests. As suggested
by the foregoing, there's a fair amount of followup work remaining to
do.
Also, the ENABLE_LIST_COMPAT macros are finally removed in this
commit. Code using those should have been gone a dozen years ago.
by me; thanks to David Rowley, Jesper Pedersen, and others
for review.
Discussion: https://postgr.es/m/11587.
1550975080@sss.pgh.pa.us
Thomas Munro [Mon, 15 Jul 2019 05:03:46 +0000 (17:03 +1200)] Provide XLogRecGetFullXid().
In order to be able to work with FullTransactionId values during replay
without increasing the size of the WAL, infer the epoch. In general we
can't do that safely, but during replay we can because we know that
nextFullXid can't advance concurrently.
Prevent frontend code from seeing this new function, due to the above
restriction. Perhaps in future it will be possible to extract the value
entirely from independent WAL records, and then this restriction can be
lifted.
Author: Thomas Munro, based on earlier code from Andres Freund
Discussion: https://postgr.es/m/CA%2BhUKG%2BmLmuDjMi6o1dxkKvGRL56Y2Rz%2BiXAcrZV03G9ZuFQ8Q%40mail.gmail.com
Peter Eisentraut [Sun, 14 Jul 2019 12:30:27 +0000 (14:30 +0200)] Add gen_random_uuid function
This adds a built-in function to generate UUIDs.
PostgreSQL hasn't had a built-in function to generate a UUID yet,
relying on external modules such as uuid-ossp and pgcrypto to provide
one. Now that we have a strong random number generator built-in, we
can easily provide a version 4 (random) UUID generation function.
This takes the existing function gen_random_uuid() from pgcrypto
and makes it a built-in function. The pgcrypto implementation now
internally redirects to the built-in one.
Reviewed-by: Fabien COELHO <[email protected]>Discussion: https://www.postgresql.org/message-id/
6a65610c-46fc-2323-6b78-
e8086340a325@2ndquadrant.com
Alexander Korotkov [Sun, 14 Jul 2019 12:22:21 +0000 (15:22 +0300)] Forgotten catversion bump
6254c55f81,
c085e1c1cb and
075f0a880f all change system catalog. But
catversion bump is missed in all of them. So, do catversion bump now.
Also, I need mention reviewer Fabien Coelho, who has been missed in
commit messages of
6254c55f81,
c085e1c1cb and
075f0a880f.
Alexander Korotkov [Sun, 14 Jul 2019 11:57:53 +0000 (14:57 +0300)] Add support for <-> (box, point) operator to SP-GiST box_ops
Opclass support functions already can handle this operator, just catalog
adjustment appears to be required.
Discussion: https://postgr.es/m/
f71ba19d-d989-63b6-f04a-
abf02ad9345d%40postgrespro.ru
Author: Nikita Glukhov
Reviewed-by: Tom Lane, Alexander KorotkovAlexander Korotkov [Sun, 14 Jul 2019 11:56:18 +0000 (14:56 +0300)] Add support for <-> (box, point) operator to GiST box_ops
Index-based calculation of this operator is exact. So, signature of
gist_bbox_distance() function is changes so that caller is responsible for
setting *recheck flag.
Discussion: https://postgr.es/m/
f71ba19d-d989-63b6-f04a-
abf02ad9345d%40postgrespro.ru
Author: Nikita Glukhov
Reviewed-by: Tom Lane, Alexander KorotkovAlexander Korotkov [Sun, 14 Jul 2019 11:55:01 +0000 (14:55 +0300)] Add missing commutators for distance operators
Some of <-> operators between geometric types have their commutators missed.
This commit adds them. The motivation is upcoming kNN support for some of those
operators.
Discussion: https://postgr.es/m/
f71ba19d-d989-63b6-f04a-
abf02ad9345d%40postgrespro.ru
Author: Nikita Glukhov
Reviewed-by: Tom Lane, Alexander KorotkovAndrew Gierth [Sun, 14 Jul 2019 11:07:40 +0000 (12:07 +0100)] Teach pg_stat_statements not to ignore FOR UPDATE clauses
Performance of a SELECT FOR UPDATE may be quite distinct from the
non-UPDATE version of the query, so treat all of the FOR UPDATE clause
as being significant for distinguishing queries.
Andrew Gierth and Vik Fearing, reviewed by Sergei Kornilov, Thomas
Munro, Tom Lane
Discussion: https://postgr.es/m/
[email protected]Thomas Munro [Sun, 14 Jul 2019 02:19:54 +0000 (14:19 +1200)] Fix documentation for pgbench tpcb-like.
We choose a random value for delta, not balance. Back- to 9.6 where
the mistake arrived.
Author: Fabien Coelho
Discussion: https://postgr.es/m/alpine.DEB.2.21.
1904081752210.5867@lancre
Noah Misch [Sat, 13 Jul 2019 20:34:22 +0000 (13:34 -0700)] Revive test of concurrent OID generation.
Commit
578b229718e8f15fa779e20f086c4b6bb3776106 replaced it with a
concurrent "nextval" test. That version does not detect PostgreSQL's
incompatibility with xlc 13.1.3, so bring back an OID-based test that
does. Back- to v12, where that commit first appeared.
Discussion: https://postgr.es/m/
20190707170035[email protected]Michael Paquier [Sat, 13 Jul 2019 07:51:31 +0000 (16:51 +0900)] Fix some inconsistencies in MSVC scripts
In configure scripts, --with-ossp-uuid is obsolete is replaced by
--with-uuid, and it needs to specify a path to its library builds when
building with the MSVC scripts. --with-perl needs also to specify a
path.
Author: Kyotaro Horiguchi
Discussion: https://postgr.es/m/
20190712.121529.
194600624[email protected]Michael Paquier [Sat, 13 Jul 2019 05:43:29 +0000 (14:43 +0900)] Fix and improve several places in the docs
This adds some missing markups, fixes a couple of incorrect ones and
clarifies some documentation in various places.
Author: Liudmila Mantrova
Discussion: https://postgr.es/m/
a068f947-7a51-5df1-b3fd-
1a131ae5c044@postgrespro.ru
Back-through: 12
Thomas Munro [Sat, 13 Jul 2019 03:56:20 +0000 (15:56 +1200)] Fix tab completion for UPDATE.
Previously it suggested an extra "=" after "SET x=".
Reported-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/CA%2BhUKGLk%3D0yLDjfviONJLzcHEzygj%3Dx6VbGH43LnXbBUvQb52g%40mail.gmail.com
Thomas Munro [Sat, 13 Jul 2019 03:51:52 +0000 (15:51 +1200)] Tab completion for CREATE TYPE.
Author: Thomas Munro
Reviewed-by: Kyotaro Horiguchi
Discussion: https://postgr.es/m/CA%2BhUKGLk%3D0yLDjfviONJLzcHEzygj%3Dx6VbGH43LnXbBUvQb52g%40mail.gmail.com
Thomas Munro [Sat, 13 Jul 2019 01:55:10 +0000 (13:55 +1200)] Forward received condition variable signals on cancel.
After a process decides not to wait for a condition variable, it can
still consume a signal before it reaches ConditionVariableCancelSleep().
In that case, pass the signal on to another waiter if possible, so that
a signal doesn't go missing when there is another process ready to
receive it.
Author: Thomas Munro
Reviewed-by: Shawn Debnath
Discussion: https://postgr.es/m/CA%2BhUKGLQ_RW%2BXs8znDn36e-%2Bmq2--zrPemBqTQ8eKT-VO1OF4Q%40mail.gmail.com
Thomas Munro [Sat, 13 Jul 2019 01:40:36 +0000 (13:40 +1200)] Introduce timed waits for condition variables.
Provide ConditionVariableTimedSleep(), like ConditionVariableSleep()
but with a timeout argument.
Author: Shawn Debnath
Reviewed-by: Kyotaro Horiguchi, Thomas MunroDiscussion: https://postgr.es/m/
eeb06007ccfe46e399df6af18bfcd15a@EX13D05UWC002.ant.amazon.com
Thomas Munro [Fri, 12 Jul 2019 22:35:34 +0000 (10:35 +1200)] Warn if wal_level is too low when creating a publication.
Provide a hint to users that they need to increase wal_level before
subscriptions can work.
Author: Lucas Viecelli, with some adjustments by Thomas Munro
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/CAPjy-57rn5Y9g4e5u--eSOP-7P4QrE9uOZmT2ZcUebF8qxsYhg%40mail.gmail.com
Tom Lane [Fri, 12 Jul 2019 20:24:59 +0000 (16:24 -0400)] Fix get_actual_variable_range() to cope with broken HOT chains.
Commit
3ca930fc3 modified get_actual_variable_range() to use a new
"SnapshotNonVacuumable" snapshot type for selecting tuples that it
would consider valid. However, because that snapshot type can accept
recently-dead tuples, this caused a bug when using a recently-created
index: we might accept a recently-dead tuple that is an early member
of a broken HOT chain and does not actually match the index entry.
Then, the data extracted from the heap tuple would not necessarily be
an endpoint value of the column; it could even be NULL, leading to
get_actual_variable_range() itself reporting "found unexpected null
value in index". Even without an error, this could lead to poor
plan choices due to an erroneous notion of the endpoint value.
We can improve matters by changing the code to use the index-only
scan technique (which didn't exist when get_actual_variable_range was
originally written). If any of the tuples in a HOT chain are live
enough to satisfy SnapshotNonVacuumable, we take the data from the
index entry, ignoring what is in the heap. This fixes the problem
without changing the live-vs-dead-tuple behavior from what was
intended by commit
3ca930fc3.
A side benefit is that for static tables we might not have to touch
the heap at all (when the extremal value is in an all-visible page).
In addition, we can save some overhead by not having to create a
complete ExecutorState, and we don't need to run FormIndexDatum,
avoiding more cycles as well as the possibility of failure for
indexes on expressions. (I'm not sure that this code would ever
be used to determine the extreme value of an expression, in the
current state of the planner; but it's definitely possible that
lower-order columns of the selected index could be expressions.
So one could construct perhaps-artificial examples in which the
old code unexpectedly failed due to trying to compute an
expression's value for a now-dead row.)
Per report from Manuel Rigger. Back- to v11 where commit
3ca930fc3 came in.
Discussion: https://postgr.es/m/CA+u7OA7W4NWEhCvftdV6_8bbm2vgypi5nuxfnSEJQqVKFSUoMg@mail.gmail.com
David Rowley [Fri, 12 Jul 2019 07:12:38 +0000 (19:12 +1200)] Fix RANGE partition pruning with multiple boolean partition keys
match_clause_to_partition_key incorrectly would return
PARTCLAUSE_UNSUPPORTED if a bool qual could not be matched to the current
partition key. This was a problem, as it causes the calling function to
discard the qual and not try to match it to any other partition key. If
there was another partition key which did match this qual, then the qual
would not be checked again and we could fail to prune some partitions.
The worst this could do was to cause partitions not to be pruned when they
could have been, so there was no danger of incorrect query results here.
Fix this by changing match_boolean_partition_clause to have it return a
PartClauseMatchStatus rather than a boolean value. This allows it to
communicate if the qual is unsupported or if it just does not match this
particular partition key, previously these two cases were treated the
same. Now, if match_clause_to_partition_key is unable to match the qual
to any other qual type then we can simply return the value from the
match_boolean_partition_clause call so that the calling function properly
treats the qual as either unmatched or unsupported.
Reported-by: Rares Salcudean
Reviewed-by: Amit Langote
Back-through: 11 where partition pruning was introduced
Discussion: https://postgr.es/m/CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com
Alexander Korotkov [Thu, 11 Jul 2019 15:18:15 +0000 (18:18 +0300)] Fixes for jsonpath filter expression elements table in docs
Reported-by: Thom Brown
Discussion: https://postgr.es/m/CAA-aLv4Tggy6Z3kaG9n%2B3SHwOVGN2Yj_MJXfdfwjH_jBNZzJNA%40mail.gmail.com
Back-through: 12
Tom Lane [Wed, 10 Jul 2019 18:32:28 +0000 (14:32 -0400)] Reduce memory consumption for multi-statement query strings.
Previously, exec_simple_query always ran parse analysis, rewrite, and
planning in MessageContext, allowing all the data generated thereby
to persist until the end of processing of the whole query string.
That's fine for single-command strings, but if a client sends many
commands in a single simple-Query message, this strategy could result
in annoying memory bloat, as complained of by Andreas Seltenreich.
To fix, create a child context to do this work in, and reclaim it
after each command. But we only do so for parsetrees that are not
last in their query string. That avoids adding any memory management
overhead for the typical case of a single-command string. Memory
allocated for the last parsetree would be freed immediately after
finishing the command string anyway.
Similarly, adjust extension.c's execute_sql_string() to reclaim memory
after each command. In that usage, multi-command strings are the norm,
so it's a bit surprising that no one has yet complained of bloat ---
especially since the bloat extended to whatever data ProcessUtility
execution might .
Amit Langote, reviewed by Julien Rouhaud
Discussion: https://postgr.es/m/
[email protected]Bruce Momjian [Wed, 10 Jul 2019 18:24:36 +0000 (14:24 -0400)] docs: remove pg_roles mention of the oid column being displayed
It is now always displayed in PG 12+.
Discussion: https://postgr.es/m/
b6ec6167-5dd5-6347-ac1d-
1fd49382019f@2ndquadrant.com
Author: Ian Barwick
Back-through: 12
Alvaro Herrera [Wed, 10 Jul 2019 12:58:41 +0000 (08:58 -0400)] Mention limitation of unique in partitioned tables
Per gripe from Phil Bayer.
Authors: Amit Langote and others
Discussion: https://postgr.es/m/
156236160709.1192.
4498528196556144085@wrigleys.postgresql.org
Michael Paquier [Wed, 10 Jul 2019 06:14:54 +0000 (15:14 +0900)] Fix variable initialization when using buffering build with GiST
This can cause valgrind to complain, as the flag marking a buffer as a
temporary copy was not getting initialized.
While on it, fill in with zeros newly-created buffer pages. This does
not matter when loading a block from a temporary file, but it makes the
push of an index tuple into a new buffer page safer.
This has been introduced by
1d27dcf, so back all the way down to
9.4.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/15899-
0d24fb273b3dd90c@postgresql.org
Back-through: 9.4
Alexander Korotkov [Wed, 10 Jul 2019 04:46:16 +0000 (07:46 +0300)] Assorted fixes for jsonpath documentation
This commit contains assorted fixes for jsonpath documentation including:
grammar fixes, incorrect examples fixes as well as wording improvements.
Discussion: https://postgr.es/m/CAA-aLv4VVX%3Db9RK5hkfPXJczqaiTdqO04teW9i0wiQVhdKcqzw%40mail.gmail.com
Author: Liudmila Mantrova
Reviewed-by: Alexander Korotkov
Reported-by: Thom Brown
David Rowley [Wed, 10 Jul 2019 04:03:04 +0000 (16:03 +1200)] Fix missing calls to table_finish_bulk_insert during COPY, take 2
86b85044e abstracted calls to heap functions in COPY FROM to support a
generic table AM. However, when performing a copy into a partitioned
table, this commit neglected to call table_finish_bulk_insert for each
partition. Before
86b85044e, when we always called the heap functions,
there was no need to call heapam_finish_bulk_insert for partitions since
it only did any work when performing a copy without WAL. For partitioned
tables, this was unsupported anyway, so there was no issue. With
pluggable storage, we can't make any assumptions about what the table AM
might want to do in its equivalent function, so we'd better ensure we
always call table_finish_bulk_insert each partition that's received a row.
For now, we make the table_finish_bulk_insert call whenever we evict a
CopyMultiInsertBuffer out of the CopyMultiInsertInfo. This does mean
that it's possible that we call table_finish_bulk_insert multiple times
per partition, which is not a problem other than being an inefficiency.
Improving this requires a more invasive , so let's leave that for
another day.
This also changes things so that we no longer needlessly call
table_finish_bulk_insert when performing a COPY FROM for a non-partitioned
table when not using multi-inserts.
Reported-by: Robert HaasBack-through: 12
Discussion: https://postgr.es/m/CA+TgmoYK=6BpxiJ0tN-p9wtH0BTAfbdxzHhwou0mdud4+BkYuQ@mail.gmail.com
Amit Kapila [Wed, 10 Jul 2019 02:22:51 +0000 (07:52 +0530)] Fix few typos and minor wordsmithing in tableam comments.
Reported-by: Ashwin Agrawal
Author: Ashwin Agrawal
Reviewed-by: Amit Kapila
Back-through: 12, where it was introduced
Discussion: https://postgr.es/m/CALfoeisgdZhYDrJOukaBzvXfJOK2FQ0szVMK7dzmcy6w93iDUA@mail.gmail.com
Thomas Munro [Tue, 9 Jul 2019 22:15:32 +0000 (10:15 +1200)] Pass QueryEnvironment down to EvalPlanQual's EState.
Otherwise the executor can't see trigger transition tables during
EPQ evaluation. Fixes bug #15900 and almost certainly also #15720.
Back- to 10, where trigger transition tables landed.
Author: Alex Aktsipetrov
Reviewed-by: Thomas Munro, Tom LaneDiscussion: https://postgr.es/m/15900-
bc482754fe8d7415%40postgresql.org
Discussion: https://postgr.es/m/15720-
38c2b29e5d720187%40postgresql.org
Alvaro Herrera [Tue, 9 Jul 2019 21:16:36 +0000 (17:16 -0400)] Propagate trigger arguments to partitions
We were creating the cloned triggers with an empty list of arguments,
losing the ones that had been specified by the user when creating the
trigger in the partitioned table. Repair.
This was forgotten in commit
86f575948c77.
Author: Patrick McHardy
Reviewed-by: Tomas VondraDiscussion: https://postgr.es/m/
20190709130027[email protected]Discussion: https://postgr.es/m/15752-
123bc90287986de4@postgresql.org
Peter Eisentraut [Tue, 9 Jul 2019 13:47:09 +0000 (15:47 +0200)] Message style improvements
Thomas Munro [Tue, 9 Jul 2019 06:11:01 +0000 (18:11 +1200)] Force hash joins to be enabled in the hash join regression tests.
Otherwise the regressplans.sh tests generate extremely slow nested
loop joins. Back- to 11 where the hash join tests came in.
Reported-by: Michael PaquierDiscussion: https://postgr.es/m/
20190708055256.GB2709%40paquier.xyz
Bruce Momjian [Tue, 9 Jul 2019 03:04:02 +0000 (23:04 -0400)] doc: adjust to_timestamp()/to_date() wording
Discussion: https://postgr.es/m/
20190706202425[email protected]Author: Justin Pryzby
Back-through: 12
Bruce Momjian [Mon, 8 Jul 2019 23:39:48 +0000 (19:39 -0400)] Adjust ssl_ciphers to be specific to OpenSSL
Syntax is OpenSSL-specific, so only use it for OpenSSL.
Discussion: https://postgr.es/m/
8232E273-7B25-47F4-B0E7-
3D4264106F82@yesql.se
Author: Daniel Gustafsson
Back-through: head
Bruce Momjian [Mon, 8 Jul 2019 23:31:16 +0000 (19:31 -0400)] Remove unused C structure member
Remove quote_all_identifiers from struct _dumpOptions.
Discussion: https://postgr.es/m/
d3d92ce9-78a4-8adb-0393-
d3deeec29f7e@postgrespro.ru
Author: Arthur Zakirov
Back-through: head
Robert Haas [Mon, 8 Jul 2019 18:51:53 +0000 (14:51 -0400)] tableam: Provide helper functions for relation sizing.
Most block-based table AMs will need the exact same implementation of
the relation_size callback as the heap, and if they use a standard
page layout, they will likely need an implementation of the
relation_estimate_size callback that is very similar to that of the
heap. Rearrange to facilitate code reuse.
by me, reviewed by Michael Paquier, Daniel Gustafsson, and
Álvaro Herrera.
Discussion: http://postgr.es/m/CA+TgmoZ6DBPnP1E-vRpQZUJQijJFD54F+SR_pxGiAAS-MyrigA@mail.gmail.com
Peter Eisentraut [Mon, 8 Jul 2019 12:28:42 +0000 (14:28 +0200)] doc: Clarify logical replication documentation
Document that the data types of replicated tables do not need to
match. The documentation previously claimed that they had to match.
Author: Robert Treat <
[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/CAJSLCQ13==D8Ka2YLyctTm0Y+8MhGYcX_zj7fU0rqRzhcV++3w@mail.gmail.com
Michael Paquier [Mon, 8 Jul 2019 04:15:09 +0000 (13:15 +0900)] Fix inconsistencies in the code
This addresses a couple of issues in the code:
- Typos and inconsistencies in comments and function declarations.
- Removal of unreferenced function declarations.
- Removal of unnecessary compile flags.
- A cleanup error in regressplans.sh.
Author: Alexander Lakhin
Discussion: https://postgr.es/m/
0c991fdf-2670-1997-c027-
772a420c4604@gmail.com
Peter Eisentraut [Sat, 6 Jul 2019 21:18:46 +0000 (23:18 +0200)] Use consistent style for checking return from system calls
Use
if (something() != 0)
error ...
instead of just
if (something)
error ...
The latter is not incorrect, but it's a bit confusing and not the
common style.
Discussion: https://www.postgresql.org/message-id/flat/
5de61b6b-8be9-7771-0048-
860328efe027%402ndquadrant.com
Michael Paquier [Sun, 7 Jul 2019 00:58:33 +0000 (09:58 +0900)] Remove more unreferenced function declarations
Author: Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoDuAYsRb3Q9aobkFZ6DZMWxsyg4HOmgkwgeWNfSkTwGxw@mail.gmail.com
Tom Lane [Sat, 6 Jul 2019 15:25:37 +0000 (11:25 -0400)] In pg_log_generic(), be more paranoid about preserving errno.
This code failed to account for the possibility that malloc() would
change errno, resulting in wrong output for %m, not to mention the
possibility of message truncation. Such a change is obviously
expected when malloc fails, but there's reason to fear that on some
platforms even a successful malloc call can modify errno.
Discussion: https://postgr.es/m/2576.
1527382833@sss.pgh.pa.us
Peter Eisentraut [Sat, 6 Jul 2019 13:02:53 +0000 (15:02 +0200)] Add missing source files to nls.mk
Peter Eisentraut [Sat, 6 Jul 2019 12:58:08 +0000 (14:58 +0200)] psql: Fix logging output format
In normal interactive mode, psql's log messages accidentally got a
"psql:" prefix that was not supposed to be there. This only happened
if there was no .psqlrc file being read, so it wasn't discovered for a
while. Fix this by adding the appropriate logging format
configuration call in the right code path.
Discussion: https://www.postgresql.org/message-id/7586.
1560540361@sss.pgh.pa.us
Amit Kapila [Sat, 6 Jul 2019 06:11:23 +0000 (11:41 +0530)] Add missing assertions for required table am callbacks.
Reported-by: Ashwin Agrawal
Author: Ashwin Agrawal
Reviewed-by: Amit Kapila
Back-through: 12, where it was introduced
Discussion: https://postgr.es/m/CALfoeisgdZhYDrJOukaBzvXfJOK2FQ0szVMK7dzmcy6w93iDUA@mail.gmail.com
Tom Lane [Sat, 6 Jul 2019 03:56:34 +0000 (23:56 -0400)] Add some test cases to improve test coverage of parse_expr.c.
I chanced to notice while thumbing through lcov reports that we had
exactly no coverage of BETWEEN SYMMETRIC, nor of current_time(N) and
localtime(N). Improve that.
parse_expr.c still has a pretty awful coverage number, but a large part
of that is due to lack of coverage of the operator_precedence_warning
logic. I have zero desire to write tests for that; I think ripping it
out would be more sensible at this point.
Tom Lane [Fri, 5 Jul 2019 23:28:45 +0000 (19:28 -0400)] Remove unreferenced function declarations.
These seem to be leftovers from old es, perhaps.
Masahiko Sawada
Discussion: https://postgr.es/m/CAD21AoDuAYsRb3Q9aobkFZ6DZMWxsyg4HOmgkwgeWNfSkTwGxw@mail.gmail.com
Tom Lane [Fri, 5 Jul 2019 18:17:27 +0000 (14:17 -0400)] Remove dead encoding-conversion functions.
The code for conversions SQL_ASCII <-> MULE_INTERNAL and
SQL_ASCII <-> UTF8 was unreachable, because we long ago changed
the wrapper functions pg_do_encoding_conversion() et al so that
they have hard-wired behaviors for conversions involving SQL_ASCII.
(At least some of those fast paths date back to 2002, though it
looks like we may not have been totally consistent about this until
later.) Given the lack of complaints, nobody is dissatisfied with
this state of affairs. Hence, let's just remove the unreachable code.
Also, change CREATE CONVERSION so that it rejects attempts to
define such conversions. Since we consider that SQL_ASCII represents
lack of knowledge about the encoding in use, such a conversion would
be semantically dubious even if it were reachable.
Adjust a couple of regression test cases that had randomly decided
to rely on these conversion functions rather than any other ones.
Discussion: https://postgr.es/m/41163.
1559156593@sss.pgh.pa.us
Tomas Vondra [Fri, 5 Jul 2019 16:06:02 +0000 (18:06 +0200)] Remove unused variable in statext_mcv_serialize()
The itemlen variable used to be referenced in multiple places, but since
reworking the serialization code it's used only in one assert. Fixed by
removing the variable and calling the macro from the assert directly.
Back to 12, where this code was introduced.
Reported-by: Jeff Janes
Discussion: https://postgr.es/m/CAMkU=1zc_ovH9NZd_9ovuiEWkF9yX06URUDdXCmgDydf-bqB5A@mail.gmail.com
Tom Lane [Fri, 5 Jul 2019 16:32:36 +0000 (12:32 -0400)] Add \warn command to psql.
This is like \echo except that the text is sent to stderr not stdout.
In passing, fix a pre-existing bug in \echo and \qecho: per documentation
the -n switch should only be recognized when it is the first argument,
but actually any argument matching "-n" was treated as a switch.
(Should we back- that?)
David Fetter (bug fix by me), reviewed by Fabien Coelho
Discussion: https://postgr.es/m/
20190421183115[email protected]Thomas Munro [Fri, 5 Jul 2019 08:59:29 +0000 (20:59 +1200)] Improve comment in postgresql.conf.sample.
The Unix manual section that "man tcp" appears in varies, so let's
just leave it out of the command to run.
Peter Eisentraut [Fri, 5 Jul 2019 06:33:51 +0000 (08:33 +0200)] doc: Spell checking
Michael Paquier [Fri, 5 Jul 2019 03:21:11 +0000 (12:21 +0900)] Add min() and max() aggregates for pg_lsn
This is useful for monitoring, when it comes for example to calculations
of WAL retention with replication slots and delays with a set of
standbys.
Bump catalog version.
Author: Fabrízio de Royes Mello
Reviewed-by: Surafel Temesgen
Discussion: https://postgr.es/m/CAFcNs+oc8ZoHhowA4rR1GGCgG8QNgK_TOwPRVYQo5rYy8_PXzA@mail.gmail.com
Michael Paquier [Fri, 5 Jul 2019 01:47:32 +0000 (10:47 +0900)] Update hardcoded DH parameters to IANA standards
The source defining the current fallback and hardcoded DH parameters
has disappeared from the web a long time ago, and RFC 3526 defines the
most current Diffie-Hellman MODP groups, so update to those new values.
Author: Daniel Gustafsson
Reviewed-by: Peter Eisentraut, Michael PaquierDiscussion: https://postgr.es/m/
5E60AC9A-CB10-4851-9EF2-
7209490A164C@yesql.se
Tomas Vondra [Thu, 4 Jul 2019 22:45:20 +0000 (00:45 +0200)] Simplify pg_mcv_list (de)serialization
The serialization format of multivariate MCV lists included alignment in
order to allow direct access to part of the serialized data, but despite
multiple fixes (see for example commits
d85e0f366a and
ea4e1c0e8f) this
proved to be problematic.
This commit abandons alignment in the serialized format, and just copies
everything during deserialization. We now also track amount of memory
needed after deserialization (including alignment), which allows us to
deserialize the MCV list in a single pass.
Bump catversion, as this affects contents of pg_statistic_ext_data.
Back to 12, where multi-column MCV lists were introduced.
Author: Tomas Vondra
Reviewed-by: Tom LaneDiscussion: https://postgr.es/m/2201.
1561521148@sss.pgh.pa.us
Tomas Vondra [Thu, 4 Jul 2019 21:43:04 +0000 (23:43 +0200)] Fix pg_mcv_list_items() to produce text[]
The function pg_mcv_list_items() returns values stored in MCV items. The
items may contain columns with different data types, so the function was
generating text array-like representation, but in an ad-hoc way without
properly escaping various characters etc.
Fixed by simply building a text[] array, which also makes it easier to
use from queries etc.
Requires changes to pg_proc entry, so bump catversion.
Back to 12, where multi-column MCV lists were introduced.
Author: Tomas Vondra
Reviewed-by: Dean RasheedDiscussion: https://postgr.es/m/
20190618205920.qtlzcu73whfpfqne@development
Tomas Vondra [Thu, 4 Jul 2019 21:02:02 +0000 (23:02 +0200)] Speed-up build of MCV lists with many distinct values
When building multi-column MCV lists, we compute base frequency for each
item, i.e. a product of per-column frequencies for values from the item.
As a value may be in multiple groups, the code was scanning the whole
array of groups while adding items to the MCV list. This works fine as
long as the number of distinct groups is small, but it's easy to trigger
trigger O(N^2) behavior, especially after increasing statistics target.
This commit precomputes frequencies for values in all columns, so that
when computing the base frequency it's enough to make a simple bsearch
lookup in the array.
Back to 12, where multi-column MCV lists were introduced.
Discussion: https://postgr.es/m/
20190618205920.qtlzcu73whfpfqne@development
Peter Eisentraut [Thu, 6 Jun 2019 12:32:54 +0000 (14:32 +0200)] Remove unnecessary casts from size_t to int
We can use the %zu format specifier directly, no need to cast to int.
Peter Eisentraut [Thu, 6 Jun 2019 12:14:29 +0000 (14:14 +0200)] Unwind some workarounds for lack of portable int64 format specifier
Because there is no portable int64/uint64 format specifier and we
can't stick macros like INT64_FORMAT into the middle of a translatable
string, we have been using various workarounds that put the number to
be printed into a string buffer first. Now that we always use our own
sprintf(), we can rely on %lld and %llu to work, so we can use those.
This undoes this workaround in a few places where it was
egregiously verbose.
Reviewed-by: Tom Lane <[email protected]>Discussion: https://www.postgresql.org/message-id/flat/CAH2-Wz%3DWbNxc5ob5NJ9yqo2RMJ0q4HXDS30GVCobeCvC9A1L9A%40mail.gmail.com
Peter Eisentraut [Thu, 4 Jul 2019 11:10:41 +0000 (13:10 +0200)] Sync our Snowball stemmer dictionaries with current upstream
The main change is a new stemmer for Greek. There are minor changes
in the Danish and French stemmers.
Author: Panagiotis Mavrogiorgos <
[email protected]>
Peter Eisentraut [Thu, 4 Jul 2019 10:31:08 +0000 (12:31 +0200)] Clean up whitespace a bit
Michael Paquier [Thu, 4 Jul 2019 07:08:09 +0000 (16:08 +0900)] Introduce safer encoding and decoding routines for base64.c
This is a follow-up refactoring after
09ec55b and
b674211, which has
proved that the encoding and decoding routines used by SCRAM have a
poor interface when it comes to check after buffer overflows. This adds
an extra argument in the shape of the length of the result buffer for
each routine, which is used for overflow checks when encoding or
decoding an input string. The original idea comes from Tom Lane.
As a result of that, the encoding routine can now fail, so all its
callers are adjusted to generate proper error messages in case of
problems.
On failure, the result buffer gets zeroed.
Author: Michael Paquier
Reviewed-by: Daniel GustafssonDiscussion: https://postgr.es/m/
20190623132535[email protected]Michael Paquier [Thu, 4 Jul 2019 02:33:42 +0000 (11:33 +0900)] Simplify TAP tests of pg_dump for connection strings
The last set of scenarios did an initialization of nodes followed by an
extra command to set up the authentication policy with pg_regress
--config-auth. This configuration step can be integrated directly using
the option auth_extra from PostgresNode::init when initializing the
node, saving from one extra command. On Windows, this also restricts
more pg_ident.conf for the SSPI user mapping by removing the entry of
the OS user running the test, which is not needed anyway.
Note that IPC::Run mishandles double quotes, hence the restore user name
is changed to map with that. This was already done in the test as a
later step, but not in a consistent way, causing the switch to use
auth_extra to fail.
Found while reviewing
ca129e5.
Discussion: https://postgr.es/m/
20190703062024[email protected]David Rowley [Thu, 4 Jul 2019 01:01:13 +0000 (13:01 +1200)] Use appendStringInfoString and appendPQExpBufferStr where possible
This changes various places where appendPQExpBuffer was used in places
where it was possible to use appendPQExpBufferStr, and likewise for
appendStringInfo and appendStringInfoString. This is really just a
stylistic improvement, but there are also small performance gains to be
had from doing this.
Discussion: http://postgr.es/m/CAKJS1f9P=M-3ULmPvr8iCno8yvfDViHibJjpriHU8+SXUgeZ=w@mail.gmail.com
Tom Lane [Wed, 3 Jul 2019 22:08:53 +0000 (18:08 -0400)] Ensure plpgsql result tuples have the right composite type marking.
A function that is declared to return a named composite type must
return tuple datums that are physically marked as having that type.
The plpgsql code path that allowed directly returning an expanded-record
datum forgot to check that, so that an expanded record marked as type
RECORDOID could be returned if it had a physically-compatible tupdesc.
This'd be harmless, I think, if the record value never escaped the
current session --- but it's possible for it to get stored into a table,
and then subsequent sessions can't interpret the anonymous record type.
Fix by flattening the record into a tuple datum and overwriting its
type/typmod fields, if its declared type doesn't match the function's
declared type. (In principle it might be possible to just change the
expanded record's stored type ID info, but there are enough tricky
consequences that I didn't want to mess with that, especially not in
a back-ed bug fix.)
Per bug report from Steve Rogerson. Back- to v11 where the bug
was introduced.
Discussion: https://postgr.es/m/
cbaecae6-7b87-584e-45f6-
4d047b92ca2a@yewtc.demon.co.uk
Tom Lane [Wed, 3 Jul 2019 16:18:10 +0000 (12:18 -0400)] Doc: document table persistence display in \dt+.
Forgotten in commit
9a2ea6183.
Tom Lane [Wed, 3 Jul 2019 15:46:34 +0000 (11:46 -0400)] Show table persistence in psql's \dt+ and related commands.
In verbose mode, listTables() now emits a "Persistence" column
showing whether the table/index/view/etc is permanent, temporary,
or unlogged.
David Fetter, reviewed by Fabien Coelho and Rafia Sabih
Discussion: https://postgr.es/m/
20190423005642[email protected]David Rowley [Wed, 3 Jul 2019 11:44:54 +0000 (23:44 +1200)] Don't remove surplus columns from GROUP BY for inheritance parents
d4c3a156c added code to remove columns that were not part of a table's
PRIMARY KEY constraint from the GROUP BY clause when all the primary key
columns were present in the group by. This is fine to do since we know
that there will only be one row per group coming from this relation.
However, the logic failed to consider inheritance parent relations. These
can have child relations without a primary key, but even if they did, they
could duplicate one of the parent's rows or one from another child
relation. In this case, those additional GROUP BY columns are required.
Fix this by disabling the optimization for inheritance parent tables.
In v11 and beyond, partitioned tables are fine since partitions cannot
overlap and before v11 partitioned tables could not have a primary key.
Reported-by: Manuel RiggerDiscussion: http://postgr.es/m/CA+u7OA7VLKf_vEr6kLF3MnWSA9LToJYncgpNX2tQ-oWzYCBQAw@mail.gmail.com
Back-through: 9.6
Etsuro Fujita [Wed, 3 Jul 2019 08:51:00 +0000 (17:51 +0900)] postgres_fdw: Remove redundancy in postgresAcquireSampleRowsFunc().
Previously, in the loop in postgresAcquireSampleRowsFunc() to iterate
fetching rows from a given remote table, we redundantly 1) determined the
fetch size by parsing the table's server/table-level options and then 2)
constructed the fetch command; remove that redundancy.
Author: Etsuro Fujita
Reviewed-by: Julien Rouhaud
Discussion: https://postgr.es/m/CAPmGK17_urk9qkLV65_iYMFw64z5qhdfhY=tMVV6Jg4KNYx8+w@mail.gmail.com
Michael Meskes [Tue, 2 Jul 2019 01:51:13 +0000 (03:51 +0200)] Fix small memory in ecpglib ecpg_update_declare_statement() is called the
second time.
Author: "Zhang, Jie" <
[email protected]>
Michael Meskes [Tue, 2 Jul 2019 01:42:09 +0000 (03:42 +0200)] Use strtoint() instead of strtol() in pgtypeslib where the result is stored in
an int variable.
Author: Yang Xiao <
[email protected]>
Michael Meskes [Tue, 2 Jul 2019 01:34:58 +0000 (03:34 +0200)] Made ecpg compatibility mode and run-time behaviour options case insensitive.
Peter Eisentraut [Tue, 2 Jul 2019 22:44:30 +0000 (23:44 +0100)] Fix accidentally swapped error message arguments
Author: Alexey Kondratov <
[email protected]>
Peter Eisentraut [Tue, 2 Jul 2019 22:18:43 +0000 (23:18 +0100)] Remove redundant newlines from error messages
These are no longer needed/allowed with the new logging API.