pgsql: Blindly try to fix test script's tar invocation for MSYS.

2021-03-18 Thread Tom Lane
Blindly try to fix test script's tar invocation for MSYS. Buildfarm member fairywren doesn't like the test case I added in commit 081876d75. I'm guessing the reason is that I shouldn't be using a perl2host-ified path in the tar command line. Branch -- master Details --- https://git.post

pgsql: Fix comments in postmaster.c.

2021-03-18 Thread Fujii Masao
Fix comments in postmaster.c. Commit 86c23a6eb2 changed the option to specify that postgres will stop all other server processes by sending the signal SIGSTOP, from -s to -T. But previously there were comments incorrectly explaining that SIGSTOP behavior is set by -s option. This commit fixes them

pgsql: Don't leak malloc'd error string in libpqrcv_check_conninfo().

2021-03-18 Thread Tom Lane
Don't leak malloc'd error string in libpqrcv_check_conninfo(). We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all

pgsql: Don't run RelationInitTableAccessMethod in a long-lived context.

2021-03-18 Thread Tom Lane
Don't run RelationInitTableAccessMethod in a long-lived context. Some code paths in this function perform syscache lookups, which can lead to table accesses and possibly leakage of cruft into the caller's context. If said context is CacheMemoryContext, we eventually will have visible bloat. But

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak malloc'd error string in libpqrcv_check_conninfo().

2021-03-18 Thread Tom Lane
Don't leak malloc'd error string in libpqrcv_check_conninfo(). We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all

pgsql: Don't leak rd_statlist when a relcache entry is dropped.

2021-03-18 Thread Tom Lane
Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where thi

pgsql: Don't leak rd_statlist when a relcache entry is dropped.

2021-03-18 Thread Tom Lane
Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where thi

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak rd_statlist when a relcache entry is dropped.

2021-03-18 Thread Tom Lane
Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where thi

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak malloc'd error string in libpqrcv_check_conninfo().

2021-03-18 Thread Tom Lane
Don't leak malloc'd error string in libpqrcv_check_conninfo(). We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all

pgsql: Don't run RelationInitTableAccessMethod in a long-lived context.

2021-03-18 Thread Tom Lane
Don't run RelationInitTableAccessMethod in a long-lived context. Some code paths in this function perform syscache lookups, which can lead to table accesses and possibly leakage of cruft into the caller's context. If said context is CacheMemoryContext, we eventually will have visible bloat. But

pgsql: Don't leak rd_statlist when a relcache entry is dropped.

2021-03-18 Thread Tom Lane
Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where thi

pgsql: Don't leak rd_statlist when a relcache entry is dropped.

2021-03-18 Thread Tom Lane
Don't leak rd_statlist when a relcache entry is dropped. Although these lists are usually NIL, and even when not empty are unlikely to be large, constant relcache update traffic could eventually result in visible bloat of CacheMemoryContext. Found via valgrind testing. Back-patch to v10 where thi

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak malloc'd error string in libpqrcv_check_conninfo().

2021-03-18 Thread Tom Lane
Don't leak malloc'd error string in libpqrcv_check_conninfo(). We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all

pgsql: Don't run RelationInitTableAccessMethod in a long-lived context.

2021-03-18 Thread Tom Lane
Don't run RelationInitTableAccessMethod in a long-lived context. Some code paths in this function perform syscache lookups, which can lead to table accesses and possibly leakage of cruft into the caller's context. If said context is CacheMemoryContext, we eventually will have visible bloat. But

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak malloc'd strings when a GUC setting is rejected.

2021-03-18 Thread Tom Lane
Don't leak malloc'd strings when a GUC setting is rejected. Because guc.c prefers to keep all its string values in malloc'd not palloc'd storage, it has to be more careful than usual to avoid leaks. Error exits out of string GUC hook checks failed to clear the proposed value string, and error exi

pgsql: Don't leak compiled regex(es) when an ispell cache entry is drop

2021-03-18 Thread Tom Lane
Don't leak compiled regex(es) when an ispell cache entry is dropped. The text search cache mechanisms assume that we can clean up an invalidated dictionary cache entry simply by resetting the associated long-lived memory context. However, that does not work for ispell affixes that make use of reg

pgsql: Don't leak malloc'd error string in libpqrcv_check_conninfo().

2021-03-18 Thread Tom Lane
Don't leak malloc'd error string in libpqrcv_check_conninfo(). We leaked the error report from PQconninfoParse, when there was one. It seems unlikely that real usage patterns would repeat the failure often enough to create serious bloat, but let's back-patch anyway to keep the code similar in all

pgsql: Fix TAP test for remove_temp_files_after_crash

2021-03-18 Thread Tomas Vondra
Fix TAP test for remove_temp_files_after_crash The test included in cd91de0d17 had two simple flaws. Firstly, the number of rows was low and on some platforms (e.g. 32-bit) the sort did not require on-disk sort, so on those machines it was not testing the automatic removal. The test was however

pgsql: Improve tab completion of IMPORT FOREIGN SCHEMA with \h in psql

2021-03-18 Thread Michael Paquier
Improve tab completion of IMPORT FOREIGN SCHEMA with \h in psql Only "IMPORT" was showing as result of the completion, while IMPORT FOREIGN SCHEMA is the only command using this keyword in first position. This changes the completion to show the full command name instead of just "IMPORT". Reviewe

pgsql: Fix misuse of foreach_delete_current().

2021-03-18 Thread Tom Lane
Fix misuse of foreach_delete_current(). Our coding convention requires this macro's result to be assigned back to the original List variable. In this usage, since the List could not become empty, there was no actual bug --- but some compilers warned about it. Oversight in be45be9c3. Discussion:

pgsql: Implement GROUP BY DISTINCT

2021-03-18 Thread Tomas Vondra
Implement GROUP BY DISTINCT With grouping sets, it's possible that some of the grouping sets are duplicate. This is especially common with CUBE and ROLLUP clauses. For example GROUP BY CUBE (a,b), CUBE (b,c) is equivalent to GROUP BY GROUPING SETS ( (a, b, c), (a, b, c), (a, b, c),

pgsql: Remove temporary files after backend crash

2021-03-18 Thread Tomas Vondra
Remove temporary files after backend crash After a crash of a backend using temporary files, the files used to be left behind, on the basis that it might be useful for debugging. But we don't have any reports of anyone actually doing that, and it means the disk usage may grow over time due to repe

pgsql: Fix function name in error hint

2021-03-18 Thread Magnus Hagander
Fix function name in error hint pg_read_file() is the function that's in core, pg_file_read() is in adminpack. But when using pg_file_read() in adminpack it calls the *C* level function pg_read_file() in core, which probably threw the original author off. But the error hint should be about the SQL

pgsql: Fix function name in error hint

2021-03-18 Thread Magnus Hagander
Fix function name in error hint pg_read_file() is the function that's in core, pg_file_read() is in adminpack. But when using pg_file_read() in adminpack it calls the *C* level function pg_read_file() in core, which probably threw the original author off. But the error hint should be about the SQL

pgsql: Fix function name in error hint

2021-03-18 Thread Magnus Hagander
Fix function name in error hint pg_read_file() is the function that's in core, pg_file_read() is in adminpack. But when using pg_file_read() in adminpack it calls the *C* level function pg_read_file() in core, which probably threw the original author off. But the error hint should be about the SQL

pgsql: Fix function name in error hint

2021-03-18 Thread Magnus Hagander
Fix function name in error hint pg_read_file() is the function that's in core, pg_file_read() is in adminpack. But when using pg_file_read() in adminpack it calls the *C* level function pg_read_file() in core, which probably threw the original author off. But the error hint should be about the SQL

pgsql: Doc: Update description for parallel insert reloption.

2021-03-18 Thread Amit Kapila
Doc: Update description for parallel insert reloption. Commit c8f78b6161 added a new reloption to enable inserts in parallel-mode but forgot to update at one of the places about the same in docs. In passing, fix a typo in the same commit. Reported-by: Justin Pryzby Author: Justin Pryzby Reviewed-