8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.23 2003/09 /29 00:05:25 petere Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.24 2003/10 /29 17:36:57 tgl Exp $
12
12
*
13
13
*
14
14
* NOTES:
@@ -1432,19 +1432,29 @@ compact_fsm_storage(void)
1432
1432
1433
1433
/*
1434
1434
* It's possible that we have to move data down, not up, if the
1435
- * allocations of previous rels expanded. This should mean that
1435
+ * allocations of previous rels expanded. This normally means that
1436
1436
* our allocation expanded too (or at least got no worse), and
1437
- * ditto for later rels. So there should be room --- but we might
1438
- * have to push down following rels to make it. We don't want to
1439
- * do the push more than once, so pack everything against the end
1440
- * of the arena if so.
1437
+ * ditto for later rels. So there should be room to move all our
1438
+ * data down without dropping any --- but we might have to push down
1439
+ * following rels to acquire the room. We don't want to do the push
1440
+ * more than once, so pack everything against the end of the arena
1441
+ * if so.
1442
+ *
1443
+ * In corner cases where roundoff has affected our allocation, it's
1444
+ * possible that we have to move down and compress our data too.
1445
+ * Since this case is extremely infrequent, we do not try to be smart
1446
+ * about it --- we just drop pages from the end of the rel's data.
1441
1447
*/
1442
1448
if (newChunkIndex > oldChunkIndex )
1443
1449
{
1444
1450
int limitChunkIndex ;
1445
1451
1446
1452
if (newAllocPages < fsmrel -> storedPages )
1447
- elog (PANIC , "can't juggle and compress too" );
1453
+ {
1454
+ /* move and compress --- just drop excess pages */
1455
+ fsmrel -> storedPages = newAllocPages ;
1456
+ curChunks = fsm_current_chunks (fsmrel );
1457
+ }
1448
1458
if (fsmrel -> nextPhysical != NULL )
1449
1459
limitChunkIndex = fsmrel -> nextPhysical -> firstChunk ;
1450
1460
else
@@ -1459,7 +1469,7 @@ compact_fsm_storage(void)
1459
1469
else
1460
1470
limitChunkIndex = FreeSpaceMap -> totalChunks ;
1461
1471
if (newChunkIndex + curChunks > limitChunkIndex )
1462
- elog (PANIC , "insufficient room" );
1472
+ elog (PANIC , "insufficient room in FSM " );
1463
1473
}
1464
1474
memmove (newLocation , oldLocation , curChunks * CHUNKBYTES );
1465
1475
}
@@ -1535,7 +1545,7 @@ push_fsm_rels_after(FSMRelation *afterRel)
1535
1545
if (newChunkIndex < oldChunkIndex )
1536
1546
{
1537
1547
/* trouble... */
1538
- elog (PANIC , "out of room" );
1548
+ elog (PANIC , "insufficient room in FSM " );
1539
1549
}
1540
1550
else if (newChunkIndex > oldChunkIndex )
1541
1551
{
0 commit comments