2004-06-24 21:10:31 +00:00
|
|
|
/*---
|
|
|
|
This software is copyrighted by the Regents of the University of
|
|
|
|
California, and other parties. The following terms apply to all files
|
|
|
|
associated with the software unless explicitly disclaimed in
|
|
|
|
individual files.
|
|
|
|
|
|
|
|
The authors hereby grant permission to use, copy, modify, distribute,
|
|
|
|
and license this software and its documentation for any purpose,
|
|
|
|
provided that existing copyright notices are retained in all copies
|
|
|
|
and that this notice is included verbatim in any distributions. No
|
|
|
|
written agreement, license, or royalty fee is required for any of the
|
|
|
|
authorized uses. Modifications to this software may be copyrighted by
|
|
|
|
their authors and need not follow the licensing terms described here,
|
|
|
|
provided that the new terms are clearly indicated on the first page of
|
|
|
|
each file where they apply.
|
|
|
|
|
|
|
|
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
|
|
|
|
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
|
|
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
|
|
|
|
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
|
|
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
|
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
|
|
|
|
NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND
|
|
|
|
THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
|
|
|
|
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
|
|
|
|
GOVERNMENT USE: If you are acquiring this software on behalf of the
|
|
|
|
U.S. government, the Government shall have only "Restricted Rights" in
|
|
|
|
the software and related documentation as defined in the Federal
|
|
|
|
Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are
|
|
|
|
acquiring the software on behalf of the Department of Defense, the
|
|
|
|
software shall be classified as "Commercial Computer Software" and the
|
|
|
|
Government shall have only "Restricted Rights" as defined in Clause
|
|
|
|
252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the
|
|
|
|
authors grant the U.S. Government and others acting in its behalf
|
|
|
|
permission to use and distribute the software in accordance with the
|
|
|
|
terms specified in this license.
|
|
|
|
---*/
|
|
|
|
|
2004-07-31 00:27:55 +00:00
|
|
|
/**
|
|
|
|
|
|
|
|
@file
|
|
|
|
|
|
|
|
Generic page interface. This file handles updates to the LSN, but
|
|
|
|
leaves finer grained concurrency to the implementor of each of the
|
|
|
|
page types. This interface's primary purpose is to wrap common
|
|
|
|
functionality together, and to delegate responsibility for page
|
|
|
|
handling to other modules.
|
|
|
|
|
|
|
|
Latching summary:
|
|
|
|
|
|
|
|
Each page has an associated read/write lock. This lock only
|
|
|
|
protects the internal layout of the page, and the members of the
|
|
|
|
page struct. Here is how it is held in various circumstances:
|
|
|
|
|
|
|
|
Record allocation: Write lock
|
|
|
|
Record read: Read lock
|
|
|
|
Read LSN Read lock
|
|
|
|
Record write *READ LOCK*
|
|
|
|
Write LSN Write lock
|
|
|
|
|
|
|
|
Any circumstance where these locks are held during an I/O operation
|
|
|
|
is a bug.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-07-27 22:04:59 +00:00
|
|
|
/* _XOPEN_SOURCE is needed for posix_memalign */
|
|
|
|
#define _XOPEN_SOURCE 600
|
|
|
|
#include <stdlib.h>
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-13 23:48:20 +00:00
|
|
|
#include <config.h>
|
|
|
|
#include <lladd/common.h>
|
2004-07-20 00:15:17 +00:00
|
|
|
#include "latches.h"
|
2004-07-14 21:25:59 +00:00
|
|
|
#include "page.h"
|
2004-07-13 23:48:20 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <lladd/constants.h>
|
2004-07-21 02:13:28 +00:00
|
|
|
#include <assert.h>
|
2004-07-26 22:01:09 +00:00
|
|
|
#include "blobManager.h"
|
2005-02-10 03:51:09 +00:00
|
|
|
#include <lladd/lockManager.h>
|
2004-07-26 22:01:09 +00:00
|
|
|
#include "pageFile.h"
|
2005-02-14 02:49:59 +00:00
|
|
|
#include <lladd/compensations.h>
|
2004-07-30 01:28:39 +00:00
|
|
|
#include "page/slotted.h"
|
2004-10-06 06:08:09 +00:00
|
|
|
#include "page/fixed.h"
|
2004-07-30 01:28:39 +00:00
|
|
|
|
2004-07-13 23:48:20 +00:00
|
|
|
/* TODO: Combine with buffer size... */
|
|
|
|
static int nextPage = 0;
|
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
static int lastAllocedPage;
|
|
|
|
static pthread_mutex_t lastAllocedPage_mutex;
|
2004-07-27 21:30:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-07-13 23:48:20 +00:00
|
|
|
/* ------ */
|
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
static pthread_mutex_t pageMallocMutex;
|
2004-07-20 00:15:17 +00:00
|
|
|
/** We need one dummy page for locking purposes, so this array has one extra page in it. */
|
|
|
|
Page pool[MAX_BUFFER_SIZE+1];
|
2004-07-13 23:48:20 +00:00
|
|
|
|
2005-02-10 03:51:09 +00:00
|
|
|
void pageWriteLSN(int xid, Page * page, lsn_t lsn) {
|
2004-07-21 02:13:28 +00:00
|
|
|
/* unlocked since we're only called by a function that holds the writelock. */
|
2004-07-30 01:28:39 +00:00
|
|
|
/* *(long *)(page->memAddr + START_OF_LSN) = page->LSN; */
|
2005-02-14 02:49:59 +00:00
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
/* tr y {
|
|
|
|
if(globalLockM anager.writ eLockPage) {
|
|
|
|
globalLock Manager.writeL ockPage(xid, page->id);
|
2005-02-14 02:49:59 +00:00
|
|
|
}
|
2005-02-22 03:10:54 +00:00
|
|
|
} en d; */
|
2005-02-10 03:51:09 +00:00
|
|
|
|
2004-07-31 00:27:55 +00:00
|
|
|
if(page->LSN < lsn) {
|
|
|
|
page->LSN = lsn;
|
|
|
|
*lsn_ptr(page) = page->LSN;
|
|
|
|
}
|
2005-02-02 02:12:40 +00:00
|
|
|
page->dirty = 1;
|
2005-02-14 02:49:59 +00:00
|
|
|
return;
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
lsn_t pageReadLSN(const Page * page) {
|
|
|
|
lsn_t ret;
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
readlock(page->rwlatch, 259);
|
|
|
|
/* ret = *(long *)(page->memAddr + START_OF_LSN); */
|
|
|
|
ret = *lsn_ptr(page);
|
|
|
|
readunlock(page->rwlatch);
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
return ret;
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-23 20:21:44 +00:00
|
|
|
|
|
|
|
static void pageReallocNoLock(Page *p, int id) {
|
|
|
|
p->id = id;
|
|
|
|
p->LSN = 0;
|
|
|
|
p->dirty = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- end static functions ----- */
|
|
|
|
|
|
|
|
/* ----- (de)initialization functions. Do not need to support multithreading. -----*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* pageInit() initializes all the important variables needed in
|
|
|
|
* all the functions dealing with pages.
|
|
|
|
*/
|
|
|
|
void pageInit() {
|
|
|
|
|
|
|
|
nextPage = 0;
|
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
pthread_mutex_init(&pageMallocMutex, NULL);
|
2004-07-27 01:04:35 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
for(int i = 0; i < MAX_BUFFER_SIZE+1; i++) {
|
|
|
|
pool[i].rwlatch = initlock();
|
|
|
|
pool[i].loadlatch = initlock();
|
2005-01-24 19:58:09 +00:00
|
|
|
int ret = posix_memalign((void*)(&(pool[i].memAddr)), PAGE_SIZE, PAGE_SIZE);
|
|
|
|
|
|
|
|
assert(!ret);
|
2004-08-17 01:46:17 +00:00
|
|
|
}
|
|
|
|
pthread_mutex_init(&lastAllocedPage_mutex , NULL);
|
|
|
|
|
2004-08-21 00:03:30 +00:00
|
|
|
lastAllocedPage = 0;
|
2004-08-17 01:46:17 +00:00
|
|
|
slottedPageInit();
|
2004-07-27 21:30:54 +00:00
|
|
|
|
2004-07-27 01:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pageDeInit() {
|
|
|
|
for(int i = 0; i < MAX_BUFFER_SIZE+1; i++) {
|
|
|
|
deletelock(pool[i].rwlatch);
|
|
|
|
deletelock(pool[i].loadlatch);
|
2005-01-15 23:55:49 +00:00
|
|
|
free(pool[i].memAddr); // breaks efence
|
2004-07-27 01:04:35 +00:00
|
|
|
}
|
2004-08-17 01:46:17 +00:00
|
|
|
pthread_mutex_destroy(&lastAllocedPage_mutex);
|
2004-07-23 20:21:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pageCommit(int xid) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void pageAbort(int xid) {
|
|
|
|
}
|
2004-10-02 07:29:34 +00:00
|
|
|
/*
|
2004-08-21 00:03:30 +00:00
|
|
|
static int pageAllocUnlocked() {
|
2004-08-17 01:46:17 +00:00
|
|
|
int ret = lastAllocedPage;
|
|
|
|
Page * p;
|
|
|
|
|
|
|
|
lastAllocedPage += 1;
|
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
p = load Page(lastAllocedPage);
|
2004-10-02 07:29:34 +00:00
|
|
|
/ ** TODO Incorrect, but this kludge tricks the tests (for now) * /
|
2004-08-17 01:46:17 +00:00
|
|
|
while(*page_type_ptr(p) != UNINITIALIZED_PAGE) {
|
|
|
|
releasePage(p);
|
|
|
|
lastAllocedPage++;
|
2005-02-22 03:10:54 +00:00
|
|
|
p = load Page(lastAllocedPage);
|
2004-08-17 01:46:17 +00:00
|
|
|
}
|
|
|
|
releasePage(p);
|
|
|
|
|
|
|
|
return ret;
|
2004-10-02 07:29:34 +00:00
|
|
|
}*/
|
2004-08-17 01:46:17 +00:00
|
|
|
|
2004-08-03 02:04:56 +00:00
|
|
|
/**
|
|
|
|
@todo DATA CORRUPTION BUG pageAllocMultiple needs to scan forward in the store file until
|
|
|
|
it finds page(s) with type = UNINITIALIZED_PAGE. Otherwise, after recovery, it will trash the storefile.
|
2004-07-23 20:21:44 +00:00
|
|
|
|
2004-08-03 02:04:56 +00:00
|
|
|
A better way to implement this is probably to reserve the first
|
|
|
|
slot of the first page in the storefile for metadata, and to keep
|
|
|
|
lastFreepage there, instead of in RAM.
|
|
|
|
*/
|
2004-08-21 00:03:30 +00:00
|
|
|
/*int pageAlloc() {
|
2004-08-17 01:46:17 +00:00
|
|
|
pthread_mutex_lock(&lastAllocedPage_mutex);
|
|
|
|
int ret = pageAllocUnlocked();
|
|
|
|
pthread_mutex_unlock(&lastAllocedPage_mutex);
|
2004-07-27 21:30:54 +00:00
|
|
|
return ret;
|
2004-08-21 00:03:30 +00:00
|
|
|
}*/
|
2004-07-27 21:30:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2004-06-28 22:48:02 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
/** @todo Does pageRealloc really need to obtain a lock? */
|
2004-07-20 00:15:17 +00:00
|
|
|
void pageRealloc(Page *p, int id) {
|
|
|
|
writelock(p->rwlatch, 10);
|
|
|
|
pageReallocNoLock(p,id);
|
2004-07-13 23:48:20 +00:00
|
|
|
writeunlock(p->rwlatch);
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allocate a new page.
|
|
|
|
@return A pointer to the new page. This memory is part of a pool,
|
2004-08-17 01:46:17 +00:00
|
|
|
and should never be freed manually. Instead, you can
|
|
|
|
reclaim it with pageRealloc()
|
2004-06-24 21:10:31 +00:00
|
|
|
*/
|
2004-08-17 01:46:17 +00:00
|
|
|
Page *pageMalloc() {
|
2004-07-14 20:49:18 +00:00
|
|
|
Page *page;
|
2004-06-28 22:48:02 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
pthread_mutex_lock(&pageMallocMutex);
|
2004-07-13 23:48:20 +00:00
|
|
|
|
2004-07-14 20:49:18 +00:00
|
|
|
page = &(pool[nextPage]);
|
2004-07-13 23:48:20 +00:00
|
|
|
|
|
|
|
nextPage++;
|
2004-07-30 01:28:39 +00:00
|
|
|
/* There's a dummy page that we need to keep around, thus the +1 */
|
|
|
|
assert(nextPage <= MAX_BUFFER_SIZE + 1);
|
2004-07-13 23:48:20 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
pthread_mutex_unlock(&pageMallocMutex);
|
2004-07-13 23:48:20 +00:00
|
|
|
|
2004-07-14 20:49:18 +00:00
|
|
|
return page;
|
2004-06-24 21:10:31 +00:00
|
|
|
}
|
|
|
|
|
2004-08-21 00:03:30 +00:00
|
|
|
/*void setRecordType(Page * page, recordid rid, int slot_type) {
|
|
|
|
if(*page_type_ptr(page) == SLOTTED_PAGE) {
|
|
|
|
slottedSetType(page, rid.slot, slot_type);
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
|
2004-10-19 21:16:37 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
void writeRecord(int xid, Page * p, lsn_t lsn, recordid rid, const void *dat) {
|
2004-06-24 21:10:31 +00:00
|
|
|
|
2004-08-17 01:46:17 +00:00
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
2005-02-14 02:49:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* writelock(p->rwlatch, 225); // Need a writelock so that we can update the lsn.
|
|
|
|
int lock_ret = pageWriteLSN(xid, p, lsn);
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
if(lock_ret) {
|
|
|
|
return lock_ret;
|
|
|
|
} */
|
|
|
|
|
2005-02-22 03:10:54 +00:00
|
|
|
writelock(p->rwlatch, 225);
|
|
|
|
pageWriteLSN(xid, p, lsn);
|
|
|
|
unlock(p->rwlatch);
|
2004-08-17 01:46:17 +00:00
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
if(rid.size > BLOB_THRESHOLD_SIZE) {
|
|
|
|
writeBlob(xid, p, lsn, rid, dat);
|
2004-10-06 06:08:09 +00:00
|
|
|
} else if(*page_type_ptr(p) == SLOTTED_PAGE) {
|
2004-08-17 01:46:17 +00:00
|
|
|
slottedWrite(xid, p, lsn, rid, dat);
|
2004-10-27 01:40:09 +00:00
|
|
|
} else if(*page_type_ptr(p) == FIXED_PAGE || *page_type_ptr(p)==ARRAY_LIST_PAGE || !*page_type_ptr(p) ) {
|
2004-10-06 06:08:09 +00:00
|
|
|
fixedWrite(p, rid, dat);
|
|
|
|
} else {
|
|
|
|
abort();
|
2004-07-30 01:28:39 +00:00
|
|
|
}
|
2004-08-17 01:46:17 +00:00
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
2004-07-30 01:28:39 +00:00
|
|
|
|
|
|
|
}
|
2004-07-21 02:13:28 +00:00
|
|
|
|
2005-02-14 02:49:59 +00:00
|
|
|
int readRecord(int xid, Page * p, recordid rid, void *buf) {
|
2004-08-17 01:46:17 +00:00
|
|
|
assert(rid.page == p->id);
|
2004-10-06 06:08:09 +00:00
|
|
|
|
|
|
|
int page_type = *page_type_ptr(p);
|
|
|
|
|
2004-07-30 01:28:39 +00:00
|
|
|
if(rid.size > BLOB_THRESHOLD_SIZE) {
|
|
|
|
readBlob(xid, p, rid, buf);
|
2004-10-06 06:08:09 +00:00
|
|
|
} else if(page_type == SLOTTED_PAGE) {
|
2004-08-17 01:46:17 +00:00
|
|
|
slottedRead(xid, p, rid, buf);
|
2004-10-19 04:45:42 +00:00
|
|
|
/* FIXED_PAGES can function correctly even if they have not been
|
|
|
|
initialized. */
|
2004-10-27 01:40:09 +00:00
|
|
|
} else if(page_type == FIXED_PAGE || page_type==ARRAY_LIST_PAGE || !page_type) {
|
2004-10-06 06:08:09 +00:00
|
|
|
fixedRead(p, rid, buf);
|
|
|
|
} else {
|
|
|
|
abort();
|
2004-07-30 01:28:39 +00:00
|
|
|
}
|
2004-08-17 01:46:17 +00:00
|
|
|
assert(rid.page == p->id);
|
2005-02-14 02:49:59 +00:00
|
|
|
|
|
|
|
return 0;
|
2004-06-25 18:56:43 +00:00
|
|
|
}
|
2004-07-30 01:28:39 +00:00
|
|
|
|
2004-10-19 21:16:37 +00:00
|
|
|
|
2005-02-14 02:49:59 +00:00
|
|
|
int readRecordUnlocked(int xid, Page * p, recordid rid, void *buf) {
|
2004-10-19 21:16:37 +00:00
|
|
|
assert(rid.page == p->id);
|
|
|
|
|
|
|
|
int page_type = *page_type_ptr(p);
|
|
|
|
|
|
|
|
if(rid.size > BLOB_THRESHOLD_SIZE) {
|
|
|
|
abort(); /* Unsupported for now. */
|
|
|
|
readBlob(xid, p, rid, buf);
|
|
|
|
} else if(page_type == SLOTTED_PAGE) {
|
|
|
|
slottedReadUnlocked(xid, p, rid, buf);
|
|
|
|
/* FIXED_PAGES can function correctly even if they have not been
|
|
|
|
initialized. */
|
|
|
|
} else if(page_type == FIXED_PAGE || !page_type) {
|
|
|
|
fixedReadUnlocked(p, rid, buf);
|
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
assert(rid.page == p->id);
|
2004-11-24 23:25:36 +00:00
|
|
|
|
2005-02-14 02:49:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2004-11-24 23:25:36 +00:00
|
|
|
|
|
|
|
int getRecordTypeUnlocked(int xid, Page * p, recordid rid) {
|
2005-01-28 03:32:17 +00:00
|
|
|
assert(rid.page == p->id);
|
|
|
|
|
|
|
|
int page_type = *page_type_ptr(p);
|
|
|
|
if(page_type == UNINITIALIZED_PAGE) {
|
|
|
|
return UNINITIALIZED_RECORD;
|
|
|
|
|
|
|
|
} else if(page_type == SLOTTED_PAGE) {
|
2005-01-28 21:28:23 +00:00
|
|
|
if(*numslots_ptr(p) <= rid.slot || *slot_ptr(p, rid.slot) == INVALID_SLOT /*|| *slot_length_ptr(p, rid.slot) == INVALID_SLOT*/) {
|
2005-01-28 03:32:17 +00:00
|
|
|
return UNINITIALIZED_PAGE;
|
2005-01-31 01:29:52 +00:00
|
|
|
// } else if(*slot_length_ptr(p, rid.slot) == BLOB_REC_SIZE) {
|
|
|
|
} else if (*slot_length_ptr(p, rid.slot) == BLOB_SLOT) {
|
2005-01-28 03:32:17 +00:00
|
|
|
return BLOB_RECORD;
|
|
|
|
} else {
|
|
|
|
return SLOTTED_RECORD;
|
|
|
|
}
|
|
|
|
} else if(page_type == FIXED_PAGE || page_type == ARRAY_LIST_PAGE) {
|
|
|
|
return (fixedPageCount(p) > rid.slot) ?
|
|
|
|
FIXED_RECORD : UNINITIALIZED_RECORD;
|
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
return UNINITIALIZED_RECORD;
|
|
|
|
}
|
2004-11-24 23:25:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int getRecordType(int xid, Page * p, recordid rid) {
|
|
|
|
readlock(p->rwlatch, 343);
|
|
|
|
int ret = getRecordTypeUnlocked(xid, p, rid);
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
return ret;
|
|
|
|
}
|
2005-02-14 02:49:59 +00:00
|
|
|
/** @todo implement getRecordLength for blobs and fixed length pages. */
|
2005-01-28 03:32:17 +00:00
|
|
|
int getRecordSize(int xid, Page * p, recordid rid) {
|
|
|
|
readlock(p->rwlatch, 353);
|
|
|
|
int ret = getRecordTypeUnlocked(xid, p, rid);
|
|
|
|
if(ret == UNINITIALIZED_RECORD) {
|
|
|
|
ret = -1;
|
|
|
|
} else if(ret == SLOTTED_RECORD) {
|
|
|
|
ret = *slot_length_ptr(p, rid.slot);
|
|
|
|
} else {
|
|
|
|
abort(); // unimplemented for fixed length pages and blobs.
|
|
|
|
}
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
return ret;
|
|
|
|
}
|
2004-10-19 21:16:37 +00:00
|
|
|
|
|
|
|
void writeRecordUnlocked(int xid, Page * p, lsn_t lsn, recordid rid, const void *dat) {
|
|
|
|
|
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
2005-02-14 02:49:59 +00:00
|
|
|
|
|
|
|
/* writelock(p->rwlatch, 225); // Need a writelock so that we can update the lsn.
|
|
|
|
int lock_error = pageWriteLSN(xid, p, lsn);
|
|
|
|
if(lock_error) {
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
return lock_error;
|
|
|
|
}
|
|
|
|
unlock(p->rwlatch); */
|
|
|
|
|
|
|
|
|
|
|
|
// Need a writelock so that we can update the lsn.
|
2005-02-22 03:10:54 +00:00
|
|
|
|
|
|
|
writelock(p->rwlatch, 225);
|
|
|
|
pageWriteLSN(xid, p, lsn);
|
|
|
|
unlock(p->rwlatch);
|
|
|
|
|
2005-02-14 02:49:59 +00:00
|
|
|
|
2004-10-19 21:16:37 +00:00
|
|
|
if(rid.size > BLOB_THRESHOLD_SIZE) {
|
|
|
|
abort();
|
|
|
|
writeBlob(xid, p, lsn, rid, dat);
|
|
|
|
} else if(*page_type_ptr(p) == SLOTTED_PAGE) {
|
|
|
|
slottedWriteUnlocked(xid, p, lsn, rid, dat);
|
2004-10-27 01:40:09 +00:00
|
|
|
} else if(*page_type_ptr(p) == FIXED_PAGE || *page_type_ptr(p)==ARRAY_LIST_PAGE || !*page_type_ptr(p) ) {
|
2004-10-19 21:16:37 +00:00
|
|
|
fixedWriteUnlocked(p, rid, dat);
|
|
|
|
} else {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
assert( (p->id == rid.page) && (p->memAddr != NULL) );
|
|
|
|
|
|
|
|
|
|
|
|
}
|