1501526 Composite primary keys
[csql.git] / src / server / TableImpl.cxx
blob5d7d98e50ca66fe09ae1c4afc53000768529f99e
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #include<Index.h>
17 #include<CatalogTables.h>
18 #include<Lock.h>
19 #include<Debug.h>
20 #include<Table.h>
21 #include<TableImpl.h>
22 #include<Predicate.h>
23 #include<PredicateImpl.h>
24 #include<Index.h>
25 #include<Config.h>
27 DbRetVal TableImpl::bindFld(const char *name, void *val)
29 //set it in the field list
30 DbRetVal rv = fldList_.updateBindVal(name, val);
31 if (OK != rv) {
32 printError(ErrNotExists, "Field %s does not exist", name);
33 return rv;
35 return OK;
38 bool TableImpl::isFldNull(const char *name){
39 int colpos = fldList_.getFieldPosition(name);
40 if (-1 == colpos)
42 printError(ErrNotExists, "Field %s does not exist", name);
43 return false;
46 return isFldNull(colpos);
49 bool TableImpl::isFldNull(int colpos)
51 if (!curTuple_) return false;
52 if (colpos <1 || colpos > numFlds_) return false;
53 char *nullOffset = (char*)curTuple_ - 4;
54 if (isIntUsedForNULL) {
55 int nullVal = *(int*)((char*)curTuple_ + (length_ - 4));
56 if (BITSET(nullVal, colpos)) return true;
58 else {
59 char *nullOffset = (char*)curTuple_ - os::align(numFlds_);
60 if (nullOffset[colpos-1]) return true;
62 return false;
64 void TableImpl::markFldNull(char const* name)
66 int colpos = fldList_.getFieldPosition(name);
67 if (-1 == colpos)
69 printError(ErrNotExists, "Field %s does not exist", name);
70 return;
72 markFldNull(colpos);
75 void TableImpl::markFldNull(int fldpos)
77 if (fldpos <1 || fldpos > numFlds_) return;
78 if (isIntUsedForNULL) {
79 if (!BITSET(iNotNullInfo, fldpos)) SETBIT(iNullInfo, fldpos);
81 else
82 if (!BITSET(iNotNullInfo, fldpos)) cNullInfo[fldpos-1] = 1;
83 return;
86 void TableImpl::clearFldNull(const char *name)
88 int colpos = fldList_.getFieldPosition(name);
89 if (-1 == colpos)
91 printError(ErrNotExists, "Field %s does not exist", name);
92 return;
95 clearFldNull(colpos);
98 void TableImpl::clearFldNull(int colpos)
100 if (colpos <1 || colpos > numFlds_) return;
101 if (isIntUsedForNULL) {
102 CLEARBIT(iNullInfo, colpos);
104 else
105 cNullInfo[colpos-1] = 0;
106 return;
110 DbRetVal TableImpl::execute()
112 if (NULL != iter)
114 printError(ErrAlready,"Scan already open:Close and re execute");
115 return ErrAlready;
117 //table ptr is set in predicate because it needs to access the
118 //type and length to evaluate
119 if( NULL != pred_)
121 PredicateImpl *pred = (PredicateImpl*) pred_;
122 pred->setTable(this);
124 DbRetVal ret = OK;
126 ret = createPlan();
127 if (OK != ret)
129 printError(ErrSysInternal,"Unable to create the plan");
130 return ErrSysInternal;
132 if (useIndex_ >= 0)
133 iter = new TupleIterator(pred_, scanType_, idxInfo[useIndex_], chunkPtr_, sysDB_->procSlot);
134 else if (scanType_ == fullTableScan)
135 iter = new TupleIterator(pred_, scanType_, NULL, chunkPtr_, sysDB_->procSlot);
136 else
138 printError(ErrSysFatal,"Unable to create tuple iterator");//should never happen
139 return ErrSysFatal;
141 ret = iter->open();
142 if (OK != ret)
144 printError(ret,"Unable to open the iterator");
145 return ret;
147 return OK;
151 DbRetVal TableImpl::createPlan()
153 if (isPlanCreated) {
154 //will do early return here. plan is generated only when setPredicate is called.
155 if (scanType_ == unknownScan) return ErrSysFatal; //this should never happen
156 else return OK;
158 useIndex_ = -1;
159 //if there are no predicates then go for full scan
160 //if there are no indexes then go for full scan
161 if (NULL == pred_ || NULL == indexPtr_)
163 scanType_ = fullTableScan;
164 isPlanCreated = true;
165 return OK;
167 if (NULL != indexPtr_)
169 PredicateImpl *pred = (PredicateImpl*)pred_;
170 printDebug(DM_Predicate, "predicate does not involve NOT , OR operator");
171 if (!pred->isNotOrInvolved())
173 printDebug(DM_Predicate, "predicate does not involve NOT , OR operator");
174 for (int i =0; i < numIndexes_; i++)
176 HashIndexInfo* info = (HashIndexInfo*) idxInfo[i];
177 FieldIterator iter = info->idxFldList.getIterator();
178 while(iter.hasElement())
180 FieldDef def = iter.nextElement();
181 if (pred->pointLookupInvolved(def.fldName_))
183 printDebug(DM_Predicate, "point lookup involved for field %s",def.fldName_);
184 scanType_ = hashIndexScan;
185 isPlanCreated = true;
186 useIndex_ = i;
188 else
190 useIndex_ = -1;
191 break;
193 }//while iter.hasElement()
194 if (useIndex_ != -1) return OK;
195 }//for
198 scanType_ = fullTableScan;
199 isPlanCreated = true;
200 return OK;
203 void* TableImpl::fetch()
205 fetchNoBind();
206 if (NULL == curTuple_) return curTuple_;
207 copyValuesToBindBuffer(curTuple_);
208 return curTuple_;
210 void* TableImpl::fetch(DbRetVal &rv)
212 fetchNoBind(rv);
213 if (NULL == curTuple_) return curTuple_;
214 copyValuesToBindBuffer(curTuple_);
215 return curTuple_;
218 void* TableImpl::fetchNoBind()
220 if (NULL == iter)
222 printError(ErrNotOpen,"Scan not open or Scan is closed\n");
223 return NULL;
225 void *prevTuple = curTuple_;
226 curTuple_ = iter->next();
227 if (NULL == curTuple_)
229 return NULL;
231 DbRetVal lockRet = OK;
232 if ((*trans)->isoLevel_ == READ_REPEATABLE) {
233 lockRet = lMgr_->getSharedLock(curTuple_, trans);
234 if (OK != lockRet)
236 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
237 curTuple_ = prevTuple;
238 return NULL;
242 else if ((*trans)->isoLevel_ == READ_COMMITTED)
244 //if iso level is read committed, operation duration lock is sufficent
245 //so release it here itself.
246 int tries = 5;
247 struct timeval timeout;
248 timeout.tv_sec = Conf::config.getMutexSecs();
249 timeout.tv_usec = Conf::config.getMutexUSecs();
251 bool status = false;
252 while(true) {
253 lockRet = lMgr_->isExclusiveLocked( curTuple_, trans, status);
254 if (OK != lockRet)
256 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
257 curTuple_ = prevTuple;
258 return NULL;
260 if (!status) break;
261 tries--;
262 if (tries == 0) break;
263 os::select(0, 0, 0, 0, &timeout);
266 if (tries == 0)
268 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
269 curTuple_ = prevTuple;
270 return NULL;
273 return curTuple_;
276 void* TableImpl::fetchNoBind(DbRetVal &rv)
278 rv = OK;
279 if (NULL == iter)
281 printError(ErrNotOpen,"Scan not open or Scan is closed\n");
282 rv = ErrNotOpen;
283 return NULL;
285 void *prevTuple = curTuple_;
286 curTuple_ = iter->next();
287 if (NULL == curTuple_)
289 return NULL;
291 DbRetVal lockRet = OK;
292 if ((*trans)->isoLevel_ == READ_REPEATABLE) {
293 lockRet = lMgr_->getSharedLock(curTuple_, trans);
294 if (OK != lockRet)
296 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
297 rv = ErrLockTimeOut;
298 curTuple_ = prevTuple;
299 return NULL;
303 else if ((*trans)->isoLevel_ == READ_COMMITTED)
305 //if iso level is read committed, operation duration lock is sufficent
306 //so release it here itself.
307 int tries = 5;
308 struct timeval timeout;
309 timeout.tv_sec = Conf::config.getMutexSecs();
310 timeout.tv_usec = Conf::config.getMutexUSecs();
312 bool status = false;
313 while(true) {
314 lockRet = lMgr_->isExclusiveLocked( curTuple_, trans, status);
315 if (OK != lockRet)
317 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
318 curTuple_ = prevTuple;
319 rv = ErrLockTimeOut;
320 return NULL;
322 if (!status) break;
323 tries--;
324 if (tries == 0) break;
325 os::select(0, 0, 0, 0, &timeout);
328 if (tries == 0)
330 printError(lockRet, "Unable to get the lock for the tuple %x", curTuple_);
331 curTuple_ = prevTuple;
332 rv = ErrLockTimeOut;
333 return NULL;
336 return curTuple_;
339 DbRetVal TableImpl::insertTuple()
341 DbRetVal ret =OK;
342 void *tptr = ((Chunk*)chunkPtr_)->allocate(db_, &ret);
343 if (NULL == tptr)
345 printError(ret, "Unable to allocate record from chunk");
346 return ret;
348 ret = lMgr_->getExclusiveLock(tptr, trans);
349 if (OK != ret)
351 ((Chunk*)chunkPtr_)->free(db_, tptr);
352 printError(ret, "Could not get lock for the insert tuple %x", tptr);
353 return ErrLockTimeOut;
357 ret = copyValuesFromBindBuffer(tptr);
358 if (ret != OK)
360 printError(ret, "Unable to copy values from bind buffer");
361 (*trans)->removeFromHasList(db_, tptr);
362 lMgr_->releaseLock(tptr);
363 ((Chunk*)chunkPtr_)->free(db_, tptr);
364 return ret;
367 int addSize = 0;
368 if (numFlds_ < 31)
370 addSize = 4;
371 *(int*)((char*)(tptr) + (length_-addSize)) = iNullInfo;
373 else
375 addSize = os::align(numFlds_);
376 os::memcpy(((char*)(tptr) + (length_-addSize)), cNullInfo, addSize);
379 //int tupleSize = length_ + addSize;
380 if (NULL != indexPtr_)
382 int i;
383 //it has index
384 for (i = 0; i < numIndexes_ ; i++)
386 ret = insertIndexNode(*trans, indexPtr_[i], idxInfo[i], tptr);
387 if (ret != OK) { printError(ret, "Error in inserting to index"); break;}
389 if (i != numIndexes_ )
391 for (int j = 0; j < i ; j++) {
392 printError(ErrWarning, "Deleting index node");
393 deleteIndexNode(*trans, indexPtr_[j], idxInfo[j], tptr);
395 lMgr_->releaseLock(tptr);
396 (*trans)->removeFromHasList(db_, tptr);
397 ((Chunk*)chunkPtr_)->free(db_, tptr);
398 printError(ret, "Unable to insert index node for tuple %x", tptr);
399 return ret;
402 if (undoFlag)
403 ret = (*trans)->appendUndoLog(sysDB_, InsertOperation, tptr, length_);
404 return ret;
407 DbRetVal TableImpl::deleteTuple()
409 if (NULL == curTuple_)
411 printError(ErrNotOpen, "Scan not open: No Current tuple");
412 return ErrNotOpen;
414 DbRetVal ret = lMgr_->getExclusiveLock(curTuple_, trans);
415 if (OK != ret)
417 printError(ret, "Could not get lock for the delete tuple %x", curTuple_);
418 return ErrLockTimeOut;
421 if (NULL != indexPtr_)
423 int i;
424 //it has index
425 for (i = 0; i < numIndexes_ ; i++)
427 ret = deleteIndexNode(*trans, indexPtr_[i], idxInfo[i], curTuple_);
428 if (ret != OK) break;
430 if (i != numIndexes_ )
432 for (int j = 0; j < i ; j++)
433 insertIndexNode(*trans, indexPtr_[j], idxInfo[j], curTuple_);
434 lMgr_->releaseLock(curTuple_);
435 (*trans)->removeFromHasList(db_, curTuple_);
436 printError(ret, "Unable to insert index node for tuple %x", curTuple_);
437 return ret;
440 ((Chunk*)chunkPtr_)->free(db_, curTuple_);
441 if (undoFlag)
442 ret = (*trans)->appendUndoLog(sysDB_, DeleteOperation, curTuple_, length_);
443 return ret;
446 int TableImpl::deleteWhere()
448 int tuplesDeleted = 0;
449 DbRetVal rv = OK;
450 rv = execute();
451 if (rv !=OK) return (int) rv;
452 while(true){
453 fetchNoBind( rv);
454 if (rv != OK) { tuplesDeleted = (int)rv; break; }
455 if (NULL == curTuple_) break;
456 rv = deleteTuple();
457 if (rv != OK) {
458 printError(rv, "Error: Could only delete %d tuples", tuplesDeleted);
459 close();
460 return (int) rv;
462 tuplesDeleted++;
464 close();
465 return tuplesDeleted;
468 int TableImpl::truncate()
470 //take exclusive lock on the table
471 //get the chunk ptr of the table
472 //traverse the tablechunks and free all the pages except the first one
473 //get the chunk ptr of all its indexes
474 //traverse the indexchunks and free all the pages except the first one
475 //release table lock
477 //TEMPORARY FIX
478 DbRetVal rv = OK;
479 Predicate* tmpPred = pred_;
480 pred_ = NULL;
481 isPlanCreated = false;
482 int tuplesDeleted = deleteWhere();
483 isPlanCreated = false;
484 pred_ = tmpPred;
485 return tuplesDeleted;
488 DbRetVal TableImpl::updateTuple()
490 if (NULL == curTuple_)
492 printError(ErrNotOpen, "Scan not open: No Current tuple");
493 return ErrNotOpen;
495 DbRetVal ret = lMgr_->getExclusiveLock(curTuple_, trans);
496 if (OK != ret)
498 printError(ret, "Could not get lock for the update tuple %x", curTuple_);
499 return ErrLockTimeOut;
501 if (NULL != indexPtr_)
503 //it has index
504 //TODO::If it fails while updating index node, we have to undo all the updates
505 //on other indexes on the table.Currently it will leave the database in an
506 //inconsistent state.
507 for (int i = 0; i < numIndexes_ ; i++)
509 ret = updateIndexNode(*trans, indexPtr_[i], idxInfo[i], curTuple_);
510 if (ret != OK)
512 lMgr_->releaseLock(curTuple_);
513 (*trans)->removeFromHasList(db_, curTuple_);
514 printError(ret, "Unable to update index node for tuple %x", curTuple_);
515 return ret;
519 if (undoFlag)
520 ret = (*trans)->appendUndoLog(sysDB_, UpdateOperation, curTuple_, length_);
521 if (ret != OK) return ret;
522 int addSize = 0;
523 if (numFlds_ < 31)
525 addSize = 4;
526 *(int*)((char*)(curTuple_) + (length_-addSize)) |= iNullInfo;
528 else
530 addSize = os::align(numFlds_);
531 //TODO::Do not do blind memcpy. It should OR each and every char
532 //os::memcpy(((char*)(curTuple_) + (length_-addSize)), cNullInfo, addSize);
536 DbRetVal rv = copyValuesFromBindBuffer(curTuple_, false);
537 if (rv != OK) {
538 lMgr_->releaseLock(curTuple_);
539 (*trans)->removeFromHasList(db_, curTuple_);
540 return rv;
542 return OK;
545 void TableImpl::printInfo()
547 printf(" <TableName> %s </TableName>\n", tblName_);
548 printf(" <TupleCount> %d </TupleCount>\n", numTuples());
549 printf(" <PagesUsed> %d </PagesUsed>\n", pagesUsed());
550 printf(" <SpaceUsed> %d </SpaceUsed>\n", spaceUsed());
551 printf(" <Indexes> %d <Indexes>\n", numIndexes_);
552 printf(" <TupleLength> %d </TupleLength>\n", length_);
553 printf(" <Fields> %d </Fields>\n", numFlds_);
554 printf(" <Indexes>\n");
555 for (int i =0; i<numIndexes_; i++)
556 printf("<IndexName> %s </IndexName>\n", CatalogTableINDEX::getName(indexPtr_[i]));
557 printf(" </Indexes>\n");
561 DbRetVal TableImpl::copyValuesFromBindBuffer(void *tuplePtr, bool isInsert)
563 //Iterate through the bind list and copy the value here
564 FieldIterator fIter = fldList_.getIterator();
565 char *colPtr = (char*) tuplePtr;
566 int fldpos=1;
567 while (fIter.hasElement())
569 FieldDef def = fIter.nextElement();
570 if (def.isNull_ && !def.isDefault_ && NULL == def.bindVal_ && isInsert)
572 printError(ErrNullViolation, "NOT NULL constraint violation for field %s\n", def.fldName_);
573 return ErrNullViolation;
575 if (def.isDefault_ && NULL == def.bindVal_ && isInsert)
577 void *dest = AllDataType::alloc(def.type_, def.length_);
578 AllDataType::convert(typeString, def.defaultValueBuf_, def.type_, dest);
579 AllDataType::copyVal(colPtr, dest, def.type_, def.length_);
580 colPtr = colPtr + os::align(AllDataType::size(def.type_, def.length_));
581 fldpos++;
582 free (dest);
583 continue;
585 switch(def.type_)
587 case typeString:
588 if (NULL != def.bindVal_)
590 strcpy((char*)colPtr, (char*)def.bindVal_);
591 *(((char*)colPtr) + (def.length_-1)) = '\0';
593 else if (!def.isNull_ && isInsert) setNullBit(fldpos);
594 colPtr = colPtr + os::align(def.length_);
595 break;
596 case typeBinary:
597 if (NULL != def.bindVal_ )
598 os::memcpy((char*)colPtr, (char*)def.bindVal_, def.length_);
599 else if (!def.isNull_ && isInsert) setNullBit(fldpos);
600 colPtr = colPtr + os::align(def.length_);
601 break;
602 default:
603 if (NULL != def.bindVal_)
604 AllDataType::copyVal(colPtr, def.bindVal_, def.type_);
605 else { if (!def.isNull_ && isInsert) setNullBit(fldpos); }
606 colPtr = colPtr + os::align(AllDataType::size(def.type_));
607 break;
609 fldpos++;
611 return OK;
613 void TableImpl::setNullBit(int fldpos)
615 if (isIntUsedForNULL)
616 SETBIT(iNullInfo, fldpos);
617 else
618 cNullInfo[fldpos-1] = 1;
620 DbRetVal TableImpl::copyValuesToBindBuffer(void *tuplePtr)
622 //Iterate through the bind list and copy the value here
623 FieldIterator fIter = fldList_.getIterator();
624 char *colPtr = (char*) tuplePtr;
625 while (fIter.hasElement())
627 FieldDef def = fIter.nextElement();
628 switch(def.type_)
630 case typeString:
631 if (NULL != def.bindVal_)
632 strcpy((char*)def.bindVal_, (char*)colPtr);
633 colPtr = colPtr + os::align(def.length_);
634 break;
635 case typeBinary:
636 if (NULL != def.bindVal_)
637 os::memcpy((char*)def.bindVal_, (char*)colPtr, def.length_);
638 colPtr = colPtr + os::align(def.length_);
639 break;
640 default:
641 if (NULL != def.bindVal_)
642 AllDataType::copyVal(def.bindVal_, colPtr, def.type_);
643 colPtr = colPtr + os::align(AllDataType::size(def.type_));
644 break;
647 return OK;
650 //-1 index not supported
651 DbRetVal TableImpl::insertIndexNode(Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple)
653 INDEX *iptr = (INDEX*)indexPtr;
654 DbRetVal ret = OK;
655 printDebug(DM_Table, "Inside insertIndexNode type %d", iptr->indexType_);
656 Index* idx = Index::getIndex(iptr->indexType_);
657 ret = idx->insert(this, tr, indexPtr, info, tuple,undoFlag);
658 return ret;
661 DbRetVal TableImpl::deleteIndexNode(Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple)
663 INDEX *iptr = (INDEX*)indexPtr;
664 DbRetVal ret = OK;
665 Index* idx = Index::getIndex(iptr->indexType_);
666 ret = idx->remove(this, tr, indexPtr, info, tuple, undoFlag);
667 return ret;
669 void TableImpl::printSQLIndexString()
671 CatalogTableINDEXFIELD cIndexField(sysDB_);
672 char fName[IDENTIFIER_LENGTH];
673 char *fldName = fName;
674 DataType type;
675 for (int i = 0; i < numIndexes_ ; i++)
677 INDEX *iptr = (INDEX*) indexPtr_[i];
678 cIndexField.getFieldNameAndType((void*)iptr, fldName, type);
679 printf("CREATE INDEX %s on %s ( %s ) ", iptr->indName_, getName(), fldName);
680 if (((HashIndexInfo*) idxInfo[i])->isUnique) printf(" UNIQUE;\n"); else printf(";\n");
685 DbRetVal TableImpl::updateIndexNode(Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple)
687 INDEX *iptr = (INDEX*)indexPtr;
688 DbRetVal ret = OK;
689 Index* idx = Index::getIndex(iptr->indexType_);
690 //TODO::currently it updates irrespective of whether the key changed or not
691 //because of this commenting the whole index update code. relook at it and uncomment
693 ret = idx->update(this, tr, indexPtr, info, tuple, undoFlag);
695 return ret;
699 void TableImpl::setTableInfo(char *name, int tblid, size_t length,
700 int numFld, int numIdx, void *chunk)
702 strcpy(tblName_, name);
703 tblID_ = tblid;
704 length_ = length;
705 numFlds_ = numFld;
706 numIndexes_ = numIdx;
707 chunkPtr_ = chunk;
710 long TableImpl::spaceUsed()
712 Chunk *chk = (Chunk*)chunkPtr_;
713 long totSize = chk->getTotalDataNodes() * chk->getSize();
714 totSize = totSize + (chk->totalPages() * sizeof (PageInfo));
715 return totSize;
718 int TableImpl::pagesUsed()
720 Chunk *chk = (Chunk*)chunkPtr_;
721 return chk->totalPages();
724 long TableImpl::numTuples()
726 return ((Chunk*)chunkPtr_)->getTotalDataNodes();
729 List TableImpl::getFieldNameList()
731 List fldNameList;
732 FieldIterator fIter = fldList_.getIterator();
733 while (fIter.hasElement())
735 FieldDef def = fIter.nextElement();
736 Identifier *elem = new Identifier();
737 strcpy(elem->name, def.fldName_);
738 fldNameList.append(elem);
740 return fldNameList;
742 DbRetVal TableImpl::close()
744 if (NULL == iter)
746 printError(ErrNotOpen,"Scan not open");
747 return ErrNotOpen;
749 iter->close();
750 delete iter;
751 iter = NULL;
752 return OK;
754 DbRetVal TableImpl::lock(bool shared)
757 DbRetVal ret = OK;
759 if (shared)
760 ret = lMgr_->getSharedLock(chunkPtr_, NULL);
761 else
762 ret = lMgr_->getExclusiveLock(chunkPtr_, NULL);
763 if (OK != ret)
765 printError(ret, "Could not exclusive lock on the table %x", chunkPtr_);
766 }else {
767 //do not append for S to X upgrade
768 if (!ProcessManager::hasLockList.exists(chunkPtr_))
769 ProcessManager::hasLockList.append(chunkPtr_);
772 return ret;
774 DbRetVal TableImpl::unlock()
777 if (!ProcessManager::hasLockList.exists(chunkPtr_)) return OK;
778 DbRetVal ret = lMgr_->releaseLock(chunkPtr_);
779 if (OK != ret)
781 printError(ret, "Could not release exclusive lock on the table %x", chunkPtr_);
782 }else
784 ProcessManager::hasLockList.remove(chunkPtr_);
787 return OK;
790 TableImpl::~TableImpl()
792 if (NULL != iter ) { delete iter; iter = NULL; }
793 if (NULL != indexPtr_) { delete[] indexPtr_; indexPtr_ = NULL; }
794 if (NULL != idxInfo)
796 for (int i = 0; i < numIndexes_; i++) delete idxInfo[i];
797 delete[] idxInfo;
798 idxInfo = NULL;
800 if (numFlds_ > 31 && cNullInfo != NULL) { free(cNullInfo); cNullInfo = NULL; }
802 fldList_.removeAll();