https://github.com/postgres/postgres
Revision f38903d1ed6fbafdfac0ba797337c682eeafe9f5 authored by Tom Lane on 09 February 2024, 17:29:41 UTC, committed by Tom Lane on 09 February 2024, 17:29:41 UTC
Since its introduction, pg_get_expr() has intended to silently
return NULL if called with an invalid relation OID, as can happen
when scanning the catalogs concurrently with relation drops.
However, there is a race condition: we check validity of the OID
at the start, but it could get dropped just afterward, leading to
failures.  This is the cause of some intermittent instability we're
seeing in a proposed new test case, and presumably it's a hazard in
the field as well.

We can fix this by AccessShareLock-ing the target relation for the
duration of pg_get_expr().  Since we don't require any permissions
on the target relation, this is semantically a bit undesirable.  But
it turns out that the set_relation_column_names() subroutine already
takes a transient AccessShareLock on that relation, and has done since
commit 2ffa740be in 2012.  Given the lack of complaints about that, it
seems like there should be no harm in holding the lock a bit longer.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/31ddcc01-a71b-4e8c-9948-01d1c47293ca@eisentraut.org
1 parent 9fb1396
History
Tip revision: f38903d1ed6fbafdfac0ba797337c682eeafe9f5 authored by Tom Lane on 09 February 2024, 17:29:41 UTC
Remove race condition in pg_get_expr().
Tip revision: f38903d
File Mode Size
expected
sql
.gitignore -rw-r--r-- 55 bytes
Makefile -rw-r--r-- 535 bytes
dict_xsyn--1.0.sql -rw-r--r-- 694 bytes
dict_xsyn--unpackaged--1.0.sql -rw-r--r-- 488 bytes
dict_xsyn.c -rw-r--r-- 5.0 KB
dict_xsyn.control -rw-r--r-- 179 bytes
xsyn_sample.rules -rw-r--r-- 139 bytes

back to top