pgsql: Fix wrong data table horizon computation during backend startup.

2020-10-28 Thread Andres Freund
Fix wrong data table horizon computation during backend startup. When ComputeXidHorizons() was called before MyDatabaseOid is set, e.g. because a dead row in a shared relation is encountered during InitPostgres(), the horizon for normal tables was computed too aggressively, ignoring all backends c

Re: pgsql: Centralize horizon determination for temp tables, fixing bug due

2020-10-28 Thread Andres Freund
Hi, On 2020-10-29 11:34:03 +0800, Julien Rouhaud wrote: > On Thu, Oct 29, 2020 at 9:07 AM Andres Freund wrote: > > > > Centralize horizon determination for temp tables, fixing bug due to skew. > > Lapwing just reported some problem > (https://brekka.postgresql.org/cgi-bin/show_log.pl?nm=lapwing&

pgsql: Track statistics for streaming of changes from ReorderBuffer.

2020-10-28 Thread Amit Kapila
Track statistics for streaming of changes from ReorderBuffer. This adds the statistics about transactions streamed to the decoding output plugin from ReorderBuffer. Users can query the pg_stat_replication_slots view to check these stats and call pg_stat_reset_replication_slot to reset the stats of

Re: pgsql: Centralize horizon determination for temp tables, fixing bug due

2020-10-28 Thread Julien Rouhaud
On Thu, Oct 29, 2020 at 9:07 AM Andres Freund wrote: > > Centralize horizon determination for temp tables, fixing bug due to skew. Lapwing just reported some problem (https://brekka.postgresql.org/cgi-bin/show_log.pl?nm=lapwing&dt=2020-10-29%2002%3A40%3A14): === 1 of 93 test

pgsql: Centralize horizon determination for temp tables, fixing bug due

2020-10-28 Thread Andres Freund
Centralize horizon determination for temp tables, fixing bug due to skew. This fixes a bug in the edge case where, for a temp table, heap_page_prune() can end up with a different horizon than heap_vacuum_rel(). Which can trigger errors like "ERROR: cannot freeze committed xmax ...". The bug was i

pgsql: Fix incorrect placement of pfree() in pg_relation_check_pages()

2020-10-28 Thread Michael Paquier
Fix incorrect placement of pfree() in pg_relation_check_pages() This would cause the function to crash when more than one page is considered as broken and reported in the SRF. Reported-by: Noriyoshi Shinoda Discussion: https://postgr.es/m/tu4pr8401mb11523d42c315aaf822e74275ee...@tu4pr8401mb1152.

pgsql: Doc: clean up pg_relation_check_pages() documentation.

2020-10-28 Thread Tom Lane
Doc: clean up pg_relation_check_pages() documentation. Commit f2b883969 did not get the memo about the new formatting style for tables documenting built-in functions. I noticed because of a PDF build warning about an overwidth table. Branch -- master Details --- https://git.postgresql.o

pgsql: Doc: clean up verify_heapam() documentation.

2020-10-28 Thread Tom Lane
Doc: clean up verify_heapam() documentation. I started with the intention of just suppressing a PDF build warning by removing the example output, but ended up doing more: correcting factual errors in the function's signature, moving a bunch of generalized handwaving into the "Using amcheck Effecti

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Use mode "r" for popen() in psql's evaluate_backtick().

2020-10-28 Thread Tom Lane
Use mode "r" for popen() in psql's evaluate_backtick(). In almost all other places, we use plain "r" or "w" mode in popen() calls (the exceptions being for COPY data). This one has been overlooked (possibly because it's buried in a ".l" flex file?), but it's using PG_BINARY_R. Kensuke Okamura co

pgsql: Calculate extraUpdatedCols in query rewriter, not parser.

2020-10-28 Thread Tom Lane
Calculate extraUpdatedCols in query rewriter, not parser. It's unsafe to do this at parse time because addition of generated columns to a table would not invalidate stored rules containing UPDATEs on the table ... but there might now be dependent generated columns that were not there when the rule

pgsql: Calculate extraUpdatedCols in query rewriter, not parser.

2020-10-28 Thread Tom Lane
Calculate extraUpdatedCols in query rewriter, not parser. It's unsafe to do this at parse time because addition of generated columns to a table would not invalidate stored rules containing UPDATEs on the table ... but there might now be dependent generated columns that were not there when the rule

pgsql: Calculate extraUpdatedCols in query rewriter, not parser.

2020-10-28 Thread Tom Lane
Calculate extraUpdatedCols in query rewriter, not parser. It's unsafe to do this at parse time because addition of generated columns to a table would not invalidate stored rules containing UPDATEs on the table ... but there might now be dependent generated columns that were not there when the rule

pgsql: Don't use custom OID symbols in pg_proc.dat.

2020-10-28 Thread Tom Lane
Don't use custom OID symbols in pg_proc.dat. We have a perfectly good convention for OID macros for built-in functions already, so making custom symbols is just introducing unnecessary deviation from the convention. Remove the one case that had snuck in, and add an error check in genbki.pl to dis

pgsql: Fix foreign-key selectivity estimation in the presence of consta

2020-10-28 Thread Tom Lane
Fix foreign-key selectivity estimation in the presence of constants. get_foreign_key_join_selectivity() looks for join clauses that equate the two sides of the FK constraint. However, if we have a query like "WHERE fktab.a = pktab.a and fktab.a = 1", it won't find any such join clause, because eq