pgsql: Make deduplication use number of key attributes.

2020-03-28 Thread Peter Geoghegan
Make deduplication use number of key attributes. Use IndexRelationGetNumberOfKeyAttributes() rather than IndexRelationGetNumberOfAttributes() when determining whether or not two index tuples are suitable for merging together into a single posting list tuple. This is a little bit tidier. It

pgsql: Fix lquery's behavior for consecutive '*' items.

2020-03-28 Thread Tom Lane
Fix lquery's behavior for consecutive '*' items. Something like "*{2}.*{3}" should presumably mean the same as "*{5}", but it didn't. Improve that. Get rid of an undocumented and remarkably ugly (though not, as far as I can tell, actually unsafe) static variable in favor of passing more

Re: pgsql: Add kqueue(2) support to the WaitEventSet API.

2020-03-28 Thread Thomas Munro
On Sun, Mar 29, 2020 at 7:43 AM Tom Lane wrote: > Thomas Munro writes: > > Pushed. > > prairiedog just turned up a different issue in this area [1]. > I wondered why it hadn't reported in for awhile, and upon > investigation I found that the test run was stuck in the > final pg_dump step of the

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Protect against overflow of ltree.numlevel and lquery.numlevel.

2020-03-28 Thread Tom Lane
Protect against overflow of ltree.numlevel and lquery.numlevel. These uint16 fields could be overflowed by excessively long input, producing strange results. Complain for invalid input. Likewise check for out-of-range values of the repeat counts in lquery. (We don't try too hard on that one,

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Ensure snapshot is registered within ScanPgRelation().

2020-03-28 Thread Andres Freund
Ensure snapshot is registered within ScanPgRelation(). In 9.4 I added support to use a historical snapshot in ScanPgRelation(), while adding logical decoding. Unfortunately a conflict with the concurrent removal of SnapshotNow was incorrectly resolved, leading to an unregistered snapshot being

pgsql: Fix costing for disk-based hash aggregation.

2020-03-28 Thread Jeff Davis
Fix costing for disk-based hash aggregation. Report and suggestions from Richard Guo and Tomas Vondra. Discussion: https://postgr.es/m/CAMbWs4_W8fYbAn8KxgidAaZHON_Oo08OYn9ze=7remjymlq...@mail.gmail.com Branch -- master Details ---

Re: pgsql: Add kqueue(2) support to the WaitEventSet API.

2020-03-28 Thread Tom Lane
Thomas Munro writes: > Pushed. prairiedog just turned up a different issue in this area [1]. I wondered why it hadn't reported in for awhile, and upon investigation I found that the test run was stuck in the final pg_dump step of the pg_upgrade test. pg_dump itself was waiting for a query

pgsql: Improve the performance and accuracy of numeric sqrt() and ln().

2020-03-28 Thread Dean Rasheed
Improve the performance and accuracy of numeric sqrt() and ln(). Instead of using Newton's method to compute numeric square roots, use the Karatsuba square root algorithm, which performs better for numbers of all sizes. In practice, this is 3-5 times faster for inputs with just a few digits and

pgsql: Enable Unix-domain sockets support on Windows

2020-03-28 Thread Peter Eisentraut
Enable Unix-domain sockets support on Windows As of Windows 10 version 1803, Unix-domain sockets are supported on Windows. But it's not automatically detected by configure because it looks for struct sockaddr_un and Windows doesn't define that. So we just make our own definition on Windows and

pgsql: Prevent functional dependency estimates from exceeding column es

2020-03-28 Thread Dean Rasheed
Prevent functional dependency estimates from exceeding column estimates. Formerly we applied a functional dependency "a => b with dependency degree f" using the formula P(a,b) = P(a) * [f + (1-f)*P(b)] This leads to the possibility that the combined selectivity P(a,b) could exceed P(b), which

pgsql: Cleanup in SQL features files

2020-03-28 Thread Peter Eisentraut
Cleanup in SQL features files Feature C011 was still listed in sql_feature_packages.txt but had been removed from sql_features.txt, so also remove from the former. Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/145cb16d3bd7d20dbf14507905404aa8153ebf2a Modified

pgsql: Trigger autovacuum based on number of INSERTs

2020-03-28 Thread David Rowley
Trigger autovacuum based on number of INSERTs Traditionally autovacuum has only ever invoked a worker based on the estimated number of dead tuples in a table and for anti-wraparound purposes. For the latter, with certain classes of tables such as insert-only tables, anti-wraparound vacuums could