Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83322e3

Browse files
committed
tableam: Allow choice of toast AM.
Previously, the toast table had to be implemented by the same AM thatwas used for the main table, which was bad, because the detoastingcode won't work with anything but heap. This commit doesn't fix thelatter problem, although there's another patch coming which does,but it does let you pick something that works (i.e. heap, right now).Patch by me, reviewed by Andres Freund.Discussion:http://postgr.es/m/CA+TgmoZv-=2iWM4jcw5ZhJeL18HF96+W1yJeYrnGMYdkFFnEpQ@mail.gmail.com
1 parent8147278 commit83322e3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

‎src/backend/access/heap/heapam_handler.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,15 @@ heapam_relation_needs_toast_table(Relation rel)
20372037
return (tuple_length>TOAST_TUPLE_THRESHOLD);
20382038
}
20392039

2040+
/*
2041+
* TOAST tables for heap relations are just heap relations.
2042+
*/
2043+
staticOid
2044+
heapam_relation_toast_am(Relationrel)
2045+
{
2046+
returnrel->rd_rel->relam;
2047+
}
2048+
20402049

20412050
/* ------------------------------------------------------------------------
20422051
* Planner related callbacks for the heap AM
@@ -2535,6 +2544,7 @@ static const TableAmRoutine heapam_methods = {
25352544

25362545
.relation_size=table_block_relation_size,
25372546
.relation_needs_toast_table=heapam_relation_needs_toast_table,
2547+
.relation_toast_am=heapam_relation_toast_am,
25382548

25392549
.relation_estimate_size=heapam_estimate_rel_size,
25402550

‎src/backend/catalog/toasting.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
258258
toast_typid,
259259
InvalidOid,
260260
rel->rd_rel->relowner,
261-
rel->rd_rel->relam,
261+
table_relation_toast_am(rel),
262262
tupdesc,
263263
NIL,
264264
RELKIND_TOASTVALUE,

‎src/include/access/tableam.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,13 @@ typedef struct TableAmRoutine
581581
*/
582582
bool(*relation_needs_toast_table) (Relationrel);
583583

584+
/*
585+
* This callback should return the OID of the table AM that implements
586+
* TOAST tables for this AM. If the relation_needs_toast_table callback
587+
* always returns false, this callback is not required.
588+
*/
589+
Oid (*relation_toast_am) (Relationrel);
590+
584591

585592
/* ------------------------------------------------------------------------
586593
* Planner related functions.
@@ -1603,6 +1610,16 @@ table_relation_needs_toast_table(Relation rel)
16031610
returnrel->rd_tableam->relation_needs_toast_table(rel);
16041611
}
16051612

1613+
/*
1614+
* Return the OID of the AM that should be used to implement the TOAST table
1615+
* for this relation.
1616+
*/
1617+
staticinlineOid
1618+
table_relation_toast_am(Relationrel)
1619+
{
1620+
returnrel->rd_tableam->relation_toast_am(rel);
1621+
}
1622+
16061623

16071624
/* ----------------------------------------------------------------------------
16081625
* Planner related functionality

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp