tableam: Add use tableam_fetch_follow_check().
authorAndres Freund <[email protected]>
Sun, 20 Jan 2019 06:51:43 +0000 (22:51 -0800)
committerAndres Freund <[email protected]>
Wed, 6 Mar 2019 06:59:31 +0000 (22:59 -0800)
Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:

src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtsort.c
src/backend/access/table/tableam.c
src/include/access/tableam.h

index 2b1802882393bcd6edba62d2be032db34c32f052..bdb66445105a1ca862f1a51dbd11823e437d3c7c 100644 (file)
@@ -15,9 +15,9 @@
 
 #include "postgres.h"
 
-#include "access/heapam.h"
 #include "access/nbtree.h"
 #include "access/nbtxlog.h"
+#include "access/tableam.h"
 #include "access/transam.h"
 #include "access/xloginsert.h"
 #include "miscadmin.h"
@@ -414,8 +414,8 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
                 * that satisfies SnapshotDirty.  This is necessary because we
                 * have just a single index entry for the entire chain.
                 */
-               else if (heap_hot_search(&htid, heapRel, &SnapshotDirty,
-                                        &all_dead))
+               else if (table_fetch_follow_check(heapRel, &htid, &SnapshotDirty,
+                                                 &all_dead))
                {
                    TransactionId xwait;
 
@@ -468,7 +468,7 @@ _bt_check_unique(Relation rel, IndexTuple itup, Relation heapRel,
                     * entry.
                     */
                    htid = itup->t_tid;
-                   if (heap_hot_search(&htid, heapRel, SnapshotSelf, NULL))
+                   if (table_fetch_follow_check(heapRel, &htid, SnapshotSelf, NULL))
                    {
                        /* Normal case --- it's still live */
                    }
index 7542c29c799bb92bf5f8f6232e5bbb8e5396873b..7360162c6ccd5ea180073843792edb67db147f2f 100644 (file)
 
 #include "postgres.h"
 
-#include "access/heapam.h"
 #include "access/nbtree.h"
 #include "access/parallel.h"
 #include "access/relscan.h"
+#include "access/table.h"
 #include "access/tableam.h"
 #include "access/xact.h"
 #include "access/xlog.h"
index 8738b6ac6aa61b688cbfc62cdeb165e51a66981a..43e5444dcb35090d7b352d625407e2ceb953df33 100644 (file)
@@ -152,6 +152,25 @@ table_beginscan_catalog(Relation relation, int nkeys, struct ScanKeyData *key)
                                            true, true, true, false, false, true);
 }
 
+bool
+table_fetch_follow_check(Relation rel,
+                        ItemPointer tid,
+                        Snapshot snapshot,
+                        bool *all_dead)
+{
+   IndexFetchTableData *scan = table_begin_index_fetch_table(rel);
+   TupleTableSlot *slot = table_gimmegimmeslot(rel, NULL);
+   bool        call_again = false;
+   bool        found;
+
+   found = table_fetch_follow(scan, tid, snapshot, slot, &call_again, all_dead);
+
+   table_end_index_fetch_table(scan);
+   ExecDropSingleTupleTableSlot(slot);
+
+   return found;
+}
+
 /*
  * simple_table_update - replace a tuple
  *
index fa5ea9c6680e95ad72f06832602fdab4f23e66af..a640910eddfce15f9bd47a9947bef97915bc5756 100644 (file)
@@ -464,6 +464,11 @@ table_fetch_follow(struct IndexFetchTableData *scan,
                                                     all_dead);
 }
 
+extern bool table_fetch_follow_check(Relation rel,
+                                    ItemPointer tid,
+                                    Snapshot snapshot,
+                                    bool *all_dead);
+
 /*
  * Return true iff tuple in slot satisfies the snapshot.
  *