pgsql: Fix nbtree cleanup-only VACUUM stats inaccuracies.

2020-11-04 Thread Peter Geoghegan
Fix nbtree cleanup-only VACUUM stats inaccuracies. Logic for counting heap TIDs from posting list tuples (added by commit 0d861bbb) was faulty. It didn't count any TIDs/index tuples in the event of no callback being set. This meant that we incorrectly counted no index tuples in clean-up only VAC

pgsql: Fix nbtree cleanup-only VACUUM stats inaccuracies.

2020-11-04 Thread Peter Geoghegan
Fix nbtree cleanup-only VACUUM stats inaccuracies. Logic for counting heap TIDs from posting list tuples (added by commit 0d861bbb) was faulty. It didn't count any TIDs/index tuples in the event of no callback being set. This meant that we incorrectly counted no index tuples in clean-up only VAC

pgsql: Fix unlinking of SLRU segments.

2020-11-04 Thread Thomas Munro
Fix unlinking of SLRU segments. Commit dee663f7 intended to drop any queued up fsync requests before unlinking segment files, but missed a code path. Fix, by centralizing the forget-and-unlink code into a single function. Reported-by: Tomas Vondra Discussion: https://postgr.es/m/20201104013205.

pgsql: Remove underflow error in float division with infinite divisor.

2020-11-04 Thread Tom Lane
Remove underflow error in float division with infinite divisor. float4_div and float8_div correctly produced zero for zero divided by infinity, but threw an underflow error for nonzero finite values divided by infinity. This seems wrong; at the very least it's inconsistent with the behavior recen

pgsql: Declare assorted array functions using anycompatible not anyelem

2020-11-04 Thread Tom Lane
Declare assorted array functions using anycompatible not anyelement. Convert array_append, array_prepend, array_cat, array_position, array_positions, array_remove, array_replace, and width_bucket to use anycompatiblearray. This is a simple extension of commit 5c292e6b9 to hit some other places wh

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Fujii Masao
On 2020/11/05 5:36, Heikki Linnakangas wrote: On 04/11/2020 15:17, Heikki Linnakangas wrote: On 04/11/2020 14:03, Fujii Masao wrote: Or ISTM that WakeupRecovery() should set the latch only when the latch has not been reset to NULL yet. Got to be careful with race conditions, if the latch i

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Heikki Linnakangas
On 04/11/2020 15:17, Heikki Linnakangas wrote: On 04/11/2020 14:03, Fujii Masao wrote: Or ISTM that WakeupRecovery() should set the latch only when the latch has not been reset to NULL yet. Got to be careful with race conditions, if the latch is set to NULL at the same time that WakeupRecovery

pgsql: Declare lead() and lag() using anycompatible not anyelement.

2020-11-04 Thread Tom Lane
Declare lead() and lag() using anycompatible not anyelement. This allows use of a "default" expression that doesn't slavishly match the data column's type. Formerly you got something like "function lag(numeric, integer, integer) does not exist", which is not just unhelpful but actively misleading

pgsql: Improve our ability to regurgitate SQL-syntax function calls.

2020-11-04 Thread Tom Lane
Improve our ability to regurgitate SQL-syntax function calls. The SQL spec calls out nonstandard syntax for certain function calls, for example substring() with numeric position info is supposed to be spelled "SUBSTRING(string FROM start FOR count)". We accept many of these things, but up to now

pgsql: Remove useless entries for aggregate functions from fmgrtab.c.

2020-11-04 Thread Tom Lane
Remove useless entries for aggregate functions from fmgrtab.c. Gen_fmgrtab.pl treated aggregate functions the same as other built-in functions, which is wasteful because there is no real need to have entries for them in the fmgr_builtins[] table. Suppressing those entries saves about 3KB in the c

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Heikki Linnakangas
On 04/11/2020 14:03, Fujii Masao wrote: I'm thinking to remove the following code to fix this issue. Thought? /* * We don't need the latch anymore. It's not strictly necessary to reset * it to NULL, but let's do it for the sake of tidiness. */ if (ArchiveRecovery

pgsql: Fix segmentation fault that commit ac22929a26 caused.

2020-11-04 Thread Fujii Masao
Fix segmentation fault that commit ac22929a26 caused. Commit ac22929a26 changed recoveryWakeupLatch so that it's reset to NULL at the end of recovery. This change could cause a segmentation fault in the buildfarm member 'elver'. Previously the latch was reset to NULL after calling ShutdownWalRcv(

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Fujii Masao
On 2020/11/04 20:20, Fujii Masao wrote: On 2020/11/04 19:27, Heikki Linnakangas wrote: On 04/11/2020 09:44, Fujii Masao wrote: Get rid of the dedicated latch for signaling the startup process. This commit gets rid of the dedicated latch for signaling the startup process in favor of using

pgsql: Enable hash partitioning of text arrays

2020-11-04 Thread Peter Eisentraut
Enable hash partitioning of text arrays hash_array_extended() needs to pass PG_GET_COLLATION() to the hash function of the element type. Otherwise, the hash function of a collation-aware data type such as text will error out, since the introduction of nondeterministic collation made hash function

pgsql: Enable hash partitioning of text arrays

2020-11-04 Thread Peter Eisentraut
Enable hash partitioning of text arrays hash_array_extended() needs to pass PG_GET_COLLATION() to the hash function of the element type. Otherwise, the hash function of a collation-aware data type such as text will error out, since the introduction of nondeterministic collation made hash function

pgsql: Enable hash partitioning of text arrays

2020-11-04 Thread Peter Eisentraut
Enable hash partitioning of text arrays hash_array_extended() needs to pass PG_GET_COLLATION() to the hash function of the element type. Otherwise, the hash function of a collation-aware data type such as text will error out, since the introduction of nondeterministic collation made hash function

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Fujii Masao
On 2020/11/04 19:27, Heikki Linnakangas wrote: On 04/11/2020 09:44, Fujii Masao wrote: Get rid of the dedicated latch for signaling the startup process. This commit gets rid of the dedicated latch for signaling the startup process in favor of using its procLatch,  since that comports better

Re: pgsql: Get rid of the dedicated latch for signaling the startup process

2020-11-04 Thread Heikki Linnakangas
On 04/11/2020 09:44, Fujii Masao wrote: Get rid of the dedicated latch for signaling the startup process. This commit gets rid of the dedicated latch for signaling the startup process in favor of using its procLatch, since that comports better with possible generic signal handlers using that la

pgsql: Refactor pg_rewind for more clear decision making.

2020-11-04 Thread Heikki Linnakangas
Refactor pg_rewind for more clear decision making. Deciding what to do with each file is now a separate step after all the necessary information has been gathered. It is more clear that way. Previously, the decision-making was divided between process_source_file() and process_target_file(), and it

pgsql: pg_rewind: Refactor the abstraction to fetch from local/libpq so

2020-11-04 Thread Heikki Linnakangas
pg_rewind: Refactor the abstraction to fetch from local/libpq source. This makes the abstraction of a "source" server more clear, by introducing a common abstract class, borrowing the object-oriented programming term, that represents all the operations that can be done on the source server. There

pgsql: pg_rewind: Replace the hybrid list+array data structure with sim

2020-11-04 Thread Heikki Linnakangas
pg_rewind: Replace the hybrid list+array data structure with simplehash. Now that simplehash can be used in frontend code, let's make use of it. Reviewed-by: Kyotaro Horiguchi, Soumyadeep Chakraborty Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi

pgsql: pg_rewind: Move syncTargetDirectory() to file_ops.c

2020-11-04 Thread Heikki Linnakangas
pg_rewind: Move syncTargetDirectory() to file_ops.c For consistency. All the other low-level functions that operate on the target directory are in file_ops.c. Reviewed-by: Michael Paquier Discussion: https://www.postgresql.org/message-id/0c5b3783-af52-3ee5-f8fa-6e794061f70d%40iki.fi Branch