pgsql: Improve the accuracy of floating point statistical aggregates.

2018-10-06 Thread Dean Rasheed
Improve the accuracy of floating point statistical aggregates. When computing statistical aggregates like variance, the common schoolbook algorithm which computes the sum of the squares of the values and subtracts the square of the mean can lead to a large loss of precision when using floating poi

pgsql: Propagate xactStartTimestamp and stmtStartTimestamp to parallel

2018-10-06 Thread Tom Lane
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. Previously, a worker process would establish values for these based on its own start time. In v10 and up, this can trivially be shown to cause misbehavior of transaction_timestamp(), timestamp_in(), and related functions whi

pgsql: Propagate xactStartTimestamp and stmtStartTimestamp to parallel

2018-10-06 Thread Tom Lane
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. Previously, a worker process would establish values for these based on its own start time. In v10 and up, this can trivially be shown to cause misbehavior of transaction_timestamp(), timestamp_in(), and related functions whi

pgsql: Propagate xactStartTimestamp and stmtStartTimestamp to parallel

2018-10-06 Thread Tom Lane
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. Previously, a worker process would establish values for these based on its own start time. In v10 and up, this can trivially be shown to cause misbehavior of transaction_timestamp(), timestamp_in(), and related functions whi

pgsql: Propagate xactStartTimestamp and stmtStartTimestamp to parallel

2018-10-06 Thread Tom Lane
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. Previously, a worker process would establish values for these based on its own start time. In v10 and up, this can trivially be shown to cause misbehavior of transaction_timestamp(), timestamp_in(), and related functions whi

pgsql: Propagate xactStartTimestamp and stmtStartTimestamp to parallel

2018-10-06 Thread Tom Lane
Propagate xactStartTimestamp and stmtStartTimestamp to parallel workers. Previously, a worker process would establish values for these based on its own start time. In v10 and up, this can trivially be shown to cause misbehavior of transaction_timestamp(), timestamp_in(), and related functions whi

pgsql: Don't use is_infinite() where isinf() will do.

2018-10-06 Thread Tom Lane
Don't use is_infinite() where isinf() will do. Places that aren't testing for sign should not use the more expensive function; it's just wasteful, not to mention being a cognitive load for readers who may know what isinf() is but not is_infinite(). As things stand, we actually don't need is_infin

pgsql: Remove more redundant relation locking during executor startup.

2018-10-06 Thread Tom Lane
Remove more redundant relation locking during executor startup. We already have appropriate locks on every relation listed in the query's rangetable before we reach the executor. Take the next step in exploiting that knowledge by removing code that worries about taking locks on non-leaf result re

pgsql: Restore sane locking behavior during parallel query.

2018-10-06 Thread Tom Lane
Restore sane locking behavior during parallel query. Commit 9a3cebeaa changed things so that parallel workers didn't obtain any lock of their own on tables they access. That was clearly a bad idea, but I'd mistakenly supposed that it was the intended end result of the series of patches for simpli

pgsql: Fix event triggers for partitioned tables

2018-10-06 Thread Alvaro Herrera
Fix event triggers for partitioned tables Index DDL cascading on partitioned tables introduced a way for ALTER TABLE to be called reentrantly. This caused an an important deficiency in event trigger support to be exposed: on exiting the reentrant call, the alter table state object was clobbered,

pgsql: Fix event triggers for partitioned tables

2018-10-06 Thread Alvaro Herrera
Fix event triggers for partitioned tables Index DDL cascading on partitioned tables introduced a way for ALTER TABLE to be called reentrantly. This caused an an important deficiency in event trigger support to be exposed: on exiting the reentrant call, the alter table state object was clobbered,

pgsql: Fix event triggers for partitioned tables

2018-10-06 Thread Alvaro Herrera
Fix event triggers for partitioned tables Index DDL cascading on partitioned tables introduced a way for ALTER TABLE to be called reentrantly. This caused an an important deficiency in event trigger support to be exposed: on exiting the reentrant call, the alter table state object was clobbered,

pgsql: Fix event triggers for partitioned tables

2018-10-06 Thread Alvaro Herrera
Fix event triggers for partitioned tables Index DDL cascading on partitioned tables introduced a way for ALTER TABLE to be called reentrantly. This caused an an important deficiency in event trigger support to be exposed: on exiting the reentrant call, the alter table state object was clobbered,

pgsql: Fix event triggers for partitioned tables

2018-10-06 Thread Alvaro Herrera
Fix event triggers for partitioned tables Index DDL cascading on partitioned tables introduced a way for ALTER TABLE to be called reentrantly. This caused an an important deficiency in event trigger support to be exposed: on exiting the reentrant call, the alter table state object was clobbered,

pgsql: Fix catalog insertion order for ATTACH PARTITION

2018-10-06 Thread Alvaro Herrera
Fix catalog insertion order for ATTACH PARTITION Commit 2fbdf1b38bc changed the order in which we inserted catalog rows when creating partitions, so that we could remove an unsightly hack required for untimely relcache invalidations. However, that commit only changed the ordering for CREATE TABLE

pgsql: Fix catalog insertion order for ATTACH PARTITION

2018-10-06 Thread Alvaro Herrera
Fix catalog insertion order for ATTACH PARTITION Commit 2fbdf1b38bc changed the order in which we inserted catalog rows when creating partitions, so that we could remove an unsightly hack required for untimely relcache invalidations. However, that commit only changed the ordering for CREATE TABLE