summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2006-07-31 01:16:38 +0000
committerTom Lane2006-07-31 01:16:38 +0000
commit6e38e34d64b5769272e0ab873416aa6c95509b50 (patch)
tree2400d919e0296ff0fd4d014ccb7846bc2c8c7f69 /src/include
parent638860ce3581f80f836c7374936a250ec46f35a2 (diff)
Change the bootstrap sequence so that toast tables for system catalogs are
created in the bootstrap phase proper, rather than added after-the-fact by initdb. This is cleaner than before because it allows us to retire the undocumented ALTER TABLE ... CREATE TOAST TABLE command, but the real reason I'm doing it is so that toast tables of shared catalogs will now have predetermined OIDs. This will allow a reasonably clean solution to the problem of locking tables before we load their relcache entries, to appear in a forthcoming patch.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h4
-rwxr-xr-xsrc/include/catalog/duplicate_oids8
-rw-r--r--src/include/catalog/index.h6
-rw-r--r--src/include/catalog/toasting.h61
-rwxr-xr-xsrc/include/catalog/unused_oids10
-rw-r--r--src/include/commands/tablecmds.h4
-rw-r--r--src/include/nodes/parsenodes.h3
7 files changed, 78 insertions, 18 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 7386e91eaf6..052d2a19cfd 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.343 2006/07/28 18:33:04 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.344 2006/07/31 01:16:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200607281
+#define CATALOG_VERSION_NO 200607301
#endif
diff --git a/src/include/catalog/duplicate_oids b/src/include/catalog/duplicate_oids
index 1964faabe3d..ea58f4a0252 100755
--- a/src/include/catalog/duplicate_oids
+++ b/src/include/catalog/duplicate_oids
@@ -2,7 +2,7 @@
#
# duplicate_oids
#
-# $PostgreSQL: pgsql/src/include/catalog/duplicate_oids,v 1.7 2005/04/14 01:38:20 tgl Exp $
+# $PostgreSQL: pgsql/src/include/catalog/duplicate_oids,v 1.8 2006/07/31 01:16:37 tgl Exp $
#
# finds manually-assigned oids that are duplicated in the system tables.
#
@@ -12,12 +12,14 @@
# note: we exclude BKI_BOOTSTRAP relations since they are expected to have
# matching DATA lines in pg_class.h
-cat pg_*.h indexing.h | \
+cat pg_*.h toasting.h indexing.h | \
egrep -v -e '^CATALOG\(.*BKI_BOOTSTRAP' | \
sed -n -e 's/^DATA(insert *OID *= *\([0-9][0-9]*\).*$/\1/p' \
-e 's/^CATALOG([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
-e 's/^DECLARE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
- -e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' | \
+ -e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
+ -e 's/^DECLARE_TOAST([^,]*, *\([0-9][0-9]*\), *\([0-9][0-9]*\).*$/\1,\2/p' | \
+tr ',' '\n' | \
sort -n | \
uniq -d
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index 7d2059ed03b..f54508fb5b4 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.69 2006/07/13 16:49:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/index.h,v 1.70 2006/07/31 01:16:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,7 +37,6 @@ extern Oid index_create(Oid heapRelationId,
Oid *classObjectId,
Datum reloptions,
bool isprimary,
- bool istoast,
bool isconstraint,
bool allow_system_table_mods,
bool skip_build);
@@ -57,8 +56,7 @@ extern void setNewRelfilenode(Relation relation);
extern void index_build(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo,
- bool isprimary,
- bool istoast);
+ bool isprimary);
extern double IndexBuildHeapScan(Relation heapRelation,
Relation indexRelation,
diff --git a/src/include/catalog/toasting.h b/src/include/catalog/toasting.h
new file mode 100644
index 00000000000..25a84b3f880
--- /dev/null
+++ b/src/include/catalog/toasting.h
@@ -0,0 +1,61 @@
+/*-------------------------------------------------------------------------
+ *
+ * toasting.h
+ * This file provides some definitions to support creation of toast tables
+ *
+ *
+ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * $PostgreSQL: pgsql/src/include/catalog/toasting.h,v 1.1 2006/07/31 01:16:37 tgl Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TOASTING_H
+#define TOASTING_H
+
+/*
+ * toasting.c prototypes
+ */
+extern void AlterTableCreateToastTable(Oid relOid);
+extern void BootstrapToastTable(char *relName,
+ Oid toastOid, Oid toastIndexOid);
+
+
+/*
+ * This macro is just to keep the C compiler from spitting up on the
+ * upcoming commands for genbki.sh.
+ */
+#define DECLARE_TOAST(name,toastoid,indexoid) extern int no_such_variable
+
+
+/*
+ * What follows are lines processed by genbki.sh to create the statements
+ * the bootstrap parser will turn into BootstrapToastTable commands.
+ * Each line specifies the system catalog that needs a toast table,
+ * the OID to assign to the toast table, and the OID to assign to the
+ * toast table's index. The reason we hard-wire these OIDs is that we
+ * need stable OIDs for shared relations, and that includes toast tables
+ * of shared relations.
+ */
+
+/* normal catalogs */
+DECLARE_TOAST(pg_attrdef,2830,2831);
+DECLARE_TOAST(pg_constraint,2832,2833);
+DECLARE_TOAST(pg_description,2834,2835);
+DECLARE_TOAST(pg_proc,2836,2837);
+DECLARE_TOAST(pg_rewrite,2838,2839);
+DECLARE_TOAST(pg_statistic,2840,2841);
+
+/* shared catalogs */
+DECLARE_TOAST(pg_authid,2842,2843);
+#define PgAuthidToastTable 2842
+#define PgAuthidToastIndex 2843
+DECLARE_TOAST(pg_database,2844,2845);
+#define PgDatabaseToastTable 2844
+#define PgDatabaseToastIndex 2845
+DECLARE_TOAST(pg_shdescription,2846,2847);
+#define PgShdescriptionToastTable 2846
+#define PgShdescriptionToastIndex 2847
+
+#endif /* TOASTING_H */
diff --git a/src/include/catalog/unused_oids b/src/include/catalog/unused_oids
index c83a637196a..4003beef532 100755
--- a/src/include/catalog/unused_oids
+++ b/src/include/catalog/unused_oids
@@ -2,7 +2,7 @@
#
# unused_oids
#
-# $PostgreSQL: pgsql/src/include/catalog/unused_oids,v 1.7 2005/04/14 01:38:21 tgl Exp $
+# $PostgreSQL: pgsql/src/include/catalog/unused_oids,v 1.8 2006/07/31 01:16:38 tgl Exp $
#
# finds blocks of manually-assignable oids that have not already been
# claimed by post_hackers. primarily useful for finding available
@@ -23,16 +23,18 @@ AWK="awk"
FIRSTOBJECTID=`grep '#define[ ]*FirstBootstrapObjectId' ../access/transam.h | $AWK '{ print $3 }'`
export FIRSTOBJECTID
-# this part (down to the uniq step) should match the unused_oids script
+# this part (down to the uniq step) should match the duplicate_oids script
# note: we exclude BKI_BOOTSTRAP relations since they are expected to have
# matching DATA lines in pg_class.h
-cat pg_*.h indexing.h | \
+cat pg_*.h toasting.h indexing.h | \
egrep -v -e '^CATALOG\(.*BKI_BOOTSTRAP' | \
sed -n -e 's/^DATA(insert *OID *= *\([0-9][0-9]*\).*$/\1/p' \
-e 's/^CATALOG([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
-e 's/^DECLARE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
- -e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' | \
+ -e 's/^DECLARE_UNIQUE_INDEX([^,]*, *\([0-9][0-9]*\).*$/\1/p' \
+ -e 's/^DECLARE_TOAST([^,]*, *\([0-9][0-9]*\), *\([0-9][0-9]*\).*$/\1,\2/p' | \
+tr ',' '\n' | \
sort -n | \
uniq | \
$AWK '
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 41c1fd9f14d..4c9063f13ca 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.29 2006/07/13 16:49:19 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.30 2006/07/31 01:16:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,8 +28,6 @@ extern void ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing);
extern void AlterTableInternal(Oid relid, List *cmds, bool recurse);
-extern void AlterTableCreateToastTable(Oid relOid, bool silent);
-
extern void AlterTableNamespace(RangeVar *relation, const char *newschema);
extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index c44ba954d84..5c227156f06 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.318 2006/07/26 19:31:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.319 2006/07/31 01:16:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -854,7 +854,6 @@ typedef enum AlterTableType
AT_DropConstraintQuietly, /* drop constraint, no error/warning (local in
* commands/tablecmds.c) */
AT_AlterColumnType, /* alter column type */
- AT_ToastTable, /* create toast table */
AT_ChangeOwner, /* change owner */
AT_ClusterOn, /* CLUSTER ON */
AT_DropCluster, /* SET WITHOUT CLUSTER */