Commit 4cc7a93d authored by Tom Lane's avatar Tom Lane

Make REINDEX DATABASE do what one would expect, namely reindex all indexes

in the database.  The old behavior (reindex system catalogs only) is now
available as REINDEX SYSTEM.  I did not add the complementary REINDEX USER
case since there did not seem to be consensus for this, but it would be
trivial to add later.  Per recent discussions.
parent e98edb55
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.44 2005/06/13 02:40:04 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.45 2005/06/22 21:14:28 tgl Exp $
--> -->
<chapter id="maintenance"> <chapter id="maintenance">
...@@ -468,8 +468,7 @@ HINT: Stop the postmaster and use a standalone backend to VACUUM in "mydb". ...@@ -468,8 +468,7 @@ HINT: Stop the postmaster and use a standalone backend to VACUUM in "mydb".
<para> <para>
In some situations it is worthwhile to rebuild indexes periodically In some situations it is worthwhile to rebuild indexes periodically
with the <command>REINDEX</> command. (There is also with the <command>REINDEX</> command.
<filename>contrib/reindexdb</> which can reindex an entire database.)
However, <productname>PostgreSQL</> 7.4 has substantially reduced the need However, <productname>PostgreSQL</> 7.4 has substantially reduced the need
for this activity compared to earlier releases. for this activity compared to earlier releases.
</para> </para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/reindex.sgml,v 1.26 2005/01/22 23:22:19 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/reindex.sgml,v 1.27 2005/06/22 21:14:28 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -20,7 +20,7 @@ PostgreSQL documentation ...@@ -20,7 +20,7 @@ PostgreSQL documentation
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replaceable> [ FORCE ] REINDEX { INDEX | TABLE | DATABASE | SYSTEM } <replaceable class="PARAMETER">name</replaceable> [ FORCE ]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -28,7 +28,7 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -28,7 +28,7 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
<title>Description</title> <title>Description</title>
<para> <para>
<command>REINDEX</command> rebuilds an index based on the data <command>REINDEX</command> rebuilds an index using the data
stored in the index's table, replacing the old copy of the index. There are stored in the index's table, replacing the old copy of the index. There are
two main reasons to use <command>REINDEX</command>: two main reasons to use <command>REINDEX</command>:
...@@ -63,12 +63,10 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -63,12 +63,10 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><literal>DATABASE</literal></term> <term><literal>INDEX</literal></term>
<listitem> <listitem>
<para> <para>
Recreate all system indexes of a specified database. Indexes on Recreate the specified index.
user tables are not processed. Also, indexes on shared system
catalogs are skipped except in stand-alone mode (see below).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -77,17 +75,30 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -77,17 +75,30 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
<term><literal>TABLE</literal></term> <term><literal>TABLE</literal></term>
<listitem> <listitem>
<para> <para>
Recreate all indexes of a specified table. If the table has a Recreate all indexes of the specified table. If the table has a
secondary <quote>TOAST</> table, that is reindexed as well. secondary <quote>TOAST</> table, that is reindexed as well.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><literal>INDEX</literal></term> <term><literal>DATABASE</literal></term>
<listitem> <listitem>
<para> <para>
Recreate a specified index. Recreate all indexes within the current database.
Indexes on shared system catalogs are skipped except in stand-alone mode
(see below).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>SYSTEM</literal></term>
<listitem>
<para>
Recreate all indexes on system catalogs within the current database.
Indexes on user tables are not processed. Also, indexes on shared
system catalogs are skipped except in stand-alone mode (see below).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -96,10 +107,11 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -96,10 +107,11 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
<term><replaceable class="PARAMETER">name</replaceable></term> <term><replaceable class="PARAMETER">name</replaceable></term>
<listitem> <listitem>
<para> <para>
The name of the specific database, table, or index to be The name of the specific index, table, or database to be
reindexed. Table and index names may be schema-qualified. reindexed. Index and table names may be schema-qualified.
Presently, <command>REINDEX DATABASE</> can only reindex the current Presently, <command>REINDEX DATABASE</> and <command>REINDEX SYSTEM</>
database, so its parameter must match the current database's name. can only reindex the current database, so their parameter must match
the current database's name.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -139,10 +151,10 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -139,10 +151,10 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
One way to do this is to shut down the postmaster and start a stand-alone One way to do this is to shut down the postmaster and start a stand-alone
<productname>PostgreSQL</productname> server <productname>PostgreSQL</productname> server
with the <option>-P</option> option included on its command line. with the <option>-P</option> option included on its command line.
Then, <command>REINDEX DATABASE</>, Then, <command>REINDEX DATABASE</>, <command>REINDEX SYSTEM</>,
<command>REINDEX TABLE</>, or <command>REINDEX INDEX</> can be <command>REINDEX TABLE</>, or <command>REINDEX INDEX</> can be
issued, depending on how much you want to reconstruct. If in issued, depending on how much you want to reconstruct. If in
doubt, use <command>REINDEX DATABASE</> to select doubt, use <command>REINDEX SYSTEM</> to select
reconstruction of all system indexes in the database. Then quit reconstruction of all system indexes in the database. Then quit
the standalone server session and restart the regular server. the standalone server session and restart the regular server.
See the <xref linkend="app-postgres"> reference page for more See the <xref linkend="app-postgres"> reference page for more
...@@ -199,6 +211,21 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac ...@@ -199,6 +211,21 @@ REINDEX { DATABASE | TABLE | INDEX } <replaceable class="PARAMETER">name</replac
<command>REINDEX</> does not. <command>REINDEX</> does not.
</para> </para>
<para>
Reindexing a single index or table requires being the owner of that
index or table. Reindexing a database requires being the owner of
the database (note that the owner can therefore rebuild indexes of
tables owned by other users). Of course, superusers can always
reindex anything.
</para>
<para>
Prior to <productname>PostgreSQL</productname> 8.1, <command>REINDEX
DATABASE</> processed only system indexes, not all indexes as one would
expect from the name. This has been changed to reduce the surprise
factor. The old behavior is available as <command>REINDEX SYSTEM</>.
</para>
<para> <para>
Prior to <productname>PostgreSQL</productname> 7.4, <command>REINDEX Prior to <productname>PostgreSQL</productname> 7.4, <command>REINDEX
TABLE</> did not automatically process TOAST tables, and so those had TABLE</> did not automatically process TOAST tables, and so those had
...@@ -227,8 +254,8 @@ REINDEX INDEX my_index; ...@@ -227,8 +254,8 @@ REINDEX INDEX my_index;
</para> </para>
<para> <para>
Rebuild all system indexes in a particular database, without trusting them Rebuild all indexes in a particular database, without trusting the
to be valid already: system indexes to be valid already:
<programlisting> <programlisting>
$ <userinput>export PGOPTIONS="-P"</userinput> $ <userinput>export PGOPTIONS="-P"</userinput>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -898,10 +898,10 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior)
/* /*
* ReindexIndex * ReindexIndex
* Recreate an index. * Recreate a specific index.
*/ */
void void
ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ ) ReindexIndex(RangeVar *indexRelation)
{ {
Oid indOid; Oid indOid;
HeapTuple tuple; HeapTuple tuple;
...@@ -931,10 +931,10 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ ) ...@@ -931,10 +931,10 @@ ReindexIndex(RangeVar *indexRelation, bool force /* currently unused */ )
/* /*
* ReindexTable * ReindexTable
* Recreate indexes of a table. * Recreate all indexes of a table (and of its toast table, if any)
*/ */
void void
ReindexTable(RangeVar *relation, bool force /* currently unused */ ) ReindexTable(RangeVar *relation)
{ {
Oid heapOid; Oid heapOid;
HeapTuple tuple; HeapTuple tuple;
...@@ -981,8 +981,7 @@ ReindexTable(RangeVar *relation, bool force /* currently unused */ ) ...@@ -981,8 +981,7 @@ ReindexTable(RangeVar *relation, bool force /* currently unused */ )
* separate transaction, so we can release the lock on it right away. * separate transaction, so we can release the lock on it right away.
*/ */
void void
ReindexDatabase(const char *dbname, bool force /* currently unused */ , ReindexDatabase(const char *databaseName, bool do_system, bool do_user)
bool all)
{ {
Relation relationRelation; Relation relationRelation;
HeapScanDesc scan; HeapScanDesc scan;
...@@ -992,23 +991,23 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ , ...@@ -992,23 +991,23 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
List *relids = NIL; List *relids = NIL;
ListCell *l; ListCell *l;
AssertArg(dbname); AssertArg(databaseName);
if (strcmp(dbname, get_database_name(MyDatabaseId)) != 0) if (strcmp(databaseName, get_database_name(MyDatabaseId)) != 0)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED), (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("can only reindex the currently open database"))); errmsg("can only reindex the currently open database")));
if (!pg_database_ownercheck(MyDatabaseId, GetUserId())) if (!pg_database_ownercheck(MyDatabaseId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE, aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
dbname); databaseName);
/* /*
* We cannot run inside a user transaction block; if we were inside a * We cannot run inside a user transaction block; if we were inside a
* transaction, then our commit- and start-transaction-command calls * transaction, then our commit- and start-transaction-command calls
* would not have the intended effect! * 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 * Create a memory context that will survive forced transaction
...@@ -1028,9 +1027,12 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ , ...@@ -1028,9 +1027,12 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
* before we process any other tables. This is critical because * before we process any other tables. This is critical because
* reindexing itself will try to update pg_class. * reindexing itself will try to update pg_class.
*/ */
old = MemoryContextSwitchTo(private_context); if (do_system)
relids = lappend_oid(relids, RelationRelationId); {
MemoryContextSwitchTo(old); 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. * 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 */ , ...@@ -1047,9 +1049,15 @@ ReindexDatabase(const char *dbname, bool force /* currently unused */ ,
if (classtuple->relkind != RELKIND_RELATION) if (classtuple->relkind != RELKIND_RELATION)
continue; 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; continue;
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -2467,8 +2467,8 @@ _copyReindexStmt(ReindexStmt *from)
COPY_SCALAR_FIELD(kind); COPY_SCALAR_FIELD(kind);
COPY_NODE_FIELD(relation); COPY_NODE_FIELD(relation);
COPY_STRING_FIELD(name); COPY_STRING_FIELD(name);
COPY_SCALAR_FIELD(force); COPY_SCALAR_FIELD(do_system);
COPY_SCALAR_FIELD(all); COPY_SCALAR_FIELD(do_user);
return newnode; return newnode;
} }
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) ...@@ -1372,8 +1372,8 @@ _equalReindexStmt(ReindexStmt *a, ReindexStmt *b)
COMPARE_SCALAR_FIELD(kind); COMPARE_SCALAR_FIELD(kind);
COMPARE_NODE_FIELD(relation); COMPARE_NODE_FIELD(relation);
COMPARE_STRING_FIELD(name); COMPARE_STRING_FIELD(name);
COMPARE_SCALAR_FIELD(force); COMPARE_SCALAR_FIELD(do_system);
COMPARE_SCALAR_FIELD(all); COMPARE_SCALAR_FIELD(do_user);
return true; return true;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -400,7 +400,7 @@ static void doNegateFloat(Value *v); ...@@ -400,7 +400,7 @@ static void doNegateFloat(Value *v);
SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE SERIALIZABLE SESSION SESSION_USER SET SETOF SHARE
SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT SHOW SIMILAR SIMPLE SMALLINT SOME STABLE START STATEMENT
STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYMMETRIC STATISTICS STDIN STDOUT STORAGE STRICT_P SUBSTRING SYMMETRIC
SYSID SYSID SYSTEM_P
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP TABLE TABLESPACE TEMP TEMPLATE TEMPORARY THEN TIME TIMESTAMP
TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
...@@ -3641,8 +3641,9 @@ DropCastStmt: DROP CAST '(' Typename AS Typename ')' opt_drop_behavior ...@@ -3641,8 +3641,9 @@ DropCastStmt: DROP CAST '(' Typename AS Typename ')' opt_drop_behavior
* *
* QUERY: * QUERY:
* *
* REINDEX type <typename> [FORCE] [ALL] * REINDEX type <name> [FORCE]
* *
* FORCE no longer does anything, but we accept it for backwards compatibility
*****************************************************************************/ *****************************************************************************/
ReindexStmt: ReindexStmt:
...@@ -3652,7 +3653,16 @@ ReindexStmt: ...@@ -3652,7 +3653,16 @@ ReindexStmt:
n->kind = $2; n->kind = $2;
n->relation = $3; n->relation = $3;
n->name = NULL; 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; $$ = (Node *)n;
} }
| REINDEX DATABASE name opt_force | REINDEX DATABASE name opt_force
...@@ -3661,7 +3671,8 @@ ReindexStmt: ...@@ -3661,7 +3671,8 @@ ReindexStmt:
n->kind = OBJECT_DATABASE; n->kind = OBJECT_DATABASE;
n->name = $3; n->name = $3;
n->relation = NULL; n->relation = NULL;
n->force = $4; n->do_system = true;
n->do_user = true;
$$ = (Node *)n; $$ = (Node *)n;
} }
; ;
...@@ -7915,6 +7926,7 @@ unreserved_keyword: ...@@ -7915,6 +7926,7 @@ unreserved_keyword:
| STDOUT | STDOUT
| STORAGE | STORAGE
| SYSID | SYSID
| SYSTEM_P
| STRICT_P | STRICT_P
| TABLESPACE | TABLESPACE
| TEMP | TEMP
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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[] = { ...@@ -300,6 +300,7 @@ static const ScanKeyword ScanKeywords[] = {
{"substring", SUBSTRING}, {"substring", SUBSTRING},
{"symmetric", SYMMETRIC}, {"symmetric", SYMMETRIC},
{"sysid", SYSID}, {"sysid", SYSID},
{"system", SYSTEM_P},
{"table", TABLE}, {"table", TABLE},
{"tablespace", TABLESPACE}, {"tablespace", TABLESPACE},
{"temp", TEMP}, {"temp", TEMP},
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * 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, ...@@ -1011,13 +1011,14 @@ ProcessUtility(Node *parsetree,
switch (stmt->kind) switch (stmt->kind)
{ {
case OBJECT_INDEX: case OBJECT_INDEX:
ReindexIndex(stmt->relation, stmt->force); ReindexIndex(stmt->relation);
break; break;
case OBJECT_TABLE: case OBJECT_TABLE:
ReindexTable(stmt->relation, stmt->force); ReindexTable(stmt->relation);
break; break;
case OBJECT_DATABASE: case OBJECT_DATABASE:
ReindexDatabase(stmt->name, stmt->force, false); ReindexDatabase(stmt->name,
stmt->do_system, stmt->do_user);
break; break;
default: default:
elog(ERROR, "unrecognized object type: %d", elog(ERROR, "unrecognized object type: %d",
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.103 2005/06/17 22:32:47 tgl Exp $ * $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.104 2005/06/22 21:14:30 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "common.h" #include "common.h"
...@@ -1246,9 +1246,9 @@ command_no_begin(const char *query) ...@@ -1246,9 +1246,9 @@ command_no_begin(const char *query)
return true; return true;
/* /*
* Note: these tests will match REINDEX TABLESPACE, which isn't really * Note: these tests will match CREATE SYSTEM, DROP SYSTEM, and
* a valid command so we don't care much. The other five possible * REINDEX TABLESPACE, which aren't really valid commands so we don't
* matches are correct. * care much. The other six possible matches are correct.
*/ */
if ((wordlen == 6 && pg_strncasecmp(query, "create", 6) == 0) || if ((wordlen == 6 && pg_strncasecmp(query, "create", 6) == 0) ||
(wordlen == 4 && pg_strncasecmp(query, "drop", 4) == 0) || (wordlen == 4 && pg_strncasecmp(query, "drop", 4) == 0) ||
...@@ -1264,6 +1264,8 @@ command_no_begin(const char *query) ...@@ -1264,6 +1264,8 @@ command_no_begin(const char *query)
if (wordlen == 8 && pg_strncasecmp(query, "database", 8) == 0) if (wordlen == 8 && pg_strncasecmp(query, "database", 8) == 0)
return true; return true;
if (wordlen == 6 && pg_strncasecmp(query, "system", 6) == 0)
return true;
if (wordlen == 10 && pg_strncasecmp(query, "tablespace", 10) == 0) if (wordlen == 10 && pg_strncasecmp(query, "tablespace", 10) == 0)
return true; return true;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2005, PostgreSQL Global Development Group * Copyright (c) 2000-2005, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.132 2005/06/21 00:48:33 neilc Exp $ * $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.133 2005/06/22 21:14:30 tgl Exp $
*/ */
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
...@@ -1456,7 +1456,7 @@ psql_completion(char *text, int start, int end) ...@@ -1456,7 +1456,7 @@ psql_completion(char *text, int start, int end)
else if (pg_strcasecmp(prev_wd, "REINDEX") == 0) else if (pg_strcasecmp(prev_wd, "REINDEX") == 0)
{ {
static const char *const list_REINDEX[] = static const char *const list_REINDEX[] =
{"TABLE", "DATABASE", "INDEX", NULL}; {"TABLE", "INDEX", "SYSTEM", "DATABASE", NULL};
COMPLETE_WITH_LIST(list_REINDEX); COMPLETE_WITH_LIST(list_REINDEX);
} }
...@@ -1464,10 +1464,11 @@ psql_completion(char *text, int start, int end) ...@@ -1464,10 +1464,11 @@ psql_completion(char *text, int start, int end)
{ {
if (pg_strcasecmp(prev_wd, "TABLE") == 0) if (pg_strcasecmp(prev_wd, "TABLE") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, NULL);
else if (pg_strcasecmp(prev_wd, "DATABASE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_databases);
else if (pg_strcasecmp(prev_wd, "INDEX") == 0) else if (pg_strcasecmp(prev_wd, "INDEX") == 0)
COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL); COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_indexes, NULL);
else if (pg_strcasecmp(prev_wd, "SYSTEM") == 0 ||
pg_strcasecmp(prev_wd, "DATABASE") == 0)
COMPLETE_WITH_QUERY(Query_for_list_of_databases);
} }
/* SELECT */ /* SELECT */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.64 2005/04/14 01:38:21 tgl Exp $ * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.65 2005/06/22 21:14:31 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -34,9 +34,10 @@ extern void DefineIndex(RangeVar *heapRelation, ...@@ -34,9 +34,10 @@ extern void DefineIndex(RangeVar *heapRelation,
bool skip_build, bool skip_build,
bool quiet); bool quiet);
extern void RemoveIndex(RangeVar *relation, DropBehavior behavior); extern void RemoveIndex(RangeVar *relation, DropBehavior behavior);
extern void ReindexIndex(RangeVar *indexRelation, bool force); extern void ReindexIndex(RangeVar *indexRelation);
extern void ReindexTable(RangeVar *relation, bool force); extern void ReindexTable(RangeVar *relation);
extern void ReindexDatabase(const char *databaseName, bool force, bool all); extern void ReindexDatabase(const char *databaseName,
bool do_system, bool do_user);
extern char *makeObjectName(const char *name1, const char *name2, extern char *makeObjectName(const char *name1, const char *name2,
const char *label); const char *label);
extern char *ChooseRelationName(const char *name1, const char *name2, extern char *ChooseRelationName(const char *name1, const char *name2,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.282 2005/06/17 22:32:49 tgl Exp $ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.283 2005/06/22 21:14:31 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1758,8 +1758,8 @@ typedef struct ReindexStmt ...@@ -1758,8 +1758,8 @@ typedef struct ReindexStmt
* OBJECT_DATABASE */ * OBJECT_DATABASE */
RangeVar *relation; /* Table or index to reindex */ RangeVar *relation; /* Table or index to reindex */
const char *name; /* name of database to reindex */ const char *name; /* name of database to reindex */
bool force; bool do_system; /* include system tables in database case */
bool all; bool do_user; /* include user tables in database case */
} ReindexStmt; } ReindexStmt;
/* ---------------------- /* ----------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment