Commit e3a97b37 authored by Hiroshi Inoue's avatar Hiroshi Inoue

Implement reindex command

parent e3befe4a
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.40 2000/01/26 05:55:57 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.41 2000/02/18 09:29:16 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -477,8 +477,9 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
{
HeapTuple tuple;
HeapScanDesc scan = NULL;
bool cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
if (!IsBootstrapProcessingMode())
if (cachesearch)
{
tuple = SearchSysCacheTuple(OPEROID,
ObjectIdGetDatum(operatorObjectId),
......@@ -501,7 +502,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
if (!HeapTupleIsValid(tuple))
{
if (IsBootstrapProcessingMode())
if (!cachesearch)
heap_endscan(scan);
elog(ERROR, "OperatorObjectIdFillScanKeyEntry: unknown operator %u",
operatorObjectId);
......@@ -512,7 +513,7 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation,
fmgr_info(entry->sk_procedure, &entry->sk_func);
entry->sk_nargs = entry->sk_func.fn_nargs;
if (IsBootstrapProcessingMode())
if (!cachesearch)
heap_endscan(scan);
if (!RegProcedureIsValid(entry->sk_procedure))
......@@ -546,8 +547,9 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
AttrNumber attributeNumber;
int attributeIndex;
Oid operatorClassObjectId[INDEX_MAX_KEYS];
bool cachesearch = (!IsBootstrapProcessingMode()) && IsCacheInitialized();
if (!IsBootstrapProcessingMode())
if (cachesearch)
{
tuple = SearchSysCacheTuple(INDEXRELID,
ObjectIdGetDatum(indexObjectId),
......@@ -589,7 +591,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy,
operatorClassObjectId[attributeIndex] = iform->indclass[attributeIndex];
}
if (IsBootstrapProcessingMode())
if (!cachesearch)
{
heap_endscan(scan);
heap_close(relation, AccessShareLock);
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.52 2000/01/26 05:55:58 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.53 2000/02/18 09:29:54 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -310,16 +310,22 @@ btbuild(Relation heap,
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
/*
UpdateStats(hrelid, nhtups, true);
UpdateStats(irelid, nitups, false);
*/
UpdateStats(hrelid, nhtups, inplace);
UpdateStats(irelid, nitups, inplace);
if (oldPred != NULL)
{
if (nitups == nhtups)
pred = NULL;
UpdateIndexPredicate(irelid, oldPred, pred);
if (!inplace)
UpdateIndexPredicate(irelid, oldPred, pred);
}
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.60 2000/01/29 16:58:29 petere Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.61 2000/02/18 09:30:20 inoue Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
......@@ -147,6 +147,7 @@
#include "access/nbtree.h"
#include "catalog/heap.h"
#include "catalog/index.h"
#include "commands/async.h"
#include "commands/sequence.h"
#include "commands/vacuum.h"
......@@ -850,6 +851,7 @@ StartTransaction()
*/
s->state = TRANS_START;
SetReindexProcessing(false);
/* ----------------
* generate a new transaction id
* ----------------
......@@ -1046,8 +1048,8 @@ AbortTransaction()
AtAbort_Notify();
CloseSequences();
AtEOXact_portals();
if (VacuumRunning)
vc_abort();
if (CommonSpecialPortalIsOpen())
CommonSpecialPortalClose();
RecordTransactionAbort();
RelationPurgeLocalRelation(false);
DropNoNameRels();
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.79 2000/01/26 05:56:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.80 2000/02/18 09:28:39 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -292,6 +292,7 @@ BootstrapMain(int argc, char *argv[])
dbName = argv[optind];
SetProcessingMode(BootstrapProcessing);
IgnoreSystemIndexes(true);
if (!DataDir)
{
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.121 2000/02/15 03:36:34 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.122 2000/02/18 09:28:40 inoue Exp $
*
*
* INTERFACE ROUTINES
......@@ -713,7 +713,7 @@ AddNewRelationTuple(Relation pg_class_desc,
if (temp_relname)
create_temp_relation(temp_relname, tup);
if (!IsBootstrapProcessingMode())
if (!IsIgnoringSystemIndexes())
{
/*
* First, open the catalog indices and insert index tuples for the
......@@ -1263,8 +1263,7 @@ heap_truncate(char *relname)
rel->rd_nblocks = 0;
/* If this relation has indexes, truncate the indexes too */
if (rel->rd_rel->relhasindex)
RelationTruncateIndexes(rel);
RelationTruncateIndexes(rel);
/*
* Close the relation, but keep exclusive lock on it until commit.
......@@ -1491,8 +1490,8 @@ heap_drop_with_catalog(const char *relname)
* remove indexes if necessary
* ----------------
*/
if (rel->rd_rel->relhasindex)
RelationRemoveIndexes(rel);
/* should ignore relhasindex */
RelationRemoveIndexes(rel);
/* ----------------
* remove rules if necessary
......
This diff is collapsed.
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.58 2000/01/26 05:56:10 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.59 2000/02/18 09:28:41 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -92,6 +92,8 @@ CatalogOpenIndices(int nIndices, char **names, Relation *idescs)
{
int i;
if (IsIgnoringSystemIndexes())
return;
for (i = 0; i < nIndices; i++)
idescs[i] = index_openr(names[i]);
}
......@@ -104,6 +106,8 @@ CatalogCloseIndices(int nIndices, Relation *idescs)
{
int i;
if (IsIgnoringSystemIndexes())
return;
for (i = 0; i < nIndices; i++)
index_close(idescs[i]);
}
......@@ -131,6 +135,8 @@ CatalogIndexInsert(Relation *idescs,
*finfoP;
int i;
if (IsIgnoringSystemIndexes())
return;
heapDescriptor = RelationGetDescr(heapRelation);
for (i = 0; i < nIndices; i++)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.20 2000/01/26 05:56:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.21 2000/02/18 09:29:37 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -17,12 +17,15 @@
#include "access/genam.h"
#include "access/heapam.h"
#include "catalog/catname.h"
#include "catalog/heap.h"
#include "catalog/index.h"
#include "catalog/pg_index.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "catalog/pg_database.h"
#include "catalog/pg_shadow.h"
#include "commands/defrem.h"
#include "optimizer/clauses.h"
#include "optimizer/planmain.h"
......@@ -30,6 +33,9 @@
#include "parser/parsetree.h"
#include "utils/builtins.h"
#include "utils/syscache.h"
#include "miscadmin.h" /* ReindexDatabase() */
#include "utils/portal.h" /* ReindexDatabase() */
#include "catalog/catalog.h" /* ReindexDatabase() */
#define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args!=NULL)
......@@ -149,6 +155,8 @@ DefineIndex(char *heapRelationName,
CheckPredicate(cnfPred, rangetable, relationId);
}
if (!IsBootstrapProcessingMode() && !IndexesAreActive(relationId, false))
elog(ERROR, "existent indexes are inactive. REINDEX first");
if (IsFuncIndex(attributeList))
{
IndexElem *funcIndex = lfirst(attributeList);
......@@ -195,6 +203,7 @@ DefineIndex(char *heapRelationName,
classObjectId, parameterCount, parameterA, (Node *) cnfPred,
lossy, unique, primary);
}
setRelhasindexInplace(relationId, true, false);
}
......@@ -570,3 +579,163 @@ RemoveIndex(char *name)
index_drop(tuple->t_data->t_oid);
}
/*
* Reindex
* Recreate an index.
*
* Exceptions:
* "ERROR" if index nonexistent.
* ...
*/
void
ReindexIndex(const char *name, bool force /* currently unused */)
{
HeapTuple tuple;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(name),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "index \"%s\" nonexistent", name);
if (((Form_pg_class) GETSTRUCT(tuple))->relkind != RELKIND_INDEX)
{
elog(ERROR, "relation \"%s\" is of type \"%c\"",
name,
((Form_pg_class) GETSTRUCT(tuple))->relkind);
}
reindex_index(tuple->t_data->t_oid, force);
}
/*
* ReindexTable
* Recreate indexes of a table.
*
* Exceptions:
* "ERROR" if table nonexistent.
* ...
*/
void
ReindexTable(const char *name, bool force)
{
HeapTuple tuple;
tuple = SearchSysCacheTuple(RELNAME,
PointerGetDatum(name),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "table \"%s\" nonexistent", name);
if (((Form_pg_class) GETSTRUCT(tuple))->relkind != RELKIND_RELATION)
{
elog(ERROR, "relation \"%s\" is of type \"%c\"",
name,
((Form_pg_class) GETSTRUCT(tuple))->relkind);
}
reindex_relation(tuple->t_data->t_oid, force);
}
/*
* ReindexDatabase
* Recreate indexes of a database.
*
* Exceptions:
* "ERROR" if table nonexistent.
* ...
*/
extern Oid MyDatabaseId;
void
ReindexDatabase(const char *dbname, bool force, bool all)
{
Relation relation, relationRelation;
HeapTuple usertuple, dbtuple, tuple;
HeapScanDesc scan;
int4 user_id, db_owner;
bool superuser;
Oid db_id;
char *username;
ScanKeyData scankey;
PortalVariableMemory pmem;
MemoryContext old;
int relcnt, relalc, i, oncealc = 200;
Oid *relids = (Oid *) NULL;
AssertArg(dbname);
username = GetPgUserName();
usertuple = SearchSysCacheTuple(SHADOWNAME, PointerGetDatum(username),
0, 0, 0);
if (!HeapTupleIsValid(usertuple))
elog(ERROR, "Current user '%s' is invalid.", username);
user_id = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesysid;
superuser = ((Form_pg_shadow) GETSTRUCT(usertuple))->usesuper;
relation = heap_openr(DatabaseRelationName, AccessShareLock);
ScanKeyEntryInitialize(&scankey, 0, Anum_pg_database_datname,
F_NAMEEQ, NameGetDatum(dbname));
scan = heap_beginscan(relation, 0, SnapshotNow, 1, &scankey);
dbtuple = heap_getnext(scan, 0);
if (!HeapTupleIsValid(dbtuple))
elog(ERROR, "Database '%s' doesn't exist", dbname);
db_id = dbtuple->t_data->t_oid;
db_owner = ((Form_pg_database) GETSTRUCT(dbtuple))->datdba;
heap_endscan(scan);
if (user_id != db_owner && !superuser)
elog(ERROR, "REINDEX DATABASE: Permission denied.");
if (db_id != MyDatabaseId)
elog(ERROR, "REINDEX DATABASE: Can be executed only on the currently open database.");
heap_close(relation, NoLock);
/** reindex_database(db_id, force, !all); **/
CommonSpecialPortalOpen();
pmem = CommonSpecialPortalGetMemory();
relationRelation = heap_openr(RelationRelationName, AccessShareLock);
scan = heap_beginscan(relationRelation, false, SnapshotNow, 0, NULL);
relcnt = relalc = 0;
while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
{
if (!all)
{
if (!IsSystemRelationName(NameStr(((Form_pg_class) GETSTRUCT(tuple))->relname)))
continue;
if (((Form_pg_class) GETSTRUCT(tuple))->relhasrules)
continue;
}
if (((Form_pg_class) GETSTRUCT(tuple))->relkind == RELKIND_RELATION)
{
old = MemoryContextSwitchTo((MemoryContext) pmem);
if (relcnt == 0)
{
relalc = oncealc;
relids = palloc(sizeof(Oid) * relalc);
}
else if (relcnt >= relalc)
{
relalc *= 2;
relids = repalloc(relids, sizeof(Oid) * relalc);
}
MemoryContextSwitchTo(old);
relids[relcnt] = tuple->t_data->t_oid;
relcnt++;
}
}
heap_endscan(scan);
heap_close(relationRelation, AccessShareLock);
CommitTransactionCommand();
for (i = 0; i < relcnt; i++)
{
StartTransactionCommand();
reindex_relation(relids[i], force);
CommitTransactionCommand();
}
CommonSpecialPortalClose();
StartTransactionCommand();
}
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.60 2000/02/13 13:21:10 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.61 2000/02/18 09:29:37 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -433,15 +433,18 @@ RelationBuildTriggers(Relation relation)
Trigger *build;
Relation tgrel;
Form_pg_trigger pg_trigger;
Relation irel;
Relation irel = (Relation) NULL;
ScanKeyData skey;
HeapTupleData tuple;
IndexScanDesc sd;
IndexScanDesc sd = (IndexScanDesc) NULL;
HeapScanDesc tgscan = (HeapScanDesc) NULL;
HeapTuple htup;
RetrieveIndexResult indexRes;
Buffer buffer;
struct varlena *val;
bool isnull;
int found;
bool hasindex;
MemSet(trigdesc, 0, sizeof(TriggerDesc));
......@@ -452,25 +455,41 @@ RelationBuildTriggers(Relation relation)
ObjectIdGetDatum(RelationGetRelid(relation)));
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
irel = index_openr(TriggerRelidIndex);
sd = index_beginscan(irel, false, 1, &skey);
hasindex = (tgrel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
if (hasindex)
{
irel = index_openr(TriggerRelidIndex);
sd = index_beginscan(irel, false, 1, &skey);
}
else
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &skey);
for (found = 0;;)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
if (hasindex)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
pfree(indexRes);
if (!tuple.t_data)
continue;
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
pfree(indexRes);
if (!tuple.t_data)
continue;
htup = &tuple;
}
else
{
htup = heap_getnext(tgscan, 0);
if (!HeapTupleIsValid(htup))
break;
}
if (found == ntrigs)
elog(ERROR, "RelationBuildTriggers: unexpected record found for rel %s",
RelationGetRelationName(relation));
pg_trigger = (Form_pg_trigger) GETSTRUCT(&tuple);
pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
if (triggers == NULL)
triggers = (Trigger *) palloc(sizeof(Trigger));
......@@ -478,7 +497,7 @@ RelationBuildTriggers(Relation relation)
triggers = (Trigger *) repalloc(triggers, (found + 1) * sizeof(Trigger));
build = &(triggers[found]);
build->tgoid = tuple.t_data->t_oid;
build->tgoid = htup->t_data->t_oid;
build->tgname = nameout(&pg_trigger->tgname);
build->tgfoid = pg_trigger->tgfoid;
build->tgfunc.fn_addr = NULL;
......@@ -489,7 +508,7 @@ RelationBuildTriggers(Relation relation)
build->tginitdeferred = pg_trigger->tginitdeferred;
build->tgnargs = pg_trigger->tgnargs;
memcpy(build->tgattr, &(pg_trigger->tgattr), FUNC_MAX_ARGS * sizeof(int16));
val = (struct varlena *) fastgetattr(&tuple,
val = (struct varlena *) fastgetattr(htup,
Anum_pg_trigger_tgargs,
tgrel->rd_att, &isnull);
if (isnull)
......@@ -500,7 +519,7 @@ RelationBuildTriggers(Relation relation)
char *p;
int i;
val = (struct varlena *) fastgetattr(&tuple,
val = (struct varlena *) fastgetattr(htup,
Anum_pg_trigger_tgargs,
tgrel->rd_att, &isnull);
if (isnull)
......@@ -518,7 +537,8 @@ RelationBuildTriggers(Relation relation)
build->tgargs = NULL;
found++;
ReleaseBuffer(buffer);
if (hasindex)
ReleaseBuffer(buffer);
}
if (found < ntrigs)
......@@ -526,8 +546,13 @@ RelationBuildTriggers(Relation relation)
ntrigs - found,
RelationGetRelationName(relation));
index_endscan(sd);
index_close(irel);
if (hasindex)
{
index_endscan(sd);
index_close(irel);
}
else
heap_endscan(tgscan);
heap_close(tgrel, AccessShareLock);
/* Build trigdesc */
......@@ -1460,7 +1485,7 @@ void
DeferredTriggerSetState(ConstraintsSetStmt *stmt)
{
Relation tgrel;
Relation irel;
Relation irel = (Relation) NULL;
List *l;
List *ls;
List *lnext;
......@@ -1468,6 +1493,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
MemoryContext oldcxt;
bool found;
DeferredTriggerStatus state;
bool hasindex;
/* ----------
* Handle SET CONSTRAINTS ALL ...
......@@ -1548,13 +1574,17 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
* ----------
*/
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
irel = index_openr(TriggerConstrNameIndex);
hasindex = (tgrel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
if (hasindex)
irel = index_openr(TriggerConstrNameIndex);
foreach (l, stmt->constraints)
{
ScanKeyData skey;
HeapTupleData tuple;
IndexScanDesc sd;
IndexScanDesc sd = (IndexScanDesc) NULL;
HeapScanDesc tgscan = (HeapScanDesc) NULL;
HeapTuple htup;
RetrieveIndexResult indexRes;
Buffer buffer;
Form_pg_trigger pg_trigger;
......@@ -1577,7 +1607,10 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
(RegProcedure) F_NAMEEQ,
PointerGetDatum((char *)lfirst(l)));
sd = index_beginscan(irel, false, 1, &skey);
if (hasindex)
sd = index_beginscan(irel, false, 1, &skey);
else
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &skey);
/* ----------
* ... and search for the constraint trigger row
......@@ -1586,33 +1619,43 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
found = false;
for (;;)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
if (hasindex)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
pfree(indexRes);
if (!tuple.t_data)
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
pfree(indexRes);
if (!tuple.t_data)
{
continue;
}
htup = &tuple;
}
else
{
ReleaseBuffer(buffer);
continue;
htup = heap_getnext(tgscan, 0);
if (!HeapTupleIsValid(htup))
break;
}
/* ----------
* If we found some, check that they fit the deferrability
* ----------
*/
pg_trigger = (Form_pg_trigger) GETSTRUCT(&tuple);
pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
if (stmt->deferred & !pg_trigger->tgdeferrable)
elog(ERROR, "Constraint '%s' is not deferrable",
(char *)lfirst(l));
constr_oid = tuple.t_data->t_oid;
constr_oid = htup->t_data->t_oid;
loid = lappend(loid, (Node *)constr_oid);
found = true;
ReleaseBuffer(buffer);
if (hasindex)
ReleaseBuffer(buffer);
}
/* ----------
......@@ -1622,9 +1665,13 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
if (!found)
elog(ERROR, "Constraint '%s' does not exist", (char *)lfirst(l));
index_endscan(sd);
if (hasindex)
index_endscan(sd);
else
heap_endscan(tgscan);
}
index_close(irel);
if (hasindex)
index_close(irel);
heap_close(tgrel, AccessShareLock);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.138 2000/01/26 05:56:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.139 2000/02/18 09:29:37 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -51,7 +51,7 @@
#endif
bool VacuumRunning = false;
bool CommonSpecialPortalInUse = false;
static Portal vc_portal;
......@@ -99,6 +99,53 @@ static bool vc_enough_space(VPageDescr vpd, Size len);
static char *vc_show_rusage(struct rusage * ru0);
/*
* This routines handle a special cross-transaction portal.
* However it is automatically closed in case of abort.
*/
void CommonSpecialPortalOpen(void)
{
char *pname;
/*
* Create a portal for safe memory across transactions. We need to
* palloc the name space for it because our hash function expects the
* name to be on a longword boundary. CreatePortal copies the name to
* safe storage for us.
*/
pname = pstrdup(VACPNAME);
vc_portal = CreatePortal(pname);
pfree(pname);
/*
* Set flag to indicate that vc_portal must be removed after an error.
* This global variable is checked in the transaction manager on xact
* abort, and the routine CommonSpecialPortalClose() is called if
* necessary.
*/
CommonSpecialPortalInUse = true;
}
void CommonSpecialPortalClose(void)
{
/* Clear flag first, to avoid recursion if PortalDrop elog's */
CommonSpecialPortalInUse = false;
/*
* Release our portal for cross-transaction memory.
*/
PortalDrop(&vc_portal);
}
PortalVariableMemory CommonSpecialPortalGetMemory(void)
{
return PortalGetVariableMemory(vc_portal);
}
bool CommonSpecialPortalIsOpen(void)
{
return CommonSpecialPortalInUse;
}
void
vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
{
......@@ -136,7 +183,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
strcpy(NameStr(VacRel), vacrel);
/* must also copy the column list, if any, to safe storage */
pmem = PortalGetVariableMemory(vc_portal);
pmem = CommonSpecialPortalGetMemory();
old = MemoryContextSwitchTo((MemoryContext) pmem);
foreach(le, va_spec)
{
......@@ -179,24 +226,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List *va_spec)
static void
vc_init()
{
char *pname;
/*
* Create a portal for safe memory across transactions. We need to
* palloc the name space for it because our hash function expects the
* name to be on a longword boundary. CreatePortal copies the name to
* safe storage for us.
*/
pname = pstrdup(VACPNAME);
vc_portal = CreatePortal(pname);
pfree(pname);
/*
* Set flag to indicate that vc_portal must be removed after an error.
* This global variable is checked in the transaction manager on xact
* abort, and the routine vc_abort() is called if necessary.
*/
VacuumRunning = true;
CommonSpecialPortalOpen();
/* matches the StartTransaction in PostgresMain() */
CommitTransactionCommand();
......@@ -219,30 +249,12 @@ vc_shutdown()
*/
unlink(RELCACHE_INIT_FILENAME);
/*
* Release our portal for cross-transaction memory.
*/
PortalDrop(&vc_portal);
/* okay, we're done */
VacuumRunning = false;
CommonSpecialPortalClose();
/* matches the CommitTransaction in PostgresMain() */
StartTransactionCommand();
}
void
vc_abort()
{
/* Clear flag first, to avoid recursion if PortalDrop elog's */
VacuumRunning = false;
/*
* Release our portal for cross-transaction memory.
*/
PortalDrop(&vc_portal);
}
/*
* vc_vacuum() -- vacuum the database.
*
......@@ -302,7 +314,7 @@ vc_getrels(NameData *VacRelP)
F_CHAREQ, CharGetDatum('r'));
}
portalmem = PortalGetVariableMemory(vc_portal);
portalmem = CommonSpecialPortalGetMemory();
vrl = cur = (VRelList) NULL;
rel = heap_openr(RelationRelationName, AccessShareLock);
......@@ -379,6 +391,7 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
int32 nindices,
i;
VRelStats *vacrelstats;
bool reindex = false;
StartTransactionCommand();
......@@ -552,17 +565,31 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
GetXmaxRecent(&XmaxRecent);
/* scan it */
reindex = false;
vacuum_pages.vpl_num_pages = fraged_pages.vpl_num_pages = 0;
vc_scanheap(vacrelstats, onerel, &vacuum_pages, &fraged_pages);
if (IsIgnoringSystemIndexes() && IsSystemRelationName(RelationGetRelationName(onerel)))
reindex = true;
/* Now open indices */
nindices = 0;
Irel = (Relation *) NULL;
vc_getindices(vacrelstats->relid, &nindices, &Irel);
if (!Irel)
reindex = false;
else if (!RelationGetForm(onerel)->relhasindex)
reindex = true;
if (nindices > 0)
vacrelstats->hasindex = true;
else
vacrelstats->hasindex = false;
if (reindex)
{
for (i = 0; i < nindices; i++)
index_close(Irel[i]);
Irel = (Relation *) NULL;
activate_indexes_of_a_table(relid, false);
}
/* Clean/scan index relation(s) */
if (Irel != (Relation *) NULL)
......@@ -590,6 +617,8 @@ vc_vacone(Oid relid, bool analyze, List *va_cols)
* vacuum_pages list */
vc_vacheap(vacrelstats, onerel, &vacuum_pages);
}
if (reindex)
activate_indexes_of_a_table(relid, true);
/* ok - free vacuum_pages list of reaped pages */
if (vacuum_pages.vpl_num_pages > 0)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.53 2000/01/26 05:56:22 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.54 2000/02/18 09:29:57 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -48,8 +48,10 @@
#include "catalog/catname.h"
#include "catalog/index.h"
#include "catalog/pg_index.h"
#include "catalog/catalog.h"
#include "executor/execdebug.h"
#include "executor/executor.h"
#include "miscadmin.h"
static void ExecGetIndexKeyInfo(Form_pg_index indexTuple, int *numAttsOutP,
AttrNumber **attsOutP, FuncIndexInfoPtr fInfoP);
......@@ -770,6 +772,12 @@ ExecOpenIndices(Oid resultRelationOid,
PredInfo *predicate;
int i;
resultRelationInfo->ri_NumIndices = 0;
if (!RelationGetForm(resultRelationInfo->ri_RelationDesc)->relhasindex)
return;
if (IsIgnoringSystemIndexes() &&
IsSystemRelationName(RelationGetRelationName(resultRelationInfo->ri_RelationDesc)))
return;
/* ----------------
* open pg_index
* ----------------
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.46 2000/02/05 23:19:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.47 2000/02/18 09:29:57 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1048,6 +1048,10 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent)
&currentRelation, /* return: rel desc */
(Pointer *) &currentScanDesc); /* return: scan desc */
if (!RelationGetForm(currentRelation)->relhasindex)
{
elog(ERROR, "indexes of the relation %u was inactivated", reloid);
}
scanstate->css_currentRelation = currentRelation;
scanstate->css_currentScanDesc = currentScanDesc;
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.48 2000/02/17 03:39:40 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.49 2000/02/18 09:30:09 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -29,6 +29,8 @@
#include "optimizer/plancat.h"
#include "parser/parsetree.h"
#include "utils/syscache.h"
#include "catalog/catalog.h"
#include "miscadmin.h"
/*
......@@ -55,7 +57,10 @@ relation_info(Query *root, Index relid,
relationObjectId);
relation = (Form_pg_class) GETSTRUCT(relationTuple);
*hasindex = (relation->relhasindex) ? true : false;
if (IsIgnoringSystemIndexes() && IsSystemRelationName(NameStr(relation->relname)))
*hasindex = false;
else
*hasindex = (relation->relhasindex) ? true : false;
*pages = relation->relpages;
*tuples = relation->reltuples;
}
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.143 2000/02/16 17:24:36 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.144 2000/02/18 09:29:40 inoue Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -124,7 +124,7 @@ static Node *doNegate(Node *n);
ExtendStmt, FetchStmt, GrantStmt, CreateTrigStmt, DropTrigStmt,
CreatePLangStmt, DropPLangStmt,
IndexStmt, ListenStmt, UnlistenStmt, LockStmt, OptimizableStmt,
ProcedureStmt, RemoveAggrStmt, RemoveOperStmt,
ProcedureStmt, ReindexStmt, RemoveAggrStmt, RemoveOperStmt,
RemoveFuncStmt, RemoveStmt,
RenameStmt, RevokeStmt, RuleStmt, TransactionStmt, ViewStmt, LoadStmt,
CreatedbStmt, DropdbStmt, VacuumStmt, CursorStmt, SubSelect,
......@@ -141,7 +141,7 @@ static Node *doNegate(Node *n);
%type <ival> createdb_opt_encoding
%type <ival> opt_lock, lock_type
%type <boolean> opt_lmode
%type <boolean> opt_lmode, opt_force
%type <ival> user_createdb_clause, user_createuser_clause
%type <str> user_passwd_clause
......@@ -211,7 +211,7 @@ static Node *doNegate(Node *n);
opt_with_copy, index_opt_unique, opt_verbose, opt_analyze
%type <boolean> opt_cursor
%type <ival> copy_dirn, def_type, direction, remove_type,
%type <ival> copy_dirn, def_type, direction, reindex_type, remove_type,
opt_column, event, comment_type, comment_cl,
comment_ag, comment_fn, comment_op, comment_tg
......@@ -339,13 +339,13 @@ static Node *doNegate(Node *n);
CACHE, CLUSTER, COMMENT, COPY, CREATEDB, CREATEUSER, CYCLE,
DATABASE, DELIMITERS, DO,
EACH, ENCODING, EXCLUSIVE, EXPLAIN, EXTEND,
FORWARD, FUNCTION, HANDLER,
FORCE, FORWARD, FUNCTION, HANDLER,
INCREMENT, INDEX, INHERITS, INSTEAD, ISNULL,
LANCOMPILER, LIMIT, LISTEN, LOAD, LOCATION, LOCK_P,
MAXVALUE, MINVALUE, MODE, MOVE,
NEW, NOCREATEDB, NOCREATEUSER, NONE, NOTHING, NOTIFY, NOTNULL,
OFFSET, OIDS, OPERATOR, PASSWORD, PROCEDURAL,
RENAME, RESET, RETURNS, ROW, RULE,
REINDEX, RENAME, RESET, RETURNS, ROW, RULE,
SEQUENCE, SERIAL, SETOF, SHARE, SHOW, START, STATEMENT, STDIN, STDOUT, SYSID,
TRUNCATE, TRUSTED,
UNLISTEN, UNTIL, VACUUM, VALID, VERBOSE, VERSION
......@@ -440,6 +440,7 @@ stmt : AlterTableStmt
| UnlistenStmt
| LockStmt
| ProcedureStmt
| ReindexStmt
| RemoveAggrStmt
| RemoveOperStmt
| RemoveFuncStmt
......@@ -2445,6 +2446,35 @@ oper_argtypes: name
;
/*****************************************************************************
*
* QUERY:
*
* REINDEX type <typename> [FORCE] [ALL]
*
*****************************************************************************/
ReindexStmt: REINDEX reindex_type name opt_force
{
ReindexStmt *n = makeNode(ReindexStmt);
if (IsTransactionBlock())
elog(ERROR,"REINDEX command could only be used outside begin/end transaction blocks");
n->reindexType = $2;
n->name = $3;
n->force = $4;
$$ = (Node *)n;
}
;
reindex_type: INDEX { $$ = INDEX; }
| TABLE { $$ = TABLE; }
| DATABASE { $$ = DATABASE; }
;
opt_force: FORCE { $$ = TRUE; }
| /* EMPTY */ { $$ = FALSE; }
;
/*****************************************************************************
*
* QUERY:
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.66 2000/02/15 03:26:38 thomas Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.67 2000/02/18 09:29:40 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -107,6 +107,7 @@ static ScanKeyword ScanKeywords[] = {
{"fetch", FETCH},
{"float", FLOAT},
{"for", FOR},
{"force", FORCE},
{"foreign", FOREIGN},
{"forward", FORWARD},
{"from", FROM},
......@@ -196,6 +197,7 @@ static ScanKeyword ScanKeywords[] = {
{"public", PUBLIC},
{"read", READ},
{"references", REFERENCES},
{"reindex", REINDEX},
{"relative", RELATIVE},
{"rename", RENAME},
{"reset", RESET},
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.135 2000/01/26 05:56:48 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.136 2000/02/18 09:28:44 inoue Exp $
*
* NOTES
*
......@@ -430,6 +430,7 @@ PostmasterMain(int argc, char *argv[])
DataDir = getenv("PGDATA"); /* default value */
opterr = 0;
IgnoreSystemIndexes(false);
while ((opt = getopt(nonblank_argc, argv, "A:a:B:b:D:d:ilm:MN:no:p:Ss")) != EOF)
{
switch (opt)
......
......@@ -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 ********************************
*
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.51 2000/01/26 05:57:14 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.52 2000/02/18 09:28:48 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -45,7 +45,7 @@ regprocin(char *pro_name_or_oid)
if (pro_name_or_oid[0] == '-' && pro_name_or_oid[1] == '\0')
return InvalidOid;
if (!IsBootstrapProcessingMode())
if (!IsIgnoringSystemIndexes())
{
/*
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.60 2000/02/04 03:16:03 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.61 2000/02/18 09:28:53 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -233,7 +233,7 @@ CatalogCacheInitializeCache(struct catcache * cache,
*/
if (cache->cc_indname != NULL && cache->indexId == InvalidOid)
{
if (RelationGetForm(relation)->relhasindex)
if (!IsIgnoringSystemIndexes() && RelationGetForm(relation)->relhasindex)
{
/*
......@@ -817,14 +817,19 @@ SearchSelfReferences(struct catcache * cache)
if (!OidIsValid(indexSelfOid))
{
ScanKeyData key;
HeapScanDesc sd;
/* Find oid of pg_index_indexrelid_index */
rel = heap_openr(RelationRelationName, AccessShareLock);
ntp = ClassNameIndexScan(rel, IndexRelidIndex);
ScanKeyEntryInitialize(&key, 0, Anum_pg_class_relname,
F_NAMEEQ, PointerGetDatum(IndexRelidIndex));
sd = heap_beginscan(rel, false, SnapshotNow, 1, &key);
ntp = heap_getnext(sd, 0);
if (!HeapTupleIsValid(ntp))
elog(ERROR, "SearchSelfReferences: %s not found in %s",
IndexRelidIndex, RelationRelationName);
indexSelfOid = ntp->t_data->t_oid;
heap_freetuple(ntp);
heap_endscan(sd);
heap_close(rel, AccessShareLock);
}
/* Looking for something other than pg_index_indexrelid_index? */
......@@ -1031,7 +1036,7 @@ SearchSysCache(struct catcache * cache,
CACHE1_elog(DEBUG, "SearchSysCache: performing scan");
if ((RelationGetForm(relation))->relhasindex
&& !IsBootstrapProcessingMode())
&& !IsIgnoringSystemIndexes())
{
/* ----------
* Switch back to old memory context so memory not freed
......
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.48 2000/01/26 05:57:18 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.49 2000/02/18 09:28:56 inoue Exp $
*
* NOTES
* These routines allow the parser/planner/executor to perform
......@@ -39,6 +39,7 @@
#include "catalog/pg_type.h"
#include "utils/catcache.h"
#include "utils/temprel.h"
#include "miscadmin.h"
extern bool AMI_OVERRIDE; /* XXX style */
......@@ -395,6 +396,11 @@ static struct cachedesc cacheinfo[] = {
static struct catcache *SysCache[lengthof(cacheinfo)];
static int32 SysCacheSize = lengthof(cacheinfo);
static bool CacheInitialized = false;
extern bool IsCacheInitialized(void)
{
return CacheInitialized;
}
/*
......@@ -442,6 +448,7 @@ InitCatalogCache()
}
}
CacheInitialized = true;
}
/*
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.43 2000/01/26 05:57:26 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.44 2000/02/18 09:28:58 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -38,6 +38,33 @@ unsigned char RecodeBackTable[128];
ProcessingMode Mode = InitProcessing;
/* ----------------------------------------------------------------
* ignoring system indexes support stuff
* ----------------------------------------------------------------
*/
static bool isIgnoringSystemIndexes = false;
/*
* IsIgnoringSystemIndexes
* True if ignoring system indexes.
*/
bool
IsIgnoringSystemIndexes()
{
return isIgnoringSystemIndexes;
}
/*
* IgnoreSystemIndexes
* Set true or false whether PostgreSQL ignores system indexes.
*
*/
void
IgnoreSystemIndexes(bool mode)
{
isIgnoringSystemIndexes = mode;
}
/* ----------------------------------------------------------------
* database path / name support stuff
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: index.h,v 1.21 2000/01/26 05:57:56 momjian Exp $
* $Id: index.h,v 1.22 2000/02/18 09:29:19 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -47,7 +47,11 @@ extern void FormIndexDatum(int numberOfAttributes,
TupleDesc heapDescriptor, Datum *datum,
char *nullv, FuncIndexInfoPtr fInfo);
extern void UpdateStats(Oid relid, long reltuples, bool hasindex);
extern void UpdateStats(Oid relid, long reltuples, bool inplace);
extern bool IndexesAreActive(Oid relid, bool comfirmCommitted);
extern void setRelhasindexInplace(Oid relid, bool hasindex, bool immediate);
extern bool SetReindexProcessing(bool processing);
extern bool IsReindexProcessing(void);
extern void FillDummyExprContext(ExprContext *econtext, TupleTableSlot *slot,
TupleDesc tupdesc, Buffer buffer);
......@@ -60,4 +64,8 @@ extern void index_build(Relation heapRelation, Relation indexRelation,
extern bool IndexIsUnique(Oid indexId);
extern bool IndexIsUniqueNoCache(Oid indexId);
extern bool activate_index(Oid indexId, bool activate);
extern bool reindex_index(Oid indexId, bool force);
extern bool activate_indexes_of_a_table(Oid relid, bool activate);
extern bool reindex_relation(Oid relid, bool force);
#endif /* INDEX_H */
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: defrem.h,v 1.18 2000/01/26 05:58:00 momjian Exp $
* $Id: defrem.h,v 1.19 2000/02/18 09:29:49 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -33,6 +33,9 @@ extern void ExtendIndex(char *indexRelationName,
Expr *predicate,
List *rangetable);
extern void RemoveIndex(char *name);
extern void ReindexIndex(const char *indexRelationName, bool force);
extern void ReindexTable(const char *relationName, bool force);
extern void ReindexDatabase(const char *databaseName, bool force, bool all);
/*
* prototypes in define.c
......
......@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: miscadmin.h,v 1.50 2000/01/26 05:57:46 momjian Exp $
* $Id: miscadmin.h,v 1.51 2000/02/18 09:29:06 inoue Exp $
*
* NOTES
* some of the information in this file will be moved to
......@@ -211,6 +211,9 @@ extern ProcessingMode Mode;
#define GetProcessingMode() Mode
extern void IgnoreSystemIndexes(bool mode);
extern bool IsIgnoringSystemIndexes(void);
extern bool IsCacheInitialized(void);
/*
* "postmaster.pid" is a file containing postmaster's pid, being
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: nodes.h,v 1.64 2000/02/15 20:49:24 tgl Exp $
* $Id: nodes.h,v 1.65 2000/02/18 09:29:43 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -146,7 +146,7 @@ typedef enum NodeTag
T_DeleteStmt,
T_UpdateStmt,
T_SelectStmt,
T_AlterTableStmt,
T_AlterTableStmt,
T_AggregateStmt,
T_ChangeACLStmt,
T_ClosePortalStmt,
......@@ -191,9 +191,10 @@ typedef enum NodeTag
T_DropUserStmt,
T_LockStmt,
T_ConstraintsSetStmt,
T_CreateGroupStmt,
T_AlterGroupStmt,
T_DropGroupStmt,
T_CreateGroupStmt,
T_AlterGroupStmt,
T_DropGroupStmt,
T_ReindexStmt,
T_A_Expr = 700,
T_Attr,
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.99 2000/02/15 20:49:24 tgl Exp $
* $Id: parsenodes.h,v 1.100 2000/02/18 09:29:44 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -722,6 +722,19 @@ typedef struct ConstraintsSetStmt
bool deferred;
} ConstraintsSetStmt;
/* ----------------------
* REINDEX Statement
* ----------------------
*/
typedef struct ReindexStmt
{
NodeTag type;
int reindexType; /* INDEX|TABLE|DATABASE */
const char *name; /* name to reindex */
bool force;
bool all;
} ReindexStmt;
/*****************************************************************************
* Optimizable Statements
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: portal.h,v 1.21 2000/01/26 05:58:38 momjian Exp $
* $Id: portal.h,v 1.22 2000/02/18 09:30:16 inoue Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -80,6 +80,10 @@ extern void EndPortalAllocMode(void);
extern void PortalResetHeapMemory(Portal portal);
extern PortalVariableMemory PortalGetVariableMemory(Portal portal);
extern PortalHeapMemory PortalGetHeapMemory(Portal portal);
extern void CommonSpecialPortalOpen(void);
extern void CommonSpecialPortalClose(void);
extern PortalVariableMemory CommonSpecialPortalGetMemory(void);
extern bool CommonSpecialPortalIsOpen(void);
/* estimate of the maximum number of open portals a user would have,
* used in initially sizing the PortalHashTable in EnablePortalManager()
......
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