diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-04-08 00:46:14 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2021-04-08 00:46:14 -0400 |
commit | 4131f755d548f74eba56285dc674f1f26e4ed6b4 (patch) | |
tree | b71b2fe2de504b965b0473e28a695d6823525965 /src | |
parent | a3027e1e7f3d3a107ecd72d3b4d6333ea2aab6a5 (diff) | |
download | postgresql-4131f755d548f74eba56285dc674f1f26e4ed6b4.tar.gz postgresql-4131f755d548f74eba56285dc674f1f26e4ed6b4.zip |
Repair find_inheritance_children with no active snapshot
When working on a scan with only a catalog snapshot, we may not have an
ActiveSnapshot set. If we were to come across a detached partition,
that would cause a crash. Fix by only ignoring detached partitions when
there's an active snapshot.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/catalog/pg_inherits.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/backend/catalog/pg_inherits.c b/src/backend/catalog/pg_inherits.c index bedee069be2..bb8b2249b10 100644 --- a/src/backend/catalog/pg_inherits.c +++ b/src/backend/catalog/pg_inherits.c @@ -106,10 +106,13 @@ find_inheritance_children(Oid parentrelId, bool include_detached, * * The reason for this check is that we want to avoid seeing the * partition as alive in RI queries during REPEATABLE READ or - * SERIALIZABLE transactions. + * SERIALIZABLE transactions. (If there's no active snapshot set, + * that means we're not running a user query, so it's OK to always + * include detached partitions in that case.) */ if (((Form_pg_inherits) GETSTRUCT(inheritsTuple))->inhdetachpending && - !include_detached) + !include_detached && + ActiveSnapshotSet()) { TransactionId xmin; Snapshot snap; |