2001-06-27 19:31:40 -04:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* freespace.h
|
|
|
|
|
* POSTGRES free space map for quickly finding free space in relations
|
|
|
|
|
*
|
|
|
|
|
*
|
2004-12-31 17:04:05 -05:00
|
|
|
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
2001-06-27 19:31:40 -04:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
|
*
|
2004-12-31 17:04:05 -05:00
|
|
|
* $PostgreSQL: pgsql/src/include/storage/freespace.h,v 1.17 2004/12/31 22:03:42 pgsql Exp $
|
2001-06-27 19:31:40 -04:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef FREESPACE_H_
|
|
|
|
|
#define FREESPACE_H_
|
|
|
|
|
|
|
|
|
|
#include "storage/block.h"
|
|
|
|
|
#include "storage/relfilenode.h"
|
|
|
|
|
|
|
|
|
|
|
2002-09-20 15:56:01 -04:00
|
|
|
/*
|
|
|
|
|
* exported types
|
|
|
|
|
*/
|
|
|
|
|
typedef struct PageFreeSpaceInfo
|
|
|
|
|
{
|
2003-08-03 20:43:34 -04:00
|
|
|
BlockNumber blkno; /* which page in relation */
|
|
|
|
|
Size avail; /* space available on this page */
|
2003-08-08 17:42:59 -04:00
|
|
|
} PageFreeSpaceInfo;
|
2002-09-20 15:56:01 -04:00
|
|
|
|
|
|
|
|
|
2003-03-04 16:51:22 -05:00
|
|
|
/* GUC variables */
|
2001-06-27 19:31:40 -04:00
|
|
|
extern int MaxFSMRelations;
|
|
|
|
|
extern int MaxFSMPages;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* function prototypes
|
|
|
|
|
*/
|
|
|
|
|
extern void InitFreeSpaceMap(void);
|
|
|
|
|
extern int FreeSpaceShmemSize(void);
|
|
|
|
|
|
|
|
|
|
extern BlockNumber GetPageWithFreeSpace(RelFileNode *rel, Size spaceNeeded);
|
|
|
|
|
extern BlockNumber RecordAndGetPageWithFreeSpace(RelFileNode *rel,
|
2001-10-25 01:50:21 -04:00
|
|
|
BlockNumber oldPage,
|
|
|
|
|
Size oldSpaceAvail,
|
|
|
|
|
Size spaceNeeded);
|
2003-03-04 16:51:22 -05:00
|
|
|
extern Size GetAvgFSMRequestSize(RelFileNode *rel);
|
|
|
|
|
extern void RecordRelationFreeSpace(RelFileNode *rel,
|
2003-08-03 20:43:34 -04:00
|
|
|
int nPages,
|
2003-08-08 17:42:59 -04:00
|
|
|
PageFreeSpaceInfo *pageSpaces);
|
2003-03-04 16:51:22 -05:00
|
|
|
|
|
|
|
|
extern BlockNumber GetFreeIndexPage(RelFileNode *rel);
|
|
|
|
|
extern void RecordIndexFreeSpace(RelFileNode *rel,
|
2003-08-03 20:43:34 -04:00
|
|
|
int nPages,
|
|
|
|
|
BlockNumber *pages);
|
2003-03-04 16:51:22 -05:00
|
|
|
|
|
|
|
|
extern void FreeSpaceMapTruncateRel(RelFileNode *rel, BlockNumber nblocks);
|
2001-06-27 19:31:40 -04:00
|
|
|
extern void FreeSpaceMapForgetRel(RelFileNode *rel);
|
2001-07-02 16:50:46 -04:00
|
|
|
extern void FreeSpaceMapForgetDatabase(Oid dbid);
|
2001-06-27 19:31:40 -04:00
|
|
|
|
2003-03-04 16:51:22 -05:00
|
|
|
extern void PrintFreeSpaceMapStatistics(int elevel);
|
|
|
|
|
|
2003-12-12 13:45:10 -05:00
|
|
|
extern void DumpFreeSpaceMap(int code, Datum arg);
|
2003-03-05 19:04:27 -05:00
|
|
|
extern void LoadFreeSpaceMap(void);
|
|
|
|
|
|
2001-06-27 19:31:40 -04:00
|
|
|
#ifdef FREESPACE_DEBUG
|
|
|
|
|
extern void DumpFreeSpace(void);
|
|
|
|
|
#endif
|
2001-10-28 01:26:15 -05:00
|
|
|
|
2001-11-05 12:46:40 -05:00
|
|
|
#endif /* FREESPACE_H */
|