summaryrefslogtreecommitdiff
path: root/src/backend/catalog/toasting.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/catalog/toasting.c')
-rw-r--r--src/backend/catalog/toasting.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 142beaeb6e..c4be3a9ae3 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -115,6 +115,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
TupleDesc tupdesc;
bool shared_relation;
bool mapped_relation;
+ Relation toast_rel;
Relation class_rel;
Oid toast_relid;
Oid toast_idxid;
@@ -229,9 +230,12 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
false);
Assert(toast_relid != InvalidOid);
- /* make the toast relation visible, else index creation will fail */
+ /* make the toast relation visible, else heap_open will fail */
CommandCounterIncrement();
+ /* ShareLock is not really needed here, but take it anyway */
+ toast_rel = heap_open(toast_relid, ShareLock);
+
/*
* Create unique index on chunk_id, chunk_seq.
*
@@ -266,7 +270,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
coloptions[0] = 0;
coloptions[1] = 0;
- toast_idxid = index_create(toast_relid, toast_idxname, toastIndexOid,
+ toast_idxid = index_create(toast_rel, toast_idxname, toastIndexOid,
indexInfo,
list_make2("chunk_id", "chunk_seq"),
BTREE_AM_OID,
@@ -275,6 +279,8 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid, Datum reloptio
true, false, false, false,
true, false, false);
+ heap_close(toast_rel, NoLock);
+
/*
* Store the toast table's OID in the parent relation's pg_class row
*/