mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Clean up a couple of ad-hoc computations of the maximum number of tuples
on a page, as suggested by ITAGAKI Takahiro. Also, change a few places that were using some other estimates of max-items-per-page to consistently use MaxOffsetNumber. This is conservatively large --- we could have used the new MaxHeapTuplesPerPage macro, or a similar one for index tuples --- but those places are simply declaring a fixed-size buffer and assuming it will work, rather than actively testing for overrun. It seems safer to size these buffers in a way that can't overflow even if the page is corrupt.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.6 2005/06/30 17:52:14 teodor Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/gist/gistvacuum.c,v 1.7 2005/09/02 19:02:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -52,7 +52,7 @@ gistVacuumUpdate( GistVacuum *gv, BlockNumber blkno, bool needunion ) {
|
||||
int lenaddon=4, curlenaddon=0, ntodelete=0;
|
||||
IndexTuple idxtuple, *addon=NULL;
|
||||
bool needwrite=false;
|
||||
OffsetNumber todelete[ BLCKSZ/SizeOfIptrData ];
|
||||
OffsetNumber todelete[MaxOffsetNumber];
|
||||
ItemPointerData *completed=NULL;
|
||||
int ncompleted=0, lencompleted=16;
|
||||
|
||||
@@ -439,7 +439,7 @@ gistbulkdelete(PG_FUNCTION_ARGS) {
|
||||
page = (Page) BufferGetPage(buffer);
|
||||
|
||||
if ( GistPageIsLeaf(page) ) {
|
||||
OffsetNumber todelete[BLCKSZ/SizeOfIptrData];
|
||||
OffsetNumber todelete[MaxOffsetNumber];
|
||||
int ntodelete = 0;
|
||||
|
||||
LockBuffer(buffer, GIST_UNLOCK);
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.130 2005/05/11 06:24:53 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.131 2005/09/02 19:02:19 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -584,7 +584,7 @@ btbulkdelete(PG_FUNCTION_ARGS)
|
||||
IndexBulkDeleteResult *result;
|
||||
double tuples_removed;
|
||||
double num_index_tuples;
|
||||
OffsetNumber deletable[BLCKSZ / sizeof(OffsetNumber)];
|
||||
OffsetNumber deletable[MaxOffsetNumber];
|
||||
int ndeletable;
|
||||
Buffer buf;
|
||||
BlockNumber num_pages;
|
||||
|
||||
Reference in New Issue
Block a user