Skip to content

Commit ad0169b

Browse files
committed
CLUSTER forgot to create a TOAST table for the clustered relation.
1 parent 9315ff5 commit ad0169b

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/backend/commands/cluster.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.60 2000/11/16 22:30:18 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.61 2001/01/01 21:35:00 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -29,6 +29,7 @@
2929
#include "catalog/pg_index.h"
3030
#include "catalog/pg_proc.h"
3131
#include "commands/cluster.h"
32+
#include "commands/command.h"
3233
#include "commands/rename.h"
3334
#include "miscadmin.h"
3435
#include "utils/builtins.h"
@@ -106,8 +107,7 @@ cluster(char *oldrelname, char *oldindexname)
106107

107108
OIDNewHeap = copy_heap(OIDOldHeap, NewHeapName);
108109

109-
/* To make the new heap visible (which is until now empty). */
110-
CommandCounterIncrement();
110+
/* We do not need CommandCounterIncrement() because copy_heap did it. */
111111

112112
/*
113113
* Copy the heap data into the new table in the desired order.
@@ -150,16 +150,27 @@ copy_heap(Oid OIDOldHeap, char *NewName)
150150

151151
/*
152152
* Need to make a copy of the tuple descriptor,
153-
* heap_create_with_catalog modifies it.
153+
* since heap_create_with_catalog modifies it.
154154
*/
155155
tupdesc = CreateTupleDescCopy(OldHeapDesc);
156156

157157
OIDNewHeap = heap_create_with_catalog(NewName, tupdesc,
158158
RELKIND_RELATION, false,
159159
allowSystemTableMods);
160160

161-
if (!OidIsValid(OIDNewHeap))
162-
elog(ERROR, "copy_heap: cannot create temporary heap relation");
161+
/*
162+
* Advance command counter so that the newly-created
163+
* relation's catalog tuples will be visible to heap_open.
164+
*/
165+
CommandCounterIncrement();
166+
167+
/*
168+
* If necessary, create a TOAST table for the new relation.
169+
* Note that AlterTableCreateToastTable ends with
170+
* CommandCounterIncrement(), so that the TOAST table will
171+
* be visible for insertion.
172+
*/
173+
AlterTableCreateToastTable(NewName, true);
163174

164175
heap_close(OldHeap, NoLock);
165176

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