From 0996fe5e7add1013304559c922a7d112d8594330 Mon Sep 17 00:00:00 2001 From: kishoramballi Date: Tue, 30 Mar 2010 14:26:55 +0000 Subject: [PATCH] Varchar free when compact table was called. --- src/sql/UpdStatement.cxx | 6 ++- src/storage/Chunk.cxx | 93 ++++++++++++++++++++++------------------------- src/storage/TableImpl.cxx | 6 +-- 3 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/sql/UpdStatement.cxx b/src/sql/UpdStatement.cxx index 56585ae5..662a8b9a 100644 --- a/src/sql/UpdStatement.cxx +++ b/src/sql/UpdStatement.cxx @@ -500,7 +500,11 @@ DbRetVal UpdStatement::resolveForAssignment() } if (value->parsedString == NULL) { - if (fInfo->isNull) { delete fInfo; return ErrNullViolation; } + if (fInfo->isNull) { + delete fInfo; + printError(ErrNullViolation, "Null Violation Error."); + return ErrNullViolation; + } table->markFldNull(value->fldName); memset(value->value, 0, value->length); continue; diff --git a/src/storage/Chunk.cxx b/src/storage/Chunk.cxx index 23c163b2..3eff1131 100644 --- a/src/storage/Chunk.cxx +++ b/src/storage/Chunk.cxx @@ -851,62 +851,57 @@ int Chunk::compact(int procSlot) { PageInfo* pageInfo = ((PageInfo*)firstPage_); PageInfo* prevPage = pageInfo; - if (NULL == pageInfo) - { - return 0; - } + if (NULL == pageInfo) return 0; int ret = getChunkMutex(procSlot); - if (ret != 0) - { + if (ret != 0) { printError(ErrLockTimeOut,"Unable to acquire chunk Mutex"); return ret; } pageInfo = (PageInfo*)pageInfo->nextPage_; - if (0 == allocSize_) - { - while( pageInfo != NULL ) - { - bool flag = false; - VarSizeInfo *varInfo = (VarSizeInfo*)(((char*)pageInfo) + - sizeof(PageInfo)); - while ((char*) varInfo < ((char*)pageInfo + PAGE_SIZE)) - { - if (1 == varInfo->isUsed_) {flag=true; break;} - varInfo = (VarSizeInfo*)((char*)varInfo + sizeof(VarSizeInfo) - +varInfo->size_); - } - if (!flag) { - printDebug(DM_VarAlloc,"Freeing unused page in varsize allocator %x\n", pageInfo); - prevPage->nextPage_ = pageInfo->nextPage_; - pageInfo->isUsed_ = 0; - } - prevPage = pageInfo; - pageInfo = (PageInfo*)(((PageInfo*)pageInfo)->nextPage_) ; - printDebug(DM_VarAlloc,"compact iter %x\n", pageInfo); - } - }else if (allocSize_ < PAGE_SIZE) - { - while( pageInfo != NULL ) - { - bool flag = false; - int noOfDataNodes=(int) os::floor((PAGE_SIZE - sizeof(PageInfo))/allocSize_); - char *data = ((char*)pageInfo) + sizeof(PageInfo); - for (int i = 0; i< noOfDataNodes ; i++) - { - if (1 == *((InUse*)data)) { flag = true; break; } - data = data +allocSize_; + if (0 == allocSize_) { + while( pageInfo != NULL ) { + bool flag = false; + VarSizeInfo *varInfo = (VarSizeInfo*)(((char*)pageInfo) + + sizeof(PageInfo)); + while ((char*) varInfo < ((char*)pageInfo + PAGE_SIZE)) { + if (1 == varInfo->isUsed_) {flag=true; break;} + varInfo = (VarSizeInfo*)((char*)varInfo + sizeof(VarSizeInfo) + +varInfo->size_); + } + if (!flag) { + printDebug(DM_VarAlloc, + "Freeing unused page in varsize allocator %x\n", pageInfo); + prevPage->nextPage_ = pageInfo->nextPage_; + pageInfo->isUsed_ = 0; + pageInfo = (PageInfo*)(((PageInfo*)prevPage)->nextPage_); + } else { + prevPage = pageInfo; + pageInfo = (PageInfo*)(((PageInfo*)pageInfo)->nextPage_); + } + printDebug(DM_VarAlloc,"compact iter %x\n", pageInfo); } - if (!flag) { - printDebug(DM_Alloc,"Freeing unused page in fixed allocator %x\n", pageInfo); - prevPage->nextPage_ = pageInfo->nextPage_; - pageInfo->isUsed_ = 0; - pageInfo = (PageInfo*)(((PageInfo*)prevPage)->nextPage_) ; - }else{ - prevPage = pageInfo; - pageInfo = (PageInfo*)(((PageInfo*)pageInfo)->nextPage_) ; + } else if (allocSize_ < PAGE_SIZE) { + while( pageInfo != NULL ) { + bool flag = false; + int noOfDataNodes=(int) + os::floor((PAGE_SIZE - sizeof(PageInfo))/allocSize_); + char *data = ((char*)pageInfo) + sizeof(PageInfo); + for (int i = 0; i< noOfDataNodes ; i++) { + if (1 == *((InUse*)data)) { flag = true; break; } + data = data +allocSize_; + } + if (!flag) { + printDebug(DM_Alloc, + "Freeing unused page in fixed allocator %x\n", pageInfo); + prevPage->nextPage_ = pageInfo->nextPage_; + pageInfo->isUsed_ = 0; + pageInfo = (PageInfo*)(((PageInfo*)prevPage)->nextPage_); + } else { + prevPage = pageInfo; + pageInfo = (PageInfo*)(((PageInfo*)pageInfo)->nextPage_) ; + } + printDebug(DM_Alloc,"compact iter %x\n", pageInfo); } - printDebug(DM_Alloc,"compact iter %x\n", pageInfo); - } } releaseChunkMutex(procSlot); return 0; diff --git a/src/storage/TableImpl.cxx b/src/storage/TableImpl.cxx index ba30a220..9c082775 100644 --- a/src/storage/TableImpl.cxx +++ b/src/storage/TableImpl.cxx @@ -2013,9 +2013,9 @@ DbRetVal TableImpl::compact() { DbRetVal rv=OK; int ret =((Chunk*)chunkPtr_)->compact(db_->procSlot); - if(ret!=0){ - return ErrLockTimeOut; - } + if(ret!=0) return ErrLockTimeOut; + ret = ((Chunk*)vcChunkPtr_)->compact(db_->procSlot); + if(ret!=0) return ErrLockTimeOut; if (NULL != indexPtr_) { int i; -- 2.11.4.GIT