postgresql/src
Heikki Linnakangas 6bf00da115 Fix snapshot reference leak if lo_export fails.
If lo_export() fails to open the target file or to write to it, it leaks
the created LargeObjectDesc and its snapshot in the top-transaction
context and resource owner. That's pretty harmless, it's a small leak
after all, but it gives the user a "Snapshot reference leak" warning.

Fix by using a short-lived memory context and no resource owner for
transient LargeObjectDescs that are opened and closed within one function
call. The leak is easiest to reproduce with lo_export() on a directory
that doesn't exist, but in principle the other lo_* functions could also
fail.

Backpatch to all supported versions.

Reported-by: Andrew B
Reviewed-by: Alvaro Herrera
Discussion: https://www.postgresql.org/message-id/32bf767a-2d65-71c4-f170-122f416bab7e@iki.fi
2021-11-03 10:54:42 +02:00
..
backend Fix snapshot reference leak if lo_export fails. 2021-11-03 10:54:42 +02:00
bin Clarify that --system reindexes system catalogs *only* 2021-10-27 16:29:07 +02:00
common Replace use of sys_siglist[] with strsignal(). 2020-07-15 22:05:12 -04:00
fe_utils Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
include Fix CREATE INDEX CONCURRENTLY for the newest prepared transactions. 2021-10-23 18:36:43 -07:00
interfaces Fix error handling with threads on OOM in ECPG connection logic 2021-09-13 13:24:35 +09:00
makefiles Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:36 -04:00
pl Fix Portal snapshot tracking to handle subtransactions properly. 2021-10-01 11:10:12 -04:00
port Stamp 11.13. 2021-08-09 16:52:43 -04:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:41 -05:00
test Fix snapshot reference leak if lo_export fails. 2021-11-03 10:54:42 +02:00
timezone Update time zone data files to tzdata release 2021e. 2021-10-29 11:38:53 -04:00
tools Back-patch "Stop requiring an explicit return from perl subroutines" 2021-10-23 19:36:30 -07:00
tutorial tutorial: land height is "elevation", not "altitude" 2021-03-10 20:25:18 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Fix prove_installcheck to use correct paths when used with PGXS 2021-07-01 08:47:21 -04:00
Makefile.shlib Ensure static libraries have correct mod time even if ranlib messes it up. 2018-11-29 15:53:44 -05:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00