aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Wieck <JanWieck@Yahoo.com>2000-07-05 13:22:25 +0000
committerJan Wieck <JanWieck@Yahoo.com>2000-07-05 13:22:25 +0000
commit93e1f5de0bc45d0ecd77fa0cf642d9e75b7c5fbf (patch)
tree09e4f8733e521d561926623f5adc3d3c6a64d165 /src
parent030962da262d9238a83b3d70a1720acdcf3efaea (diff)
downloadpostgresql-93e1f5de0bc45d0ecd77fa0cf642d9e75b7c5fbf.tar.gz
postgresql-93e1f5de0bc45d0ecd77fa0cf642d9e75b7c5fbf.zip
Automatically create toast tables on ALTER TABLE ... ADD COLUMN
and SELECT ... INTO ... too. Jan
Diffstat (limited to 'src')
-rw-r--r--src/backend/commands/command.c22
-rw-r--r--src/backend/executor/execMain.c8
2 files changed, 28 insertions, 2 deletions
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index bb77fdf11fc..7c5d4edd8d1 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.84 2000/07/05 12:45:25 wieck Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.85 2000/07/05 13:22:23 wieck Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -471,6 +471,13 @@ AlterTableAddColumn(const char *relationName,
heap_freetuple(reltup);
heap_close(rel, NoLock);
+
+ /*
+ * Automatically create the secondary relation for TOAST
+ * if it formerly had no such but now has toastable attributes.
+ */
+ CommandCounterIncrement();
+ AlterTableCreateToastTable(relationName, true);
}
@@ -1255,6 +1262,7 @@ AlterTableCreateToastTable(const char *relationName, bool silent)
{
heap_close(rel, NoLock);
heap_close(class_rel, NoLock);
+ heap_freetuple(reltup);
return;
}
@@ -1276,8 +1284,18 @@ AlterTableCreateToastTable(const char *relationName, bool silent)
}
if (((Form_pg_class) GETSTRUCT(reltup))->reltoastrelid != InvalidOid)
+ {
+ if (silent)
+ {
+ heap_close(rel, NoLock);
+ heap_close(class_rel, NoLock);
+ heap_freetuple(reltup);
+ return;
+ }
+
elog(ERROR, "ALTER TABLE: relation \"%s\" already has a toast table",
relationName);
+ }
/*
* Create the toast table and its index
@@ -1348,6 +1366,8 @@ AlterTableCreateToastTable(const char *relationName, bool silent)
heap_close(class_rel, NoLock);
heap_close(rel, NoLock);
+
+ CommandCounterIncrement();
}
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 7492c7ae2f6..c707315081d 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -27,7 +27,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.119 2000/07/04 06:11:33 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.120 2000/07/05 13:22:25 wieck Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,6 +35,7 @@
#include "access/heapam.h"
#include "catalog/heap.h"
+#include "commands/command.h"
#include "commands/trigger.h"
#include "executor/execdebug.h"
#include "executor/execdefs.h"
@@ -892,6 +893,11 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
*/
CommandCounterIncrement();
+ /*
+ * Eventually create a TOAST table for the into relation
+ */
+ AlterTableCreateToastTable(intoName, true);
+
intoRelationDesc = heap_open(intoRelationId,
AccessExclusiveLock);
}