Skip to content

Commit d435592

Browse files
committed
Repair oversight in recent changes to index-creation: tuple time qual
check *can* return HEAPTUPLE_INSERT_IN_PROGRESS or HEAPTUPLE_DELETE_IN_PROGRESS, even though we have ShareLock on the relation. To wit, this can happen if the tuple was inserted/deleted by our own transaction. Per report from Justin Clift 9/23.
1 parent 1481b3b commit d435592

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/backend/catalog/index.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.163 2001/08/26 16:55:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.164 2001/09/26 21:09:27 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1789,19 +1789,27 @@ IndexBuildHeapScan(Relation heapRelation,
17891789
break;
17901790
case HEAPTUPLE_INSERT_IN_PROGRESS:
17911791
/*
1792-
* This should not happen, if caller holds ShareLock on
1793-
* the parent relation.
1792+
* Since caller should hold ShareLock or better, we should
1793+
* not see any tuples inserted by open transactions ---
1794+
* unless it's our own transaction. (Consider INSERT
1795+
* followed by CREATE INDEX within a transaction.)
17941796
*/
1795-
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
1796-
indexIt = tupleIsAlive = false; /* keep compiler quiet */
1797+
if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmin))
1798+
elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress");
1799+
indexIt = true;
1800+
tupleIsAlive = true;
17971801
break;
17981802
case HEAPTUPLE_DELETE_IN_PROGRESS:
17991803
/*
1800-
* This should not happen, if caller holds ShareLock on
1801-
* the parent relation.
1804+
* Since caller should hold ShareLock or better, we should
1805+
* not see any tuples deleted by open transactions ---
1806+
* unless it's our own transaction. (Consider DELETE
1807+
* followed by CREATE INDEX within a transaction.)
18021808
*/
1803-
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
1804-
indexIt = tupleIsAlive = false; /* keep compiler quiet */
1809+
if (! TransactionIdIsCurrentTransactionId(heapTuple->t_data->t_xmax))
1810+
elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress");
1811+
indexIt = true;
1812+
tupleIsAlive = false;
18051813
break;
18061814
default:
18071815
elog(ERROR, "Unexpected HeapTupleSatisfiesVacuum result");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy