41 #define NUM_TEST_BUFFERS 16
44 #define TestSlruCtl (&TestSlruCtlData)
154 elog(
NOTICE,
"Called SlruSyncFileTag() for segment %lld on path %s",
155 (
long long) ftag.
segno, path);
169 elog(
NOTICE,
"Called SlruDeleteSegment() for segment %lld",
170 (
long long) ftag.
segno);
210 return page1 < page2;
220 const bool long_segment_names =
true;
221 const char slru_dir_name[] =
"pg_test_slru";
223 int test_buffer_tranche_id;
253 (
errmsg(
"cannot load \"%s\" after startup",
"test_slru"),
254 errdetail(
"\"%s\" must be loaded with \"shared_preload_libraries\".",
#define Assert(condition)
int errdetail(const char *fmt,...)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
int MakePGDirectory(const char *directoryName)
#define PG_GETARG_TEXT_PP(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_TEXT_P(x)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_BOOL(x)
void(* shmem_startup_hook_type)(void)
shmem_startup_hook_type shmem_startup_hook
void RequestAddinShmemSpace(Size size)
bool LWLockHeldByMe(LWLock *lock)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRegisterTranche(int tranche_id, const char *tranche_name)
int LWLockNewTrancheId(void)
void LWLockRelease(LWLock *lock)
void(* shmem_request_hook_type)(void)
shmem_request_hook_type shmem_request_hook
bool process_shared_preload_libraries_in_progress
void SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns, const char *subdir, int buffer_tranche_id, int bank_tranche_id, SyncRequestHandler sync_handler, bool long_segment_names)
int SimpleLruReadPage_ReadOnly(SlruCtl ctl, int64 pageno, TransactionId xid)
void SimpleLruWritePage(SlruCtl ctl, int slotno)
void SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
bool SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int64 pageno)
void SlruDeleteSegment(SlruCtl ctl, int64 segno)
bool SlruScanDirectory(SlruCtl ctl, SlruScanCallback callback, void *data)
bool SlruScanDirCbDeleteAll(SlruCtl ctl, char *filename, int64 segpage, void *data)
int SimpleLruReadPage(SlruCtl ctl, int64 pageno, bool write_ok, TransactionId xid)
int SlruSyncFileTag(SlruCtl ctl, const FileTag *ftag, char *path)
int SimpleLruZeroPage(SlruCtl ctl, int64 pageno)
void SimpleLruTruncate(SlruCtl ctl, int64 cutoffPage)
Size SimpleLruShmemSize(int nslots, int nlsns)
static LWLock * SimpleLruGetBankLock(SlruCtl ctl, int64 pageno)
#define SLRU_PAGES_PER_SEGMENT
static void test_slru_shmem_startup(void)
Datum test_slru_page_delete(PG_FUNCTION_ARGS)
static bool test_slru_page_precedes_logically(int64 page1, int64 page2)
Datum test_slru_page_write(PG_FUNCTION_ARGS)
Datum test_slru_page_exists(PG_FUNCTION_ARGS)
Datum test_slru_page_writeall(PG_FUNCTION_ARGS)
Datum test_slru_page_readonly(PG_FUNCTION_ARGS)
Datum test_slru_page_truncate(PG_FUNCTION_ARGS)
static shmem_startup_hook_type prev_shmem_startup_hook
static shmem_request_hook_type prev_shmem_request_hook
Datum test_slru_page_read(PG_FUNCTION_ARGS)
Datum test_slru_delete_all(PG_FUNCTION_ARGS)
static void test_slru_shmem_request(void)
PG_FUNCTION_INFO_V1(test_slru_page_write)
static SlruCtlData TestSlruCtlData
Datum test_slru_page_sync(PG_FUNCTION_ARGS)
static bool test_slru_scan_cb(SlruCtl ctl, char *filename, int64 segpage, void *data)
#define InvalidTransactionId
char * text_to_cstring(const text *t)
text * cstring_to_text(const char *s)