aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/commands/indexcmds.c40
-rw-r--r--src/backend/nodes/copyfuncs.c6
-rw-r--r--src/backend/nodes/equalfuncs.c6
-rw-r--r--src/backend/parser/gram.y22
-rw-r--r--src/backend/parser/keywords.c3
-rw-r--r--src/backend/tcop/utility.c9
6 files changed, 54 insertions, 32 deletions
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 07adceb0228..6bfa8a04e24 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.132 2005/06/21 00:35:05 neilc Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/indexcmds.c,v 1.133 2005/06/22 21:14:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -898,10 +898,10 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior)
/*
* ReindexIndex
- * Recreate an index.
+ * Recreate a specific index.
*/
void
-ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
+ReindexIndex(RangeVar *indexRelation)
{
Oid indOid;
HeapTuple tuple;
@@ -931,10 +931,10 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
/*
* ReindexTable
- * Recreate indexes of a table.
+ * Recreate all indexes of a table (and of its toast table, if any)
*/
void
-ReindexTable(RangeVar *relation, bool force /* currently unused */ )
+ReindexTable(RangeVar *relation)
{
Oid heapOid;
HeapTuple tuple;
@@ -981,8 +981,7 @@ ReindexTable(RangeVar *relation, bool force /* currently unused */ )
* separate transaction, so we can release the lock on it right away.
*/
void
-ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
- bool all)
+ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
{
Relation relationRelation;
HeapScanDesc scan;
@@ -992,23 +991,23 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
List *relids = NIL;
ListCell *l;
- AssertArg(dbname);
+ AssertArg(databaseName);
- if (strcmp(dbname, get_database_name(MyDatabaseId)) != 0)
+ if (strcmp(databaseName, get_database_name(MyDatabaseId)) != 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("can only reindex the currently open database")));
if (!pg_database_ownercheck(MyDatabaseId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
- dbname);
+ databaseName);
/*
* We cannot run inside a user transaction block; if we were inside a
* transaction, then our commit- and start-transaction-command calls
* would not have the intended effect!
*/
- PreventTransactionChain((void *) dbname, "REINDEX DATABASE");
+ PreventTransactionChain((void *) databaseName, "REINDEX DATABASE");
/*
* Create a memory context that will survive forced transaction
@@ -1028,9 +1027,12 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
* before we process any other tables. This is critical because
* reindexing itself will try to update pg_class.
*/
- old = MemoryContextSwitchTo(private_context);
- relids = lappend_oid(relids, RelationRelationId);
- MemoryContextSwitchTo(old);
+ if (do_system)
+ {
+ old = MemoryContextSwitchTo(private_context);
+ relids = lappend_oid(relids, RelationRelationId);
+ MemoryContextSwitchTo(old);
+ }
/*
* Scan pg_class to build a list of the relations we need to reindex.
@@ -1047,9 +1049,15 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
if (classtuple->relkind != RELKIND_RELATION)
continue;
- if (!all) /* only system tables? */
+ /* Check user/system classification, and optionally skip */
+ if (IsSystemClass(classtuple))
+ {
+ if (!do_system)
+ continue;
+ }
+ else
{
- if (!IsSystemClass(classtuple))
+ if (!do_user)
continue;
}
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 2e0d8dbc1a2..2ce9edac707 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.307 2005/06/17 22:32:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.308 2005/06/22 21:14:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2467,8 +2467,8 @@ _copyReindexStmt(ReindexStmt *from)
COPY_SCALAR_FIELD(kind);
COPY_NODE_FIELD(relation);
COPY_STRING_FIELD(name);
- COPY_SCALAR_FIELD(force);
- COPY_SCALAR_FIELD(all);
+ COPY_SCALAR_FIELD(do_system);
+ COPY_SCALAR_FIELD(do_user);
return newnode;
}
diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c
index a991cf5eed3..e66ac81b755 100644
--- a/src/backend/nodes/equalfuncs.c
+++ b/src/backend/nodes/equalfuncs.c
@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.244 2005/06/17 22:32:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.245 2005/06/22 21:14:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1372,8 +1372,8 @@ _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
COMPARE_SCALAR_FIELD(kind);
COMPARE_NODE_FIELD(relation);
COMPARE_STRING_FIELD(name);
- COMPARE_SCALAR_FIELD(force);
- COMPARE_SCALAR_FIELD(all);
+ COMPARE_SCALAR_FIELD(do_system);
+ COMPARE_SCALAR_FIELD(do_user);
return true;
}
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d12fa9fa052..2603a652922 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.495 2005/06/17 22:32:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.496 2005/06/22 21:14:29 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -400,7 +400,7 @@ static void doNegateFloat(Value *v);
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYMMETRIC
- SYSID
+ SYSID SYSTEM_P
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
@@ -3641,8 +3641,9 @@ DropCastStmt: DROP CAST '(' Typename AS Typename ')' opt_drop_behavior
*
* QUERY:
*
- * REINDEX type <typename> [FORCE] [ALL]
+ * REINDEX type <name> [FORCE]
*
+ * FORCE no longer does anything, but we accept it for backwards compatibility
*****************************************************************************/
ReindexStmt:
@@ -3652,7 +3653,16 @@ ReindexStmt:
n->kind = $2;
n->relation = $3;
n->name = NULL;
- n->force = $4;
+ $$ = (Node *)n;
+ }
+ | REINDEX SYSTEM_P name opt_force
+ {
+ ReindexStmt *n = makeNode(ReindexStmt);
+ n->kind = OBJECT_DATABASE;
+ n->name = $3;
+ n->relation = NULL;
+ n->do_system = true;
+ n->do_user = false;
$$ = (Node *)n;
}
| REINDEX DATABASE name opt_force
@@ -3661,7 +3671,8 @@ ReindexStmt:
n->kind = OBJECT_DATABASE;
n->name = $3;
n->relation = NULL;
- n->force = $4;
+ n->do_system = true;
+ n->do_user = true;
$$ = (Node *)n;
}
;
@@ -7915,6 +7926,7 @@ unreserved_keyword:
| STDOUT
| STORAGE
| SYSID
+ | SYSTEM_P
| STRICT_P
| TABLESPACE
| TEMP
diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c
index 1e0c63a9ce2..009cc2e7ba6 100644
--- a/src/backend/parser/keywords.c
+++ b/src/backend/parser/keywords.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.157 2005/06/17 22:32:44 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.158 2005/06/22 21:14:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -300,6 +300,7 @@ static const ScanKeyword ScanKeywords[] = {
{"substring", SUBSTRING},
{"symmetric", SYMMETRIC},
{"sysid", SYSID},
+ {"system", SYSTEM_P},
{"table", TABLE},
{"tablespace", TABLESPACE},
{"temp", TEMP},
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index f948b0f854e..82bd8eafc11 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.237 2005/06/17 22:32:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.238 2005/06/22 21:14:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1011,13 +1011,14 @@ ProcessUtility(Node *parsetree,
switch (stmt->kind)
{
case OBJECT_INDEX:
- ReindexIndex(stmt->relation, stmt->force);
+ ReindexIndex(stmt->relation);
break;
case OBJECT_TABLE:
- ReindexTable(stmt->relation, stmt->force);
+ ReindexTable(stmt->relation);
break;
case OBJECT_DATABASE:
- ReindexDatabase(stmt->name, stmt->force, false);
+ ReindexDatabase(stmt->name,
+ stmt->do_system, stmt->do_user);
break;
default:
elog(ERROR, "unrecognized object type: %d",