1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-23 03:21:12 +03:00

pgindent run on all C files. Java run to follow. initdb/regression

tests pass.
This commit is contained in:
Bruce Momjian
2001-10-25 05:50:21 +00:00
parent 59da2105d8
commit b81844b173
818 changed files with 21684 additions and 20491 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.125 2001/08/23 23:06:37 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.126 2001/10/25 05:49:21 momjian Exp $
*
*
* INTERFACE ROUTINES
@ -116,8 +116,8 @@ heapgettup(Relation relation,
{
ItemId lpp;
Page dp;
BlockNumber page;
BlockNumber pages;
BlockNumber page;
BlockNumber pages;
int lines;
OffsetNumber lineoff;
int linesleft;
@ -350,7 +350,7 @@ heapgettup(Relation relation,
/*
* return NULL if we've exhausted all the pages
*/
if ((dir < 0) ? (page == 0) : (page+1 >= pages))
if ((dir < 0) ? (page == 0) : (page + 1 >= pages))
{
if (BufferIsValid(*buffer))
ReleaseBuffer(*buffer);
@ -429,9 +429,8 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
(
(Datum) NULL
)
);
);
}
#endif /* defined(DISABLE_COMPLEX_MACRO) */
@ -1045,12 +1044,13 @@ heap_insert(Relation relation, HeapTuple tup)
if (relation->rd_rel->relhasoids)
{
/*
* If the object id of this tuple has already been assigned, trust the
* caller. There are a couple of ways this can happen. At initial db
* creation, the backend program sets oids for tuples. When we define
* an index, we set the oid. Finally, in the future, we may allow
* users to set their own object ids in order to support a persistent
* object store (objects need to contain pointers to one another).
* If the object id of this tuple has already been assigned, trust
* the caller. There are a couple of ways this can happen. At
* initial db creation, the backend program sets oids for tuples.
* When we define an index, we set the oid. Finally, in the
* future, we may allow users to set their own object ids in order
* to support a persistent object store (objects need to contain
* pointers to one another).
*/
if (!OidIsValid(tup->t_data->t_oid))
tup->t_data->t_oid = newoid();
@ -1478,21 +1478,22 @@ l2:
}
/*
* Now, do we need a new page for the tuple, or not? This is a bit
* tricky since someone else could have added tuples to the page
* while we weren't looking. We have to recheck the available space
* after reacquiring the buffer lock. But don't bother to do that
* if the former amount of free space is still not enough; it's
* unlikely there's more free now than before.
* Now, do we need a new page for the tuple, or not? This is a
* bit tricky since someone else could have added tuples to the
* page while we weren't looking. We have to recheck the
* available space after reacquiring the buffer lock. But don't
* bother to do that if the former amount of free space is still
* not enough; it's unlikely there's more free now than before.
*
* What's more, if we need to get a new page, we will need to acquire
* buffer locks on both old and new pages. To avoid deadlock against
* some other backend trying to get the same two locks in the other
* order, we must be consistent about the order we get the locks in.
* We use the rule "lock the lower-numbered page of the relation
* first". To implement this, we must do RelationGetBufferForTuple
* while not holding the lock on the old page, and we must rely on it
* to get the locks on both pages in the correct order.
* buffer locks on both old and new pages. To avoid deadlock
* against some other backend trying to get the same two locks in
* the other order, we must be consistent about the order we get
* the locks in. We use the rule "lock the lower-numbered page of
* the relation first". To implement this, we must do
* RelationGetBufferForTuple while not holding the lock on the old
* page, and we must rely on it to get the locks on both pages in
* the correct order.
*/
if (newtupsize > pagefree)
{
@ -1510,8 +1511,8 @@ l2:
{
/*
* Rats, it doesn't fit anymore. We must now unlock and
* relock to avoid deadlock. Fortunately, this path should
* seldom be taken.
* relock to avoid deadlock. Fortunately, this path
* should seldom be taken.
*/
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
newbuf = RelationGetBufferForTuple(relation, newtup->t_len,
@ -1534,9 +1535,9 @@ l2:
pgstat_count_heap_update(&relation->pgstat_info);
/*
* At this point newbuf and buffer are both pinned and locked,
* and newbuf has enough space for the new tuple. If they are
* the same buffer, only one pin is held.
* At this point newbuf and buffer are both pinned and locked, and
* newbuf has enough space for the new tuple. If they are the same
* buffer, only one pin is held.
*/
/* NO ELOG(ERROR) from here till changes are logged */
@ -1865,12 +1866,14 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
* Note: xlhdr is declared to have adequate size and correct alignment
* for an xl_heap_header. However the two tids, if present at all,
* will be packed in with no wasted space after the xl_heap_header;
* they aren't necessarily aligned as implied by this struct declaration.
* they aren't necessarily aligned as implied by this struct
* declaration.
*/
struct {
xl_heap_header hdr;
TransactionId tid1;
TransactionId tid2;
struct
{
xl_heap_header hdr;
TransactionId tid1;
TransactionId tid2;
} xlhdr;
int hsize = SizeOfHeapHeader;
xl_heap_update xlrec;
@ -1972,7 +1975,7 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record)
if (record->xl_len > SizeOfHeapClean)
{
OffsetNumber unbuf[BLCKSZ/sizeof(OffsetNumber)];
OffsetNumber unbuf[BLCKSZ / sizeof(OffsetNumber)];
OffsetNumber *unused = unbuf;
char *unend;
ItemId lp;
@ -2084,9 +2087,10 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
if (redo)
{
struct {
struct
{
HeapTupleHeaderData hdr;
char data[MaxTupleSize];
char data[MaxTupleSize];
} tbuf;
HeapTupleHeader htup;
xl_heap_header xlhdr;
@ -2251,9 +2255,10 @@ newsame:;
if (redo)
{
struct {
struct
{
HeapTupleHeaderData hdr;
char data[MaxTupleSize];
char data[MaxTupleSize];
} tbuf;
xl_heap_header xlhdr;
int hsize;

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Id: hio.c,v 1.42 2001/07/13 22:52:58 tgl Exp $
* $Id: hio.c,v 1.43 2001/10/25 05:49:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -83,7 +83,7 @@ RelationPutHeapTuple(Relation relation,
* NOTE: it is unlikely, but not quite impossible, for otherBuffer to be the
* same buffer we select for insertion of the new tuple (this could only
* happen if space is freed in that page after heap_update finds there's not
* enough there). In that case, the page will be pinned and locked only once.
* enough there). In that case, the page will be pinned and locked only once.
*
* Note that we use LockPage(rel, 0) to lock relation for extension.
* We can do this as long as in all other places we use page-level locking
@ -115,17 +115,19 @@ RelationGetBufferForTuple(Relation relation, Size len,
if (otherBuffer != InvalidBuffer)
otherBlock = BufferGetBlockNumber(otherBuffer);
else
otherBlock = InvalidBlockNumber; /* just to keep compiler quiet */
otherBlock = InvalidBlockNumber; /* just to keep compiler
* quiet */
/*
* We first try to put the tuple on the same page we last inserted a
* tuple on, as cached in the relcache entry. If that doesn't work,
* we ask the shared Free Space Map to locate a suitable page. Since
* we ask the shared Free Space Map to locate a suitable page. Since
* the FSM's info might be out of date, we have to be prepared to loop
* around and retry multiple times. (To insure this isn't an infinite
* loop, we must update the FSM with the correct amount of free space on
* each page that proves not to be suitable.) If the FSM has no record of
* a page with enough free space, we give up and extend the relation.
* loop, we must update the FSM with the correct amount of free space
* on each page that proves not to be suitable.) If the FSM has no
* record of a page with enough free space, we give up and extend the
* relation.
*/
targetBlock = relation->rd_targblock;
@ -137,6 +139,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
* target.
*/
targetBlock = GetPageWithFreeSpace(&relation->rd_node, len);
/*
* If the FSM knows nothing of the rel, try the last page before
* we give up and extend. This avoids one-tuple-per-page syndrome
@ -144,7 +147,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
*/
if (targetBlock == InvalidBlockNumber)
{
BlockNumber nblocks = RelationGetNumberOfBlocks(relation);
BlockNumber nblocks = RelationGetNumberOfBlocks(relation);
if (nblocks > 0)
targetBlock = nblocks - 1;
@ -154,9 +157,9 @@ RelationGetBufferForTuple(Relation relation, Size len,
while (targetBlock != InvalidBlockNumber)
{
/*
* Read and exclusive-lock the target block, as well as the
* other block if one was given, taking suitable care with
* lock ordering and the possibility they are the same block.
* Read and exclusive-lock the target block, as well as the other
* block if one was given, taking suitable care with lock ordering
* and the possibility they are the same block.
*/
if (otherBuffer == InvalidBuffer)
{
@ -184,9 +187,10 @@ RelationGetBufferForTuple(Relation relation, Size len,
LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE);
}
/*
* Now we can check to see if there's enough free space here.
* If so, we're done.
* Now we can check to see if there's enough free space here. If
* so, we're done.
*/
pageHeader = (Page) BufferGetPage(buffer);
pageFreeSpace = PageGetFreeSpace(pageHeader);
@ -196,22 +200,22 @@ RelationGetBufferForTuple(Relation relation, Size len,
relation->rd_targblock = targetBlock;
return buffer;
}
/*
* Not enough space, so we must give up our page locks and
* pin (if any) and prepare to look elsewhere. We don't care
* which order we unlock the two buffers in, so this can be
* slightly simpler than the code above.
* Not enough space, so we must give up our page locks and pin (if
* any) and prepare to look elsewhere. We don't care which order
* we unlock the two buffers in, so this can be slightly simpler
* than the code above.
*/
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
if (otherBuffer == InvalidBuffer)
{
ReleaseBuffer(buffer);
}
else if (otherBlock != targetBlock)
{
LockBuffer(otherBuffer, BUFFER_LOCK_UNLOCK);
ReleaseBuffer(buffer);
}
/*
* Update FSM as to condition of this page, and ask for another
* page to try.
@ -225,9 +229,9 @@ RelationGetBufferForTuple(Relation relation, Size len,
/*
* Have to extend the relation.
*
* We have to use a lock to ensure no one else is extending the
* rel at the same time, else we will both try to initialize the
* same new page.
* We have to use a lock to ensure no one else is extending the rel at
* the same time, else we will both try to initialize the same new
* page.
*/
if (!relation->rd_myxactonly)
LockPage(relation, 0, ExclusiveLock);
@ -236,20 +240,21 @@ RelationGetBufferForTuple(Relation relation, Size len,
* XXX This does an lseek - rather expensive - but at the moment it is
* the only way to accurately determine how many blocks are in a
* relation. Is it worth keeping an accurate file length in shared
* memory someplace, rather than relying on the kernel to do it for us?
* memory someplace, rather than relying on the kernel to do it for
* us?
*/
buffer = ReadBuffer(relation, P_NEW);
/*
* Release the file-extension lock; it's now OK for someone else
* to extend the relation some more.
* Release the file-extension lock; it's now OK for someone else to
* extend the relation some more.
*/
if (!relation->rd_myxactonly)
UnlockPage(relation, 0, ExclusiveLock);
/*
* We can be certain that locking the otherBuffer first is OK,
* since it must have a lower page number.
* We can be certain that locking the otherBuffer first is OK, since
* it must have a lower page number.
*/
if (otherBuffer != InvalidBuffer)
LockBuffer(otherBuffer, BUFFER_LOCK_EXCLUSIVE);
@ -273,7 +278,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
*
* XXX should we enter the new page into the free space map immediately,
* or just keep it for this backend's exclusive use in the short run
* (until VACUUM sees it)? Seems to depend on whether you expect the
* (until VACUUM sees it)? Seems to depend on whether you expect the
* current backend to make more insertions or not, which is probably a
* good bet most of the time. So for now, don't add it to FSM yet.
*/

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.24 2001/03/22 06:16:07 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.25 2001/10/25 05:49:21 momjian Exp $
*
* NOTES
* initam should be moved someplace else.
@ -164,7 +164,6 @@ ResetHeapAccessStatistics()
time(&stats->local_reset_timestamp);
time(&stats->last_request_timestamp);
}
#endif
#ifdef NOT_USED
@ -200,7 +199,6 @@ GetHeapAccessStatistics()
return stats;
}
#endif
#ifdef NOT_USED
@ -211,7 +209,6 @@ GetHeapAccessStatistics()
void
PrintHeapAccessStatistics(HeapAccessStatistics stats)
{
/*
* return nothing if stats aren't valid
*/
@ -302,7 +299,6 @@ PrintHeapAccessStatistics(HeapAccessStatistics stats)
printf("\n");
}
#endif
#ifdef NOT_USED
@ -317,7 +313,6 @@ PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats)
if (stats != NULL)
pfree(stats);
}
#endif
/* ----------------------------------------------------------------
@ -331,7 +326,6 @@ PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats)
void
initam(void)
{
/*
* initialize heap statistics.
*/

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.24 2001/08/10 18:57:33 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.25 2001/10/25 05:49:21 momjian Exp $
*
*
* INTERFACE ROUTINES
@ -74,14 +74,13 @@ heap_tuple_toast_attrs(Relation rel, HeapTuple newtup, HeapTuple oldtup)
* external storage (possibly still in compressed format).
* ----------
*/
varattrib *
varattrib *
heap_tuple_fetch_attr(varattrib *attr)
{
varattrib *result;
if (VARATT_IS_EXTERNAL(attr))
{
/*
* This is an external stored plain value
*/
@ -89,7 +88,6 @@ heap_tuple_fetch_attr(varattrib *attr)
}
else
{
/*
* This is a plain value inside of the main tuple - why am I
* called?
@ -108,7 +106,7 @@ heap_tuple_fetch_attr(varattrib *attr)
* or external storage.
* ----------
*/
varattrib *
varattrib *
heap_tuple_untoast_attr(varattrib *attr)
{
varattrib *result;
@ -135,7 +133,6 @@ heap_tuple_untoast_attr(varattrib *attr)
}
else
{
/*
* This is an external stored plain value
*/
@ -144,7 +141,6 @@ heap_tuple_untoast_attr(varattrib *attr)
}
else if (VARATT_IS_COMPRESSED(attr))
{
/*
* This is a compressed value inside of the main tuple
*/
@ -181,8 +177,8 @@ toast_raw_datum_size(Datum value)
if (VARATT_IS_COMPRESSED(attr))
{
/*
* va_rawsize shows the original data size, whether the datum
* is external or not.
* va_rawsize shows the original data size, whether the datum is
* external or not.
*/
result = attr->va_content.va_compressed.va_rawsize + VARHDRSZ;
}
@ -301,7 +297,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
if (oldtup != NULL)
{
/*
* For UPDATE get the old and new values of this attribute
*/
@ -324,7 +319,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
old_value->va_content.va_external.va_toastrelid !=
new_value->va_content.va_external.va_toastrelid)
{
/*
* The old external store value isn't needed any more
* after the update
@ -334,7 +328,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
}
else
{
/*
* This attribute isn't changed by this update so we
* reuse the original reference to the old value in
@ -348,7 +341,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
}
else
{
/*
* For INSERT simply get the new value
*/
@ -372,7 +364,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
*/
if (att[i]->attlen == -1)
{
/*
* If the table's attribute says PLAIN always, force it so.
*/
@ -400,7 +391,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
}
else
{
/*
* Not a variable size attribute, plain storage always
*/
@ -475,7 +465,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
}
else
{
/*
* incompressible data, ignore on subsequent compression
* passes
@ -588,7 +577,6 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
}
else
{
/*
* incompressible data, ignore on subsequent compression
* passes
@ -776,9 +764,10 @@ toast_save_datum(Relation rel, Datum value)
Datum t_values[3];
char t_nulls[3];
varattrib *result;
struct {
struct varlena hdr;
char data[TOAST_MAX_CHUNK_SIZE];
struct
{
struct varlena hdr;
char data[TOAST_MAX_CHUNK_SIZE];
} chunk_data;
int32 chunk_size;
int32 chunk_seq = 0;
@ -851,12 +840,12 @@ toast_save_datum(Relation rel, Datum value)
heap_insert(toastrel, toasttup);
/*
* Create the index entry. We cheat a little here by not using
* Create the index entry. We cheat a little here by not using
* FormIndexDatum: this relies on the knowledge that the index
* columns are the same as the initial columns of the table.
*
* Note also that there had better not be any user-created index
* on the TOAST table, since we don't bother to update anything else.
* Note also that there had better not be any user-created index on
* the TOAST table, since we don't bother to update anything else.
*/
idxres = index_insert(toastidx, t_values, t_nulls,
&(toasttup->t_self),
@ -916,8 +905,8 @@ toast_delete_datum(Relation rel, Datum value)
toastidx = index_open(toastrel->rd_rel->reltoastidxid);
/*
* Setup a scan key to fetch from the index by va_valueid
* (we don't particularly care whether we see them in sequence or not)
* Setup a scan key to fetch from the index by va_valueid (we don't
* particularly care whether we see them in sequence or not)
*/
ScanKeyEntryInitialize(&toastkey,
(bits16) 0,
@ -1096,5 +1085,4 @@ toast_fetch_datum(varattrib *attr)
return result;
}
#endif /* TUPLE_TOASTER_ACTIVE */