pgsql: Fix crash of pg_stat_statements_info() without library loaded

2021-01-27 Thread Michael Paquier
Fix crash of pg_stat_statements_info() without library loaded Other code paths are already protected against this case, and _PG_init() warns about that in pg_stat_statements.c. While on it, I have checked the other extensions of the tree but did not notice any holes. Oversight in 9fbc3f3. Autho

pgsql: Refactor SQL functions of SHA-2 in cryptohashfuncs.c

2021-01-27 Thread Michael Paquier
Refactor SQL functions of SHA-2 in cryptohashfuncs.c The same code pattern was repeated four times when compiling a SHA-2 hash. This refactoring has the advantage to issue a compilation warning if a new value is added to pg_cryptohash_type, so as anybody doing an addition in this area would need

Re: pgsql: Refactor code in tablecmds.c to check and process tablespace mov

2021-01-27 Thread Michael Paquier
On Wed, Jan 27, 2021 at 11:07:41AM -0300, Alvaro Herrera wrote: > Thanks, looks good. Small comment: CheckRelationTableSpaceMove is > documented as * newTableSpaceId is the new tablespace for the relation, and - * newRelFileNode its new filenode. If newrelfilenode is InvalidOid, + * newRelFile

pgsql: Reduce the default value of vacuum_cost_page_miss.

2021-01-27 Thread Peter Geoghegan
Reduce the default value of vacuum_cost_page_miss. When commit f425b605 introduced cost based vacuum delays back in 2004, the defaults reflected then-current trends in hardware, as well as certain historical limitations in PostgreSQL. There have been enormous improvements in both areas since that

pgsql: In TrimCLOG(), don't reset XactCtl->shared->latest_page_number.

2021-01-27 Thread Robert Haas
In TrimCLOG(), don't reset XactCtl->shared->latest_page_number. Since the CLOG page number is not recorded directly in the checkpoint record, we have to use ShmemVariableCache->nextXid to figure out the latest CLOG page number at the start of recovery. However, as recovery progresses, replay of CL

pgsql: In clog_redo(), don't set XactCtl->shared->latest_page_number.

2021-01-27 Thread Robert Haas
In clog_redo(), don't set XactCtl->shared->latest_page_number. The comment is no longer accurate, and hasn't been entirely accurate since Hot Standby was introduced. The original idea here was that StartupCLOG() wouldn't be called until the end of recovery and therefore this value would be uniniti

pgsql: Doc: improve documentation for UNNEST().

2021-01-27 Thread Tom Lane
Doc: improve documentation for UNNEST(). Per a user question, spell out that UNNEST() returns array elements in storage order; also provide an example to clarify the behavior for multi-dimensional arrays. While here, also clarify the SELECT reference page's description of WITH ORDINALITY. These

pgsql: Doc: improve documentation for UNNEST().

2021-01-27 Thread Tom Lane
Doc: improve documentation for UNNEST(). Per a user question, spell out that UNNEST() returns array elements in storage order; also provide an example to clarify the behavior for multi-dimensional arrays. While here, also clarify the SELECT reference page's description of WITH ORDINALITY. These

pgsql: Move StartupCLOG() calls to just after we initialize ShmemVariab

2021-01-27 Thread Robert Haas
Move StartupCLOG() calls to just after we initialize ShmemVariableCache. Previously, the hot_standby=off code path did this at end of recovery, while the hot_standby=on code path did it at the beginning of recovery. It's better to do this in only one place because (a) it's simpler, (b) StartupCLOG

Re: pgsql: Refactor code in tablecmds.c to check and process tablespace mov

2021-01-27 Thread Alvaro Herrera
On 2021-Jan-27, Michael Paquier wrote: > Refactor code in tablecmds.c to check and process tablespace moves Thanks, looks good. Small comment: CheckRelationTableSpaceMove is documented as + * Returns true if the relation can be moved to the new tablespace; + * false otherwise. but in reality i