mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
Implement reindex command
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.141 2000/01/26 05:57:07 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.142 2000/02/18 09:29:27 inoue Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@@ -963,7 +963,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
optind = 1; /* reset after postmaster's usage */
|
||||
|
||||
while ((flag = getopt(argc, argv,
|
||||
"A:B:CD:d:EeFf:iK:LNOo:p:QS:sT:t:v:W:x:"))
|
||||
"A:B:CD:d:EeFf:iK:LNOPo:p:QS:sT:t:v:W:x:"))
|
||||
!= EOF)
|
||||
switch (flag)
|
||||
{
|
||||
@@ -1116,6 +1116,15 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
allowSystemTableMods = true;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
/* --------------------
|
||||
* ignore system indexes
|
||||
* --------------------
|
||||
*/
|
||||
if (secure) /* XXX safe to allow from client??? */
|
||||
IgnoreSystemIndexes(true);
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
/* ----------------
|
||||
* o - send output (stdout and stderr) to the given file
|
||||
@@ -1516,7 +1525,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.141 $ $Date: 2000/01/26 05:57:07 $\n");
|
||||
puts("$Revision: 1.142 $ $Date: 2000/02/18 09:29:27 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.82 2000/01/29 16:58:38 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.83 2000/02/18 09:29:31 inoue Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -846,6 +846,61 @@ ProcessUtility(Node *parsetree,
|
||||
DropGroup((DropGroupStmt *) parsetree);
|
||||
break;
|
||||
|
||||
case T_ReindexStmt:
|
||||
{
|
||||
ReindexStmt *stmt = (ReindexStmt *) parsetree;
|
||||
|
||||
PS_SET_STATUS(commandTag = "REINDEX");
|
||||
CHECK_IF_ABORTED();
|
||||
|
||||
switch (stmt->reindexType)
|
||||
{
|
||||
case INDEX:
|
||||
relname = stmt->name;
|
||||
if (IsSystemRelationName(relname))
|
||||
{
|
||||
if (!allowSystemTableMods && IsSystemRelationName(relname))
|
||||
elog(ERROR, "class \"%s\" is a system catalog index",
|
||||
relname);
|
||||
if (!IsIgnoringSystemIndexes())
|
||||
elog(ERROR, "class \"%s\" is a system catalog index",
|
||||
relname);
|
||||
}
|
||||
#ifndef NO_SECURITY
|
||||
if (!pg_ownercheck(userName, relname, RELNAME))
|
||||
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
|
||||
#endif
|
||||
ReindexIndex(relname, stmt->force);
|
||||
break;
|
||||
case TABLE:
|
||||
relname = stmt->name;
|
||||
if (IsSystemRelationName(relname))
|
||||
{
|
||||
if (!allowSystemTableMods && IsSystemRelationName(relname))
|
||||
elog(ERROR, "class \"%s\" is a system catalog index",
|
||||
relname);
|
||||
if (!IsIgnoringSystemIndexes())
|
||||
elog(ERROR, "class \"%s\" is a system catalog index",
|
||||
relname);
|
||||
}
|
||||
#ifndef NO_SECURITY
|
||||
if (!pg_ownercheck(userName, relname, RELNAME))
|
||||
elog(ERROR, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]);
|
||||
#endif
|
||||
ReindexTable(relname, stmt->force);
|
||||
break;
|
||||
case DATABASE:
|
||||
relname = stmt->name;
|
||||
if (!allowSystemTableMods)
|
||||
elog(ERROR, "-O option is needed");
|
||||
if (!IsIgnoringSystemIndexes())
|
||||
elog(ERROR, "-P option is needed");
|
||||
ReindexDatabase(relname, stmt->force, false);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
/*
|
||||
* ******************************** default ********************************
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user