aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/access/heap/heapam_handler.c10
-rw-r--r--src/backend/catalog/toasting.c2
-rw-r--r--src/include/access/tableam.h17
3 files changed, 28 insertions, 1 deletions
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index a6c369eaea7..1ed60f4f4e5 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -2037,6 +2037,15 @@ heapam_relation_needs_toast_table(Relation rel)
return (tuple_length > TOAST_TUPLE_THRESHOLD);
}
+/*
+ * TOAST tables for heap relations are just heap relations.
+ */
+static Oid
+heapam_relation_toast_am(Relation rel)
+{
+ return rel->rd_rel->relam;
+}
+
/* ------------------------------------------------------------------------
* Planner related callbacks for the heap AM
@@ -2535,6 +2544,7 @@ static const TableAmRoutine heapam_methods = {
.relation_size = table_block_relation_size,
.relation_needs_toast_table = heapam_relation_needs_toast_table,
+ .relation_toast_am = heapam_relation_toast_am,
.relation_estimate_size = heapam_estimate_rel_size,
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 2dfac45b5bc..33344476cac 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -258,7 +258,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
toast_typid,
InvalidOid,
rel->rd_rel->relowner,
- rel->rd_rel->relam,
+ table_relation_toast_am(rel),
tupdesc,
NIL,
RELKIND_TOASTVALUE,
diff --git a/src/include/access/tableam.h b/src/include/access/tableam.h
index b14082a6f64..c30a435b72c 100644
--- a/src/include/access/tableam.h
+++ b/src/include/access/tableam.h
@@ -581,6 +581,13 @@ typedef struct TableAmRoutine
*/
bool (*relation_needs_toast_table) (Relation rel);
+ /*
+ * This callback should return the OID of the table AM that implements
+ * TOAST tables for this AM. If the relation_needs_toast_table callback
+ * always returns false, this callback is not required.
+ */
+ Oid (*relation_toast_am) (Relation rel);
+
/* ------------------------------------------------------------------------
* Planner related functions.
@@ -1603,6 +1610,16 @@ table_relation_needs_toast_table(Relation rel)
return rel->rd_tableam->relation_needs_toast_table(rel);
}
+/*
+ * Return the OID of the AM that should be used to implement the TOAST table
+ * for this relation.
+ */
+static inline Oid
+table_relation_toast_am(Relation rel)
+{
+ return rel->rd_tableam->relation_toast_am(rel);
+}
+
/* ----------------------------------------------------------------------------
* Planner related functionality