From 7dada65a1339d023a68866d2abb5bb24b661436c Mon Sep 17 00:00:00 2001 From: Sears Russell Date: Fri, 11 Aug 2006 02:24:01 +0000 Subject: [PATCH] Addded "interpretRid" which knows how to call the "dereference*" functions. --- src/lladd/page.c | 30 ++++++++++++++++++++++++++ src/lladd/page.h | 3 +++ src/lladd/transactional2.c | 44 ++++++-------------------------------- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/src/lladd/page.c b/src/lladd/page.c index 84f9e2a..f613aff 100644 --- a/src/lladd/page.c +++ b/src/lladd/page.c @@ -88,6 +88,8 @@ terms specified in this license. #include #include "page/slotted.h" #include "page/fixed.h" +#include "page/indirect.h" +#include #include #include void pageWriteLSN(int xid, Page * page, lsn_t lsn) { @@ -263,3 +265,31 @@ void writeRecordUnlocked(int xid, Page * p, lsn_t lsn, recordid rid, const void } + +recordid interpretRidUnlocked(int xid, recordid rid, Page * p) { + int page_type = *page_type_ptr(p); + if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) { + + } else if(page_type == INDIRECT_PAGE) { + rid = dereferenceRIDUnlocked(xid, rid); + } else if(page_type == ARRAY_LIST_PAGE) { + rid = dereferenceArrayListRidUnlocked(p, rid.slot); + } else { + abort(); + } + return rid; +} +recordid interpretRid(int xid, recordid rid, Page * p) { + int page_type = *page_type_ptr(p); + if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) { + + } else if(page_type == INDIRECT_PAGE) { + rid = dereferenceRID(xid, rid); + } else if(page_type == ARRAY_LIST_PAGE) { + rid = dereferenceArrayListRid(p, rid.slot); + } else { + abort(); + } + return rid; +} + diff --git a/src/lladd/page.h b/src/lladd/page.h index 3c5be85..a56a286 100644 --- a/src/lladd/page.h +++ b/src/lladd/page.h @@ -278,6 +278,9 @@ int getRecordTypeUnlocked(int xid, Page * p, recordid rid); */ int getRecordLength(int xid, Page * p, recordid rid); +recordid interpretRid(int xid, recordid rid, Page * p); +recordid interpretRidUnlocked(int xid, recordid rid, Page * p); + END_C_DECLS #endif diff --git a/src/lladd/transactional2.c b/src/lladd/transactional2.c index 68a87be..7220158 100644 --- a/src/lladd/transactional2.c +++ b/src/lladd/transactional2.c @@ -214,7 +214,7 @@ compensated_function void Tupdate(int xid, recordid rid, const void *dat, int op rid = dereferenceRID(xid, rid); p = loadPage(xid, rid.page); } end; - /** @todo Kludge! Shouldn't special case operations in transactional2. */ + // @todo Kludge! Shouldn't special case operations in transactional2. } else if(*page_type_ptr(p) == ARRAY_LIST_PAGE && op != OPERATION_LINEAR_INSERT && op != OPERATION_UNDO_LINEAR_INSERT && @@ -240,25 +240,11 @@ void TreadUnlocked(int xid, recordid rid, void * dat) { try { p = loadPage(xid, rid.page); } end; - int page_type = *page_type_ptr(p); - if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) { - } else if(page_type == INDIRECT_PAGE) { + rid = interpretRidUnlocked(xid, rid, p); + if(rid.page != p->id) { releasePage(p); - - try { - rid = dereferenceRIDUnlocked(xid, rid); - p = loadPage(xid, rid.page); - } end; - } else if(page_type == ARRAY_LIST_PAGE) { - rid = dereferenceArrayListRidUnlocked(p, rid.slot); - releasePage(p); - try { - p = loadPage(xid, rid.page); - } end; - - } else { - abort(); + p = loadPage(xid, rid.page); } readRecordUnlocked(xid, p, rid, dat); releasePage(p); @@ -269,27 +255,11 @@ compensated_function void Tread(int xid, recordid rid, void * dat) { try { p = loadPage(xid, rid.page); } end; - int page_type = *page_type_ptr(p); - if(page_type == SLOTTED_PAGE || page_type == FIXED_PAGE || (!page_type) || page_type == BOUNDARY_TAG_PAGE ) { - } else if(page_type == INDIRECT_PAGE) { + rid = interpretRid(xid, rid, p); + if(rid.page != p->id) { releasePage(p); - try { - rid = dereferenceRID(xid, rid); - } end; - try { - p = loadPage(xid, rid.page); - } end; - - } else if(page_type == ARRAY_LIST_PAGE) { - rid = dereferenceArrayListRid(p, rid.slot); - releasePage(p); - try { - p = loadPage(xid, rid.page); - } end; - - } else { - abort(); + p = loadPage(xid, rid.page); } readRecord(xid, p, rid, dat); releasePage(p);