2003-06-12 00:37:46 +02:00
|
|
|
/*
|
|
|
|
* slru.h
|
|
|
|
*
|
|
|
|
* Simple LRU
|
|
|
|
*
|
|
|
|
* Portions Copyright (c) 2003, PostgreSQL Global Development Group
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2004-05-31 05:48:10 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/access/slru.h,v 1.6 2004/05/31 03:48:08 tgl Exp $
|
2003-06-12 00:37:46 +02:00
|
|
|
*/
|
|
|
|
#ifndef SLRU_H
|
|
|
|
#define SLRU_H
|
|
|
|
|
2004-05-31 05:48:10 +02:00
|
|
|
#include "storage/lwlock.h"
|
2003-06-12 00:37:46 +02:00
|
|
|
|
|
|
|
|
2004-05-31 05:48:10 +02:00
|
|
|
/* Opaque structs known only in slru.c */
|
|
|
|
typedef struct SlruSharedData *SlruShared;
|
|
|
|
typedef struct SlruFlushData *SlruFlush;
|
2003-06-12 00:37:46 +02:00
|
|
|
|
2004-05-28 07:13:32 +02:00
|
|
|
/*
|
|
|
|
* SlruCtlData is an unshared structure that points to the active information
|
|
|
|
* in shared memory.
|
|
|
|
*/
|
2003-06-12 00:37:46 +02:00
|
|
|
typedef struct SlruCtlData
|
|
|
|
{
|
2004-05-31 05:48:10 +02:00
|
|
|
SlruShared shared;
|
|
|
|
|
|
|
|
LWLockId ControlLock;
|
2003-06-12 00:37:46 +02:00
|
|
|
|
2004-05-28 07:13:32 +02:00
|
|
|
/*
|
2004-05-31 05:48:10 +02:00
|
|
|
* Dir is set during SimpleLruInit and does not change thereafter.
|
|
|
|
* Since it's always the same, it doesn't need to be in shared memory.
|
2004-05-28 07:13:32 +02:00
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
char Dir[MAXPGPATH];
|
|
|
|
|
2004-05-28 07:13:32 +02:00
|
|
|
/*
|
|
|
|
* Decide which of two page numbers is "older" for truncation purposes.
|
|
|
|
* We need to use comparison of TransactionIds here in order to do the
|
|
|
|
* right thing with wraparound XID arithmetic.
|
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
bool (*PagePrecedes) (int, int);
|
2003-06-12 00:37:46 +02:00
|
|
|
|
2003-08-08 23:42:59 +02:00
|
|
|
} SlruCtlData;
|
2004-05-31 05:48:10 +02:00
|
|
|
|
2003-06-12 00:37:46 +02:00
|
|
|
typedef SlruCtlData *SlruCtl;
|
|
|
|
|
2004-05-31 05:48:10 +02:00
|
|
|
|
2003-06-12 00:37:46 +02:00
|
|
|
extern int SimpleLruShmemSize(void);
|
|
|
|
extern void SimpleLruInit(SlruCtl ctl, const char *name, const char *subdir);
|
|
|
|
extern int SimpleLruZeroPage(SlruCtl ctl, int pageno);
|
2004-05-31 05:48:10 +02:00
|
|
|
extern char *SimpleLruReadPage(SlruCtl ctl, int pageno,
|
|
|
|
TransactionId xid, bool forwrite);
|
|
|
|
extern void SimpleLruWritePage(SlruCtl ctl, int slotno, SlruFlush fdata);
|
2003-06-12 00:37:46 +02:00
|
|
|
extern void SimpleLruSetLatestPage(SlruCtl ctl, int pageno);
|
|
|
|
extern void SimpleLruFlush(SlruCtl ctl, bool checkpoint);
|
|
|
|
extern void SimpleLruTruncate(SlruCtl ctl, int cutoffPage);
|
|
|
|
|
|
|
|
#endif /* SLRU_H */
|