aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/common/tupdesc.c55
-rw-r--r--src/backend/access/gist/gist.c9
-rw-r--r--src/backend/access/hash/hash.c9
-rw-r--r--src/backend/access/heap/heapam.c36
-rw-r--r--src/backend/access/nbtree/nbtree.c11
-rw-r--r--src/backend/access/rtree/rtree.c9
-rw-r--r--src/backend/access/transam/varsup.c4
-rw-r--r--src/backend/access/transam/xact.c11
-rw-r--r--src/backend/access/transam/xlogutils.c7
9 files changed, 80 insertions, 71 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 9b59947a882..1ed2366efda 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.67 2000/10/05 19:48:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.68 2000/11/08 22:09:53 tgl Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -228,7 +228,9 @@ FreeTupleDesc(TupleDesc tupdesc)
bool
equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
{
- int i;
+ int i,
+ j,
+ n;
if (tupdesc1->natts != tupdesc2->natts)
return false;
@@ -240,7 +242,9 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
/*
* We do not need to check every single field here, and in fact
* some fields such as attdispersion probably shouldn't be
- * compared.
+ * compared. We can also disregard attnum (it was used to
+ * place the row in the attrs array) and everything derived
+ * from the column datatype.
*/
if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
return false;
@@ -260,32 +264,53 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
if (constr2 == NULL)
return false;
- if (constr1->num_defval != constr2->num_defval)
+ if (constr1->has_not_null != constr2->has_not_null)
+ return false;
+ n = constr1->num_defval;
+ if (n != (int) constr2->num_defval)
return false;
- for (i = 0; i < (int) constr1->num_defval; i++)
+ for (i = 0; i < n; i++)
{
AttrDefault *defval1 = constr1->defval + i;
- AttrDefault *defval2 = constr2->defval + i;
+ AttrDefault *defval2 = constr2->defval;
- if (defval1->adnum != defval2->adnum)
+ /*
+ * We can't assume that the items are always read from the
+ * system catalogs in the same order; so use the adnum field to
+ * identify the matching item to compare.
+ */
+ for (j = 0; j < n; defval2++, j++)
+ {
+ if (defval1->adnum == defval2->adnum)
+ break;
+ }
+ if (j >= n)
return false;
if (strcmp(defval1->adbin, defval2->adbin) != 0)
return false;
}
- if (constr1->num_check != constr2->num_check)
+ n = constr1->num_check;
+ if (n != (int) constr2->num_check)
return false;
- for (i = 0; i < (int) constr1->num_check; i++)
+ for (i = 0; i < n; i++)
{
ConstrCheck *check1 = constr1->check + i;
- ConstrCheck *check2 = constr2->check + i;
+ ConstrCheck *check2 = constr2->check;
- if (strcmp(check1->ccname, check2->ccname) != 0)
- return false;
- if (strcmp(check1->ccbin, check2->ccbin) != 0)
+ /*
+ * Similarly, don't assume that the checks are always read
+ * in the same order; match them up by name and contents.
+ * (The name *should* be unique, but...)
+ */
+ for (j = 0; j < n; check2++, j++)
+ {
+ if (strcmp(check1->ccname, check2->ccname) == 0 &&
+ strcmp(check1->ccbin, check2->ccbin) == 0)
+ break;
+ }
+ if (j >= n)
return false;
}
- if (constr1->has_not_null != constr2->has_not_null)
- return false;
}
else if (tupdesc2->constr != NULL)
return false;
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index 560f28743f9..d7bfeb1287d 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.63 2000/10/21 15:43:09 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.64 2000/11/08 22:09:53 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -266,13 +266,12 @@ gistbuild(PG_FUNCTION_ARGS)
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
- bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
- UpdateStats(hrelid, nhtups, inplace);
- UpdateStats(irelid, nitups, inplace);
- if (oldPred != NULL && !inplace)
+ UpdateStats(hrelid, nhtups);
+ UpdateStats(irelid, nitups);
+ if (oldPred != NULL)
{
if (nitups == nhtups)
pred = NULL;
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 8db80d5154f..333199a898e 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.43 2000/10/21 15:43:11 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.44 2000/11/08 22:09:54 tgl Exp $
*
* NOTES
* This file contains only the public interface routines.
@@ -217,13 +217,12 @@ hashbuild(PG_FUNCTION_ARGS)
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
- bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
- UpdateStats(hrelid, nhtups, inplace);
- UpdateStats(irelid, nitups, inplace);
- if (oldPred != NULL && !inplace)
+ UpdateStats(hrelid, nhtups);
+ UpdateStats(irelid, nitups);
+ if (oldPred != NULL)
{
if (nitups == nhtups)
pred = NULL;
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index e796762ef16..5f450f91524 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.92 2000/10/29 18:33:39 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.93 2000/11/08 22:09:54 tgl Exp $
*
*
* INTERFACE ROUTINES
@@ -780,19 +780,13 @@ heap_beginscan(Relation relation,
/* ----------------
* increment relation ref count while scanning relation
- * ----------------
- */
- RelationIncrementReferenceCount(relation);
-
- /* ----------------
- * Acquire AccessShareLock for the duration of the scan
*
- * Note: we could get an SI inval message here and consequently have
- * to rebuild the relcache entry. The refcount increment above
- * ensures that we will rebuild it and not just flush it...
+ * This is just to make really sure the relcache entry won't go away
+ * while the scan has a pointer to it. Caller should be holding the
+ * rel open anyway, so this is redundant in all normal scenarios...
* ----------------
*/
- LockRelation(relation, AccessShareLock);
+ RelationIncrementReferenceCount(relation);
/* XXX someday assert SelfTimeQual if relkind == RELKIND_UNCATALOGED */
if (relation->rd_rel->relkind == RELKIND_UNCATALOGED)
@@ -809,13 +803,11 @@ heap_beginscan(Relation relation,
scan->rs_snapshot = snapshot;
scan->rs_nkeys = (short) nkeys;
+ /*
+ * we do this here instead of in initscan() because heap_rescan
+ * also calls initscan() and we don't want to allocate memory again
+ */
if (nkeys)
-
- /*
- * we do this here instead of in initscan() because heap_rescan
- * also calls initscan() and we don't want to allocate memory
- * again
- */
scan->rs_key = (ScanKey) palloc(sizeof(ScanKeyData) * nkeys);
else
scan->rs_key = NULL;
@@ -841,8 +833,6 @@ heap_rescan(HeapScanDesc scan,
IncrHeapAccessStat(local_rescan);
IncrHeapAccessStat(global_rescan);
- /* Note: set relation level read lock is still set */
-
/* ----------------
* unpin scan buffers
* ----------------
@@ -853,7 +843,7 @@ heap_rescan(HeapScanDesc scan,
* reinitialize scan descriptor
* ----------------
*/
- scan->rs_atend = (bool) scanFromEnd;
+ scan->rs_atend = scanFromEnd;
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
}
@@ -883,12 +873,6 @@ heap_endscan(HeapScanDesc scan)
unpinscan(scan);
/* ----------------
- * Release AccessShareLock acquired by heap_beginscan()
- * ----------------
- */
- UnlockRelation(scan->rs_rd, AccessShareLock);
-
- /* ----------------
* decrement relation reference count and free scan descriptor storage
* ----------------
*/
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index fb437ac99f4..ab942844afd 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -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.69 2000/11/01 20:39:58 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.70 2000/11/08 22:09:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -340,19 +340,16 @@ btbuild(PG_FUNCTION_ARGS)
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
- bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
-
- UpdateStats(hrelid, nhtups, inplace);
- UpdateStats(irelid, nitups, inplace);
+ UpdateStats(hrelid, nhtups);
+ UpdateStats(irelid, nitups);
if (oldPred != NULL)
{
if (nitups == nhtups)
pred = NULL;
- if (!inplace)
- UpdateIndexPredicate(irelid, oldPred, pred);
+ UpdateIndexPredicate(irelid, oldPred, pred);
}
}
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index 60f6a2f6ca9..ee5f621c0c3 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.54 2000/10/21 15:43:20 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.55 2000/11/08 22:09:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -237,13 +237,12 @@ rtbuild(PG_FUNCTION_ARGS)
{
Oid hrelid = RelationGetRelid(heap);
Oid irelid = RelationGetRelid(index);
- bool inplace = IsReindexProcessing();
heap_close(heap, NoLock);
index_close(index);
- UpdateStats(hrelid, nhtups, inplace);
- UpdateStats(irelid, nitups, inplace);
- if (oldPred != NULL && !inplace)
+ UpdateStats(hrelid, nhtups);
+ UpdateStats(irelid, nitups);
+ if (oldPred != NULL)
{
if (nitups == nhtups)
pred = NULL;
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index f29b41d749c..8c7d98ca707 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.31 2000/11/03 11:39:35 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.32 2000/11/08 22:09:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -130,7 +130,7 @@ VariableRelationPutNextXid(TransactionId xid)
TransactionIdStore(xid, &(var->nextXidData));
- FlushBuffer(buf, TRUE);
+ FlushBuffer(buf, true, true);
}
/* --------------------------------
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index cc4209fa51f..97ff91fc440 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.80 2000/11/05 22:50:19 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.81 2000/11/08 22:09:55 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@@ -167,6 +167,7 @@
#include "miscadmin.h"
#include "storage/proc.h"
#include "storage/sinval.h"
+#include "storage/smgr.h"
#include "utils/inval.h"
#include "utils/memutils.h"
#include "utils/portal.h"
@@ -1105,6 +1106,9 @@ CommitTransaction(void)
}
RelationPurgeLocalRelation(true);
+ AtEOXact_temp_relations(true);
+ smgrDoPendingDeletes(true);
+
AtEOXact_SPI();
AtEOXact_nbtree();
AtCommit_Cache();
@@ -1181,8 +1185,11 @@ AbortTransaction(void)
CloseSequences();
AtEOXact_portals();
RecordTransactionAbort();
+
RelationPurgeLocalRelation(false);
- remove_temp_rel_in_myxid();
+ AtEOXact_temp_relations(false);
+ smgrDoPendingDeletes(false);
+
AtEOXact_SPI();
AtEOXact_nbtree();
AtAbort_Cache();
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index 1fdc7e83fb5..b6442787334 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -171,9 +171,8 @@ XLogOpenLogRelation(void)
sprintf(RelationGetPhysicalRelationName(logRelation), "pg_log");
logRelation->rd_node.tblNode = InvalidOid;
logRelation->rd_node.relNode = RelOid_pg_log;
- logRelation->rd_unlinked = false; /* must exists */
logRelation->rd_fd = -1;
- logRelation->rd_fd = smgropen(DEFAULT_SMGR, logRelation);
+ logRelation->rd_fd = smgropen(DEFAULT_SMGR, logRelation, false);
if (logRelation->rd_fd < 0)
elog(STOP, "XLogOpenLogRelation: failed to open pg_log");
LogRelation = logRelation;
@@ -384,9 +383,9 @@ XLogOpenRelation(bool redo, RmgrId rmid, RelFileNode rnode)
hentry->rdesc = res;
- res->reldata.rd_unlinked = true; /* look smgropen */
res->reldata.rd_fd = -1;
- res->reldata.rd_fd = smgropen(DEFAULT_SMGR, &(res->reldata));
+ res->reldata.rd_fd = smgropen(DEFAULT_SMGR, &(res->reldata),
+ true /* allow failure */);
}
res->moreRecently = &(_xlrelarr[0]);