mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Remove archive stuff.
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.16 1997/11/20 23:20:58 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.17 1997/11/21 18:09:46 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -215,11 +215,7 @@ copy_heap(Oid OIDOldHeap)
|
||||
|
||||
tupdesc = CreateTupleDescCopy(OldHeapDesc);
|
||||
|
||||
OIDNewHeap = heap_create(NewName,
|
||||
NULL,
|
||||
OldHeap->rd_rel->relarch,
|
||||
OldHeap->rd_rel->relsmgr,
|
||||
tupdesc);
|
||||
OIDNewHeap = heap_create(NewName, tupdesc);
|
||||
|
||||
if (!OidIsValid(OIDNewHeap))
|
||||
elog(WARN, "clusterheap: cannot create temporary heap relation\n");
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.18 1997/10/25 01:08:51 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.19 1997/11/21 18:09:49 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -51,16 +51,9 @@ DefineRelation(CreateStmt *stmt)
|
||||
List *schema = stmt->tableElts;
|
||||
int numberOfAttributes;
|
||||
Oid relationId;
|
||||
char archChar;
|
||||
List *inheritList = NULL;
|
||||
char *archiveName = NULL;
|
||||
TupleDesc descriptor;
|
||||
List *constraints;
|
||||
int heaploc,
|
||||
archloc;
|
||||
|
||||
char *typename = NULL;/* the typename of this relation. not
|
||||
* useod for now */
|
||||
|
||||
if (strlen(stmt->relname) >= NAMEDATALEN)
|
||||
elog(WARN, "the relation name %s is >= %d characters long", stmt->relname,
|
||||
@ -75,53 +68,6 @@ DefineRelation(CreateStmt *stmt)
|
||||
*/
|
||||
inheritList = stmt->inhRelnames;
|
||||
|
||||
/* ----------------
|
||||
* determine archive mode
|
||||
* XXX use symbolic constants...
|
||||
* ----------------
|
||||
*/
|
||||
archChar = 'n';
|
||||
|
||||
switch (stmt->archiveType)
|
||||
{
|
||||
case ARCH_NONE:
|
||||
archChar = 'n';
|
||||
break;
|
||||
case ARCH_LIGHT:
|
||||
archChar = 'l';
|
||||
break;
|
||||
case ARCH_HEAVY:
|
||||
archChar = 'h';
|
||||
break;
|
||||
default:
|
||||
elog(WARN, "Botched archive mode %d, ignoring",
|
||||
stmt->archiveType);
|
||||
break;
|
||||
}
|
||||
|
||||
if (stmt->location == -1)
|
||||
heaploc = 0;
|
||||
else
|
||||
heaploc = stmt->location;
|
||||
|
||||
/*
|
||||
* For now, any user-defined relation defaults to the magnetic disk
|
||||
* storgage manager. --mao 2 july 91
|
||||
*/
|
||||
if (stmt->archiveLoc == -1)
|
||||
{
|
||||
archloc = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (archChar == 'n')
|
||||
{
|
||||
elog(WARN, "Set archive location, but not mode, for %s",
|
||||
relname);
|
||||
}
|
||||
archloc = stmt->archiveLoc;
|
||||
}
|
||||
|
||||
/* ----------------
|
||||
* generate relation schema, including inherited attributes.
|
||||
* ----------------
|
||||
@ -191,42 +137,9 @@ DefineRelation(CreateStmt *stmt)
|
||||
}
|
||||
}
|
||||
|
||||
relationId = heap_create(relname,
|
||||
typename,
|
||||
archChar,
|
||||
heaploc,
|
||||
descriptor);
|
||||
relationId = heap_create(relname, descriptor);
|
||||
|
||||
StoreCatalogInheritance(relationId, inheritList);
|
||||
|
||||
/*
|
||||
* create an archive relation if necessary
|
||||
*/
|
||||
if (archChar != 'n')
|
||||
{
|
||||
TupleDesc tupdesc;
|
||||
|
||||
/*
|
||||
* Need to create an archive relation for this heap relation. We
|
||||
* cobble up the command by hand, and increment the command
|
||||
* counter ourselves.
|
||||
*/
|
||||
|
||||
CommandCounterIncrement();
|
||||
archiveName = MakeArchiveName(relationId);
|
||||
|
||||
tupdesc = CreateTupleDescCopy(descriptor); /* get rid of
|
||||
* constraints */
|
||||
(void) heap_create(archiveName,
|
||||
typename,
|
||||
'n', /* archive isn't archived */
|
||||
archloc,
|
||||
tupdesc);
|
||||
|
||||
FreeTupleDesc(tupdesc);
|
||||
FreeTupleDesc(descriptor);
|
||||
pfree(archiveName);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -664,26 +577,3 @@ checkAttrExists(char *attributeName, char *attributeType, List *schema)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* MakeArchiveName
|
||||
* make an archive rel name out of a regular rel name
|
||||
*
|
||||
* the CALLER is responsible for freeing the memory allocated
|
||||
*/
|
||||
|
||||
char *
|
||||
MakeArchiveName(Oid relationId)
|
||||
{
|
||||
char *arch;
|
||||
|
||||
/*
|
||||
* Archive relations are named a,XXXXX where XXXXX == the OID of the
|
||||
* relation they archive. Create a string containing this name and
|
||||
* find the reldesc for the archive relation.
|
||||
*/
|
||||
arch = palloc(NAMEDATALEN);
|
||||
sprintf(arch, "a,%d", relationId);
|
||||
|
||||
return arch;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.11 1997/11/20 23:21:10 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.12 1997/11/21 18:09:51 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1047,11 +1047,7 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||
len = length(q->qtrees[0]->targetList);
|
||||
tupdesc = rel->rd_att;
|
||||
|
||||
relid = heap_create(child->nodeElem->outTypes->val[0],
|
||||
NULL, /* XXX */
|
||||
'n',
|
||||
DEFAULT_SMGR,
|
||||
tupdesc);
|
||||
relid = heap_create(child->nodeElem->outTypes->val[0], tupdesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1076,9 +1072,6 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo)
|
||||
else
|
||||
{
|
||||
relid = heap_create(child->nodeElem->outTypes->val[0],
|
||||
NULL, /* XXX */
|
||||
'n',
|
||||
DEFAULT_SMGR,
|
||||
tupdesc);
|
||||
}
|
||||
}
|
||||
|
@ -151,8 +151,6 @@ DefineSequence(CreateSeqStmt *seq)
|
||||
}
|
||||
|
||||
stmt->relname = seq->seqname;
|
||||
stmt->archiveLoc = -1; /* default */
|
||||
stmt->archiveType = ARCH_NONE;
|
||||
stmt->inhRelnames = NIL;
|
||||
stmt->constraints = NIL;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.50 1997/11/20 23:21:16 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.51 1997/11/21 18:09:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -82,7 +82,7 @@ static void vc_vacone(Oid relid, bool analyze, List *va_cols);
|
||||
static void vc_scanheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl);
|
||||
static void vc_rpfheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation *Irel);
|
||||
static void vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList vpl);
|
||||
static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel);
|
||||
static void vc_vacpage(Page page, VPageDescr vpd);
|
||||
static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups);
|
||||
static void vc_scanoneind(Relation indrel, int nhtups);
|
||||
static void vc_attrstats(Relation onerel, VRelStats *vacrelstats, HeapTuple htup);
|
||||
@ -96,9 +96,6 @@ static void vc_vpinsert(VPageList vpl, VPageDescr vpnew);
|
||||
static void vc_free(VRelList vrl);
|
||||
static void vc_getindices(Oid relid, int *nindices, Relation **Irel);
|
||||
static void vc_clsindices(int nindices, Relation *Irel);
|
||||
static Relation vc_getarchrel(Relation heaprel);
|
||||
static void vc_archive(Relation archrel, HeapTuple htup);
|
||||
static bool vc_isarchrel(char *rname);
|
||||
static void vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc);
|
||||
static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *));
|
||||
static int vc_cmp_blk(char *left, char *right);
|
||||
@ -271,7 +268,6 @@ vc_getrels(NameData *VacRelP)
|
||||
Datum d;
|
||||
char *rname;
|
||||
char rkind;
|
||||
int16 smgrno;
|
||||
bool n;
|
||||
ScanKeyData pgckey;
|
||||
bool found = false;
|
||||
@ -303,23 +299,9 @@ vc_getrels(NameData *VacRelP)
|
||||
|
||||
found = true;
|
||||
|
||||
/*
|
||||
* We have to be careful not to vacuum the archive (since it
|
||||
* already contains vacuumed tuples), and not to vacuum relations
|
||||
* on write-once storage managers like the Sony jukebox at
|
||||
* Berkeley.
|
||||
*/
|
||||
|
||||
d = heap_getattr(pgctup, buf, Anum_pg_class_relname, pgcdesc, &n);
|
||||
rname = (char *) d;
|
||||
|
||||
/* skip archive relations */
|
||||
if (vc_isarchrel(rname))
|
||||
{
|
||||
ReleaseBuffer(buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* don't vacuum large objects for now - something breaks when we
|
||||
* do
|
||||
@ -335,16 +317,6 @@ vc_getrels(NameData *VacRelP)
|
||||
continue;
|
||||
}
|
||||
|
||||
d = heap_getattr(pgctup, buf, Anum_pg_class_relsmgr, pgcdesc, &n);
|
||||
smgrno = DatumGetInt16(d);
|
||||
|
||||
/* skip write-once storage managers */
|
||||
if (smgriswo(smgrno))
|
||||
{
|
||||
ReleaseBuffer(buf);
|
||||
continue;
|
||||
}
|
||||
|
||||
d = heap_getattr(pgctup, buf, Anum_pg_class_relkind, pgcdesc, &n);
|
||||
|
||||
rkind = DatumGetChar(d);
|
||||
@ -1005,7 +977,6 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
ntups;
|
||||
bool isempty,
|
||||
dowrite;
|
||||
Relation archrel;
|
||||
struct rusage ru0,
|
||||
ru1;
|
||||
|
||||
@ -1022,27 +993,6 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
inulls = (char *) palloc(INDEX_MAX_KEYS * sizeof(*inulls));
|
||||
}
|
||||
|
||||
/* if the relation has an archive, open it */
|
||||
if (onerel->rd_rel->relarch != 'n')
|
||||
{
|
||||
archrel = vc_getarchrel(onerel);
|
||||
/* Archive tuples from "empty" end-pages */
|
||||
for (vpp = Vvpl->vpl_pgdesc + Vvpl->vpl_npages - 1,
|
||||
i = Vvpl->vpl_nemend; i > 0; i--, vpp--)
|
||||
{
|
||||
if ((*vpp)->vpd_noff > 0)
|
||||
{
|
||||
buf = ReadBuffer(onerel, (*vpp)->vpd_blkno);
|
||||
page = BufferGetPage(buf);
|
||||
Assert(!PageIsEmpty(page));
|
||||
vc_vacpage(page, *vpp, archrel);
|
||||
WriteBuffer(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
archrel = (Relation) NULL;
|
||||
|
||||
Nvpl.vpl_npages = 0;
|
||||
Fnpages = Fvpl->vpl_npages;
|
||||
Fvplast = Fvpl->vpl_pgdesc[Fnpages - 1];
|
||||
@ -1078,7 +1028,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
if (Vvplast->vpd_noff > 0) /* there are dead tuples */
|
||||
{ /* on this page - clean */
|
||||
Assert(!isempty);
|
||||
vc_vacpage(page, Vvplast, archrel);
|
||||
vc_vacpage(page, Vvplast);
|
||||
dowrite = true;
|
||||
}
|
||||
else
|
||||
@ -1169,7 +1119,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
ToPage = BufferGetPage(ToBuf);
|
||||
/* if this page was not used before - clean it */
|
||||
if (!PageIsEmpty(ToPage) && ToVpd->vpd_nusd == 0)
|
||||
vc_vacpage(ToPage, ToVpd, archrel);
|
||||
vc_vacpage(ToPage, ToVpd);
|
||||
}
|
||||
|
||||
/* copy tuple */
|
||||
@ -1292,7 +1242,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
* re-used
|
||||
*/
|
||||
Assert((*vpp)->vpd_noff > 0);
|
||||
vc_vacpage(page, *vpp, archrel);
|
||||
vc_vacpage(page, *vpp);
|
||||
}
|
||||
else
|
||||
/* this page was used */
|
||||
@ -1392,14 +1342,11 @@ Elapsed %u/%u sec.",
|
||||
i = BlowawayRelationBuffers(onerel, blkno);
|
||||
if (i < 0)
|
||||
elog (FATAL, "VACUUM (vc_rpfheap): BlowawayRelationBuffers returned %d", i);
|
||||
blkno = smgrtruncate(onerel->rd_rel->relsmgr, onerel, blkno);
|
||||
blkno = smgrtruncate(DEFAULT_SMGR, onerel, blkno);
|
||||
Assert(blkno >= 0);
|
||||
vacrelstats->npages = blkno; /* set new number of blocks */
|
||||
}
|
||||
|
||||
if (archrel != (Relation) NULL)
|
||||
heap_close(archrel);
|
||||
|
||||
if (Irel != (Relation *) NULL) /* pfree index' allocations */
|
||||
{
|
||||
pfree(Idesc);
|
||||
@ -1424,19 +1371,11 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl)
|
||||
Buffer buf;
|
||||
Page page;
|
||||
VPageDescr *vpp;
|
||||
Relation archrel;
|
||||
int nblocks;
|
||||
int i;
|
||||
|
||||
nblocks = Vvpl->vpl_npages;
|
||||
/* if the relation has an archive, open it */
|
||||
if (onerel->rd_rel->relarch != 'n')
|
||||
archrel = vc_getarchrel(onerel);
|
||||
else
|
||||
{
|
||||
archrel = (Relation) NULL;
|
||||
nblocks -= Vvpl->vpl_nemend; /* nothing to do with them */
|
||||
}
|
||||
nblocks -= Vvpl->vpl_nemend; /* nothing to do with them */
|
||||
|
||||
for (i = 0, vpp = Vvpl->vpl_pgdesc; i < nblocks; i++, vpp++)
|
||||
{
|
||||
@ -1444,7 +1383,7 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl)
|
||||
{
|
||||
buf = ReadBuffer(onerel, (*vpp)->vpd_blkno);
|
||||
page = BufferGetPage(buf);
|
||||
vc_vacpage(page, *vpp, archrel);
|
||||
vc_vacpage(page, *vpp);
|
||||
WriteBuffer(buf);
|
||||
}
|
||||
}
|
||||
@ -1468,22 +1407,19 @@ vc_vacheap(VRelStats *vacrelstats, Relation onerel, VPageList Vvpl)
|
||||
if (i < 0)
|
||||
elog (FATAL, "VACUUM (vc_vacheap): BlowawayRelationBuffers returned %d", i);
|
||||
|
||||
nblocks = smgrtruncate(onerel->rd_rel->relsmgr, onerel, nblocks);
|
||||
nblocks = smgrtruncate(DEFAULT_SMGR, onerel, nblocks);
|
||||
Assert(nblocks >= 0);
|
||||
vacrelstats->npages = nblocks; /* set new number of blocks */
|
||||
}
|
||||
|
||||
if (archrel != (Relation) NULL)
|
||||
heap_close(archrel);
|
||||
|
||||
} /* vc_vacheap */
|
||||
|
||||
/*
|
||||
* vc_vacpage() -- free (and archive if needed) dead tuples on a page
|
||||
* vc_vacpage() -- free dead tuples on a page
|
||||
* and repaire its fragmentation.
|
||||
*/
|
||||
static void
|
||||
vc_vacpage(Page page, VPageDescr vpd, Relation archrel)
|
||||
vc_vacpage(Page page, VPageDescr vpd)
|
||||
{
|
||||
ItemId itemid;
|
||||
HeapTuple htup;
|
||||
@ -1493,11 +1429,6 @@ vc_vacpage(Page page, VPageDescr vpd, Relation archrel)
|
||||
for (i = 0; i < vpd->vpd_noff; i++)
|
||||
{
|
||||
itemid = &(((PageHeader) page)->pd_linp[vpd->vpd_voff[i] - 1]);
|
||||
if (archrel != (Relation) NULL && ItemIdIsUsed(itemid))
|
||||
{
|
||||
htup = (HeapTuple) PageGetItem(page, itemid);
|
||||
vc_archive(archrel, htup);
|
||||
}
|
||||
itemid->lp_flags &= ~LP_USED;
|
||||
}
|
||||
PageRepairFragmentation(page);
|
||||
@ -2128,51 +2059,6 @@ vc_free(VRelList vrl)
|
||||
MemoryContextSwitchTo(old);
|
||||
}
|
||||
|
||||
/*
|
||||
* vc_getarchrel() -- open the archive relation for a heap relation
|
||||
*
|
||||
* The archive relation is named 'a,XXXXX' for the heap relation
|
||||
* whose relid is XXXXX.
|
||||
*/
|
||||
|
||||
#define ARCHIVE_PREFIX "a,"
|
||||
|
||||
static Relation
|
||||
vc_getarchrel(Relation heaprel)
|
||||
{
|
||||
Relation archrel;
|
||||
char *archrelname;
|
||||
|
||||
archrelname = palloc(sizeof(ARCHIVE_PREFIX) + NAMEDATALEN); /* bogus */
|
||||
sprintf(archrelname, "%s%d", ARCHIVE_PREFIX, heaprel->rd_id);
|
||||
|
||||
archrel = heap_openr(archrelname);
|
||||
|
||||
pfree(archrelname);
|
||||
return (archrel);
|
||||
}
|
||||
|
||||
/*
|
||||
* vc_archive() -- write a tuple to an archive relation
|
||||
*
|
||||
* In the future, this will invoke the archived accessd method. For
|
||||
* now, archive relations are on mag disk.
|
||||
*/
|
||||
static void
|
||||
vc_archive(Relation archrel, HeapTuple htup)
|
||||
{
|
||||
doinsert(archrel, htup);
|
||||
}
|
||||
|
||||
static bool
|
||||
vc_isarchrel(char *rname)
|
||||
{
|
||||
if (strncmp(ARCHIVE_PREFIX, rname, strlen(ARCHIVE_PREFIX)) == 0)
|
||||
return (true);
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
static char *
|
||||
vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *))
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.14 1997/11/20 23:21:18 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.15 1997/11/21 18:09:58 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -100,9 +100,6 @@ DefineVirtualRelation(char *relname, List *tlist)
|
||||
createStmt.tableElts = attrList;
|
||||
/* createStmt.tableType = NULL;*/
|
||||
createStmt.inhRelnames = NIL;
|
||||
createStmt.archiveType = ARCH_NONE;
|
||||
createStmt.location = -1;
|
||||
createStmt.archiveLoc = -1;
|
||||
createStmt.constraints = NIL;
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user