From bd31fca52d770a747490f126b9aebd7a77e828f2 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Wed, 5 Nov 2008 17:21:25 +0000 Subject: [PATCH] 1669029 Tree Index feature --- include/DatabaseManagerImpl.h | 2 + include/Debug.h | 6 +- include/Index.h | 68 ++++- include/PredicateImpl.h | 4 +- include/TableImpl.h | 2 + src/odbc/Makefile | 18 +- src/storage/AggTableImpl.cxx | 257 ----------------- src/storage/CatalogTables.cxx | 5 +- src/storage/DatabaseManagerImpl.cxx | 131 ++++++++- src/storage/Debug.cxx | 2 + src/storage/Index.cxx | 6 +- src/storage/JoinTableImpl.cxx | 268 ++++++++++++++++++ src/storage/Makefile.am | 4 +- src/storage/Makefile.in | 26 +- src/storage/PredicateImpl.cxx | 67 ++++- src/storage/TableImpl.cxx | 19 +- src/storage/TreeIndex.cxx | 518 ++++++++++++++++++++++++++++++++++ src/storage/TreeIter.cxx | 155 ++++++++++ src/storage/TupleIterator.cxx | 60 +++- test/cache/Bidirectional/test001.ksh | 2 +- test/cache/Bidirectional/test013.ksh | 4 +- test/cache/Bidirectional/test014.ksh | 4 +- test/cache/Bidirectional/test015.ksh | 4 +- test/cache/CacheTable/exp.test003.ksh | 2 +- test/cache/CacheTable/exp.test008.ksh | 4 +- test/cache/CacheTable/inputtest4.sql | 1 + test/cache/Recovery/exp.test002.ksh | 200 ++++++------- test/cache/Recovery/exp.test003.ksh | 4 +- test/cache/Recovery/exp.test004.ksh | 4 +- test/cache/Recovery/test002.ksh | 2 +- test/tools/csql/exp.test007.ksh | 4 +- test/tools/csql/exp.test030.ksh | 2 +- test/tools/csql/exp.test031.ksh | 2 +- test/tools/csql/exp.test032.ksh | 2 +- test/tools/csql/exp.test033.ksh | 3 +- test/tools/csql/exp.test034.ksh | 2 +- test/tools/csqldump/exp.test002.ksh | 2 +- test/tools/csqldump/exp.test003.ksh | 2 +- test/tools/csqldump/exp.test004.ksh | 2 +- test/tools/csqldump/exp.test005.ksh | 2 +- test/tools/csqldump/exp.test006.ksh | 4 +- test/tools/csqldump/exp.test007.ksh | 2 +- test/tools/csqldump/exp.test008.ksh | 20 +- test/tools/csqldump/exp.test010.ksh | 2 +- test/tools/csqldump/exp.test011.ksh | 2 +- test/tools/csqldump/exp.test012.ksh | 2 +- tmptest/Makefile | 6 + 47 files changed, 1466 insertions(+), 444 deletions(-) create mode 100644 src/storage/JoinTableImpl.cxx create mode 100644 src/storage/TreeIndex.cxx create mode 100644 src/storage/TreeIter.cxx diff --git a/include/DatabaseManagerImpl.h b/include/DatabaseManagerImpl.h index 6e1a5101..c623b97b 100644 --- a/include/DatabaseManagerImpl.h +++ b/include/DatabaseManagerImpl.h @@ -81,6 +81,8 @@ class DatabaseManagerImpl : public DatabaseManager DbRetVal createHashIndex(const char *indName, const char *tableName, FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false); + DbRetVal createTreeIndex(const char *indName, const char *tableName, + FieldNameList &fldList, int bucketSize, bool isUnique, bool isPrimary = false); void initHashBuckets(Bucket *buck, int bucketSize); DbRetVal dropIndexInt(const char *name, bool takeLock); diff --git a/include/Debug.h b/include/Debug.h index 0592231a..9e24a7ba 100644 --- a/include/Debug.h +++ b/include/Debug.h @@ -25,6 +25,7 @@ extern int DebugDM_UndoLog; extern int DebugDM_RedoLog; extern int DebugDM_Index; extern int DebugDM_HashIndex; +extern int DebugDM_TreeIndex; extern int DebugDM_SystemDatabase; extern int DebugDM_Database; extern int DebugDM_Table; @@ -51,6 +52,7 @@ enum DebugModule DM_RedoLog, DM_Index, DM_HashIndex, + DM_TreeIndex, DM_SystemDatabase, DM_Database, DM_Table, @@ -65,8 +67,8 @@ enum DebugModule static char moduleNames[][20] = { "Alloc", "VariableAlloc", "Lock", "Trans", "UndoLog", "RedoLog", "Index", - "HashIndex", "SysDb", "Db", "Table", "Predicate", "Iter", "Procmgmt", - "Network", "Gateway", "Adapter", "SqlLog" + "HashIndex", "TreeIndex", "SysDb", "Db", "Table", "Predicate", "Iter", + "Procmgmt", "Network", "Gateway", "Adapter", "SqlLog" }; extern int printDebug1(int module, char *fname, int lineno, char *format, ...); diff --git a/include/Index.h b/include/Index.h index a7451eb6..01c708f1 100644 --- a/include/Index.h +++ b/include/Index.h @@ -24,6 +24,7 @@ class Chunk; class Database; class Transaction; class TableImpl; +class CINDEX; class Bucket { @@ -38,6 +39,28 @@ class HashIndexNode void *ptrToTuple_; HashIndexNode *next_; }; + +class IndexInfo; +class TreeNode +{ + public: + Mutex mutex_; + void *min_; + void *max_; + int noElements_; + int balance_; + TreeNode *next_; + TreeNode *prev_; + //Note::after this array of pointer to tuples are stored + + DbRetVal insert(Database *db, IndexInfo *info, void *indexPtr, void *tuple); + DbRetVal insert(int position, Database *db, IndexInfo *indInfo, CINDEX *iptr, void *tuple, TreeNode *iter); + DbRetVal remove(Database *db, IndexInfo *info, void *indexPtr, void *tuple); + DbRetVal update(Database *db, IndexInfo *info, void *indexPtr, void *tuple); + void displayAll(IndexInfo *indInfo, void *indexPtr); + void displayAll(int offset); +}; + class BucketIter { HashIndexNode *iter; @@ -66,12 +89,15 @@ class BucketList }; class HashIndex; class IndexInfo; +class HashIndexInfo; +class TreeIndex; class Index { // create (one) object for each indexing mechanisms here // Also need to make changes to getIndex() and destroy() methods // accordingly for new index machanism. static HashIndex *hIdx; + static TreeIndex *tIdx; static long usageCount; public: static Index* getIndex(IndexType type); @@ -97,6 +123,46 @@ class HashIndex : public Index }; +class TreeIndex : public Index +{ + + TreeNode* locateNode(TreeNode *iter, void *tuple, IndexInfo *indInfo); + DbRetVal removeElement(TreeNode *iter, void *tuple, HashIndexInfo *info); + public: + DbRetVal insert(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple, bool undoFlag); + DbRetVal remove(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple, bool undoFlag); + DbRetVal update(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *info, void *tuple, bool undoFlag); + +}; +class TreeIter +{ + TreeNode *iter; + int fldOffset; + DataType type; + int length; + ComparisionOp op; + bool asc; + void *searchKey; + bool firstCall; + int nodeOffset; + bool recordsOver; + + void* locateNode(); + void* locateElement(); + + public: + TreeIter(){} + TreeIter(TreeNode *head) { iter = head; firstCall = true; recordsOver=false;} + void setSearchKey(void *key, ComparisionOp cop, bool ascending = true) + { + searchKey = key; op = cop; asc =ascending; + } + void setFldOffset(int off) { fldOffset = off; } + void setTypeLength(DataType t, int l) { type =t ; length =l; } + void* prev(); + void* next(); +}; + enum IndexIntType { hashOneField = 1, @@ -107,7 +173,7 @@ enum IndexIntType class IndexInfo { public: - IndexType type; + IndexType indType; }; //Used by TableImpl to cache information related to hash indexes on that table diff --git a/include/PredicateImpl.h b/include/PredicateImpl.h index 0609676f..af42a13d 100644 --- a/include/PredicateImpl.h +++ b/include/PredicateImpl.h @@ -58,6 +58,7 @@ class PredicateImpl:public Predicate void setTerm(Predicate *p1, LogicalOp op, Predicate *p2 = NULL); void* valPtrForIndexField(const char *name); + ComparisionOp opForIndexField(const char *name); DbRetVal evaluate(bool &result); @@ -69,8 +70,9 @@ class PredicateImpl:public Predicate //and does not have OR, NOT operator // TODO:: expression like !(f1 !=100) wont be optimized for now bool pointLookupInvolved(const char *fName); + bool rangeQueryInvolved(const char *fName); - void print(); + void print(); }; diff --git a/include/TableImpl.h b/include/TableImpl.h index 7caefb12..50b84b35 100644 --- a/include/TableImpl.h +++ b/include/TableImpl.h @@ -41,6 +41,7 @@ class TupleIterator ScanType scanType_; ChunkIterator *cIter; BucketIter *bIter; + TreeIter *tIter; IndexInfo *info; void *chunkPtr_; int procSlot; @@ -59,6 +60,7 @@ class TupleIterator DbRetVal open(); void* next(); + void* prev();//used only for tree iter during deleteTuple DbRetVal close(); }; diff --git a/src/odbc/Makefile b/src/odbc/Makefile index 4d084e29..1df61d3f 100644 --- a/src/odbc/Makefile +++ b/src/odbc/Makefile @@ -77,14 +77,14 @@ HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = ${SHELL} /home/bijaya/csql/missing --run aclocal-1.9 +ACLOCAL = ${SHELL} /home/csql/latest/csql/missing --run aclocal-1.9 AMDEP_FALSE = # AMDEP_TRUE = -AMTAR = ${SHELL} /home/bijaya/csql/missing --run tar +AMTAR = ${SHELL} /home/csql/latest/csql/missing --run tar AR = ar -AUTOCONF = ${SHELL} /home/bijaya/csql/missing --run autoconf -AUTOHEADER = ${SHELL} /home/bijaya/csql/missing --run autoheader -AUTOMAKE = ${SHELL} /home/bijaya/csql/missing --run automake-1.9 +AUTOCONF = ${SHELL} /home/csql/latest/csql/missing --run autoconf +AUTOHEADER = ${SHELL} /home/csql/latest/csql/missing --run autoheader +AUTOMAKE = ${SHELL} /home/csql/latest/csql/missing --run automake-1.9 AWK = gawk CC = gcc CCDEPMODE = depmode=gcc3 @@ -94,7 +94,7 @@ CPPFLAGS = CXX = g++ CXXCPP = g++ -E CXXDEPMODE = depmode=gcc3 -CXXFLAGS = -g -I/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/include -I/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/include/linux +CXXFLAGS = -g -I/usr/java/jdk1.6.0_10/include -I/usr/java/jdk1.6.0_10/include/linux CYGPATH_W = echo DEFS = -DHAVE_CONFIG_H DEPDIR = .deps @@ -120,7 +120,7 @@ LIBS = LIBTOOL = $(SHELL) $(top_builddir)/libtool LN_S = ln -s LTLIBOBJS = -MAKEINFO = ${SHELL} /home/bijaya/csql/missing --run makeinfo +MAKEINFO = ${SHELL} /home/csql/latest/csql/missing --run makeinfo OBJEXT = o PACKAGE = csql PACKAGE_BUGREPORT = @@ -167,7 +167,7 @@ host_vendor = pc htmldir = ${docdir} includedir = ${prefix}/include infodir = ${datarootdir}/info -install_sh = /home/bijaya/csql/install-sh +install_sh = /home/csql/latest/csql/install-sh libdir = ${exec_prefix}/lib libexecdir = ${exec_prefix}/libexec localedir = ${datarootdir}/locale @@ -176,7 +176,7 @@ mandir = ${datarootdir}/man mkdir_p = mkdir -p -- oldincludedir = /usr/include pdfdir = ${docdir} -prefix = /home/bijaya/csql/install +prefix = /home/csql/latest/csql/install program_transform_name = s,x,x, psdir = ${docdir} sbindir = ${exec_prefix}/sbin diff --git a/src/storage/AggTableImpl.cxx b/src/storage/AggTableImpl.cxx index 2375df52..b6217d98 100644 --- a/src/storage/AggTableImpl.cxx +++ b/src/storage/AggTableImpl.cxx @@ -307,260 +307,3 @@ DbRetVal AggTableImpl::close() fldList.reset(); return OK; } - - - - - - - -//----------------------------------------------------------- - -JoinTableImpl::JoinTableImpl() -{ - isNestedLoop= true; -} -JoinTableImpl::~JoinTableImpl() -{ -} -void JoinTableImpl::getFieldNameAlone(char *fname, char *name) { - bool dotFound= false; - char *fullname = fname; - while(*fullname != '\0') - { - if (*fullname == '.') { dotFound = true; break; } - fullname++; - } - if (dotFound) strcpy(name, ++fullname); else strcpy(name, fname); - -} -void JoinTableImpl::getTableNameAlone(char *fname, char *name) { - strcpy(name, fname); - while(*name != '\0') - { - if (*name == '.') { *name='\0'; break; } - name++; - } - return; -} -DbRetVal JoinTableImpl::bindFld(const char *fldname, void *val) -{ - FieldInfo *info = new FieldInfo(); - char tableName[IDENTIFIER_LENGTH]; - char fieldName[IDENTIFIER_LENGTH]; - getTableNameAlone((char*)fldname, tableName); - getFieldNameAlone((char*)fldname, fieldName); - printf("%s %s \n", tableName, fieldName); - - ListIterator iter = projList.getIterator(); - JoinProjFieldInfo *elem; - while (iter.hasElement()) - { - elem = (JoinProjFieldInfo*) iter.nextElement(); - if (strcmp(elem->fieldName, fieldName)==0 && - strcmp(elem->tableName, tableName) ==0) - { - printError(ErrBadCall, "Field already binded %s\n", fldname); - delete info; - return ErrBadCall; - } - } - JoinProjFieldInfo *def = new JoinProjFieldInfo(); - strcpy(def->tableName, tableName); - strcpy(def->fieldName, fieldName); - def->appBuf = val; - def->bindBuf = AllDataType::alloc(def->type, def->length); - - if (strcmp(tableName, leftTableHdl->getName()) == 0) - { - leftTableHdl->getFieldInfo(fieldName, info); - def->bindBuf = AllDataType::alloc(info->type, info->length); - leftTableHdl->bindFld(fieldName, def->bindBuf); - - }else if (strcmp(tableName, rightTableHdl->getName()) == 0) - { - rightTableHdl->getFieldInfo(fieldName, info); - def->bindBuf = AllDataType::alloc(info->type, info->length); - rightTableHdl->bindFld(fieldName, def->bindBuf); - }else - { - printError(ErrBadCall, "TableName is invalid\n"); - delete info; - return ErrBadCall; - } - def->type = info->type; - def->length= info->length; - projList.append(def); - delete info; - return OK; -} -DbRetVal JoinTableImpl::setJoinCondition(const char *fldname1, - ComparisionOp op, - const char *fldname2) -{ - getTableNameAlone((char*)fldname1, jCondition.tableName1); - getFieldNameAlone((char*)fldname1, jCondition.fieldName1); - getTableNameAlone((char*)fldname2, jCondition.tableName2); - getFieldNameAlone((char*)fldname2, jCondition.fieldName2); - - //check if it is already binded - ListIterator iter = projList.getIterator(); - JoinProjFieldInfo *elem; - jCondition.alreadyBinded1 = false; - jCondition.alreadyBinded2 = false; - jCondition.op = op; - while (iter.hasElement()) - { - elem = (JoinProjFieldInfo*) iter.nextElement(); - if (strcmp(elem->fieldName, jCondition.fieldName1)==0 && - strcmp(elem->tableName, jCondition.tableName1) ==0) - { - jCondition.alreadyBinded1 = true; - jCondition.bindBuf1 = elem->bindBuf; - jCondition.type1 = elem->type; - jCondition.length1 = elem->length; - } - if (strcmp(elem->fieldName, jCondition.fieldName2)==0 && - strcmp(elem->tableName, jCondition.tableName2) ==0) - { - jCondition.alreadyBinded2 = true; - jCondition.bindBuf2 = elem->bindBuf; - jCondition.type2 = elem->type; - jCondition.length2 = elem->length; - } - } - - FieldInfo *info = new FieldInfo(); - if (!jCondition.alreadyBinded1) { - if (strcmp(jCondition.tableName1, leftTableHdl->getName()) == 0) - { - leftTableHdl->getFieldInfo(jCondition.fieldName1, info); - jCondition.bindBuf1 = AllDataType::alloc(info->type, info->length); - leftTableHdl->bindFld(jCondition.fieldName1, jCondition.bindBuf1); - - }else if (strcmp(jCondition.tableName1, rightTableHdl->getName()) == 0) - { - rightTableHdl->getFieldInfo(jCondition.fieldName1, info); - jCondition.bindBuf1 = AllDataType::alloc(info->type, info->length); - rightTableHdl->bindFld(jCondition.fieldName1, jCondition.bindBuf1); - }else - { - printError(ErrBadCall, "TableName is invalid\n"); - delete info; - return ErrBadCall; - } - } - if (!jCondition.alreadyBinded2) { - if (strcmp(jCondition.tableName2, leftTableHdl->getName()) == 0) - { - leftTableHdl->getFieldInfo(jCondition.fieldName2, info); - jCondition.bindBuf2 = AllDataType::alloc(info->type, info->length); - leftTableHdl->bindFld(jCondition.fieldName2, jCondition.bindBuf2); - - }else if (strcmp(jCondition.tableName2, rightTableHdl->getName()) == 0) - { - rightTableHdl->getFieldInfo(jCondition.fieldName2, info); - jCondition.bindBuf2 = AllDataType::alloc(info->type, info->length); - rightTableHdl->bindFld(jCondition.fieldName2, jCondition.bindBuf2); - }else - { - printError(ErrBadCall, "TableName is invalid\n"); - delete info; - return ErrBadCall; - } - } - return OK; -} - - -DbRetVal JoinTableImpl::execute() -{ - isNestedLoop = true; - leftTableHdl->execute(); - rightTableHdl->execute(); - leftTableHdl->fetch(); - //TODO - //if join condition is not set then do nl - //if it is inner join, hen do nl - //nl cannot be done for outer join - return OK; -} - -void* JoinTableImpl::fetch() -{ - if (isNestedLoop) - { - void *rec = rightTableHdl->fetch(); - if (rec==NULL) - { - rightTableHdl->close(); - rightTableHdl->execute(); - rec = rightTableHdl->fetch(); - if (rec == NULL) return NULL; - rec = leftTableHdl->fetch(); - if (rec == NULL) return NULL; - bool result = evaluate(); - if (! result) return fetch(); - copyValuesToBindBuffer(NULL); - return rec; - } - else { - bool result = evaluate(); - if (! result) return fetch(); - copyValuesToBindBuffer(NULL); - return rec; - } - - } - return NULL; -} -bool JoinTableImpl::evaluate() -{ - if (!jCondition.bindBuf1 || !jCondition.bindBuf2) return true; - return AllDataType::compareVal(jCondition.bindBuf1, jCondition.bindBuf2, - jCondition.op, - jCondition.type1, jCondition.length1); -} -void* JoinTableImpl::fetch(DbRetVal &rv) -{ - rv = OK; - return fetch(); -} - -void* JoinTableImpl::fetchNoBind() -{ - return NULL; -} - -void* JoinTableImpl::fetchNoBind(DbRetVal &rv) -{ - rv = OK; - return fetchNoBind(); -} - -DbRetVal JoinTableImpl::copyValuesToBindBuffer(void *elem) -{ - //Iterate through the bind list and copy the value here - ListIterator fIter = projList.getIterator(); - JoinProjFieldInfo *def; - while (fIter.hasElement()) - { - def = (JoinProjFieldInfo*) fIter.nextElement(); - if (NULL != def->appBuf) { - AllDataType::copyVal(def->appBuf, def->bindBuf, def->type, def->length); - } - } - return OK; -} - -long JoinTableImpl::numTuples() -{ - return 0; -} -void JoinTableImpl::closeScan() -{ -} -DbRetVal JoinTableImpl::close() -{ - return OK; -} diff --git a/src/storage/CatalogTables.cxx b/src/storage/CatalogTables.cxx index 8b618010..1ff72cb0 100644 --- a/src/storage/CatalogTables.cxx +++ b/src/storage/CatalogTables.cxx @@ -256,7 +256,10 @@ DbRetVal CatalogTableINDEX::insert(const char *name, void *tptr, int numFlds, bo indexInfo->tblID_ = -1; //Not used currently indexInfo->tblPtr_ = tptr; indexInfo->numFlds_ = numFlds; - indexInfo->indexType_ = hashIndex; + if (NULL == hChunk) + indexInfo->indexType_ = treeIndex; + else + indexInfo->indexType_ = hashIndex; indexInfo->chunkPtr_ = chunk; indexInfo->hashNodeChunk_ = hChunk; indexInfo->noOfBuckets_ = bucketSize; diff --git a/src/storage/DatabaseManagerImpl.cxx b/src/storage/DatabaseManagerImpl.cxx index f3b17f00..80623948 100644 --- a/src/storage/DatabaseManagerImpl.cxx +++ b/src/storage/DatabaseManagerImpl.cxx @@ -679,6 +679,7 @@ Table* DatabaseManagerImpl::openTable(const char *name) cIndexField.getFieldInfo(table->indexPtr_[i], hIdxInfo->idxFldList); ChunkIterator citer = CatalogTableINDEX::getIterator(table->indexPtr_[i]); hIdxInfo->indexPtr = table->indexPtr_[i]; + hIdxInfo->indType = ((CINDEX*)hIdxInfo->indexPtr)->indexType_; hIdxInfo->noOfBuckets = CatalogTableINDEX::getNoOfBuckets(table->indexPtr_[i]); FieldIterator fIter = hIdxInfo->idxFldList.getIterator(); bool firstFld = true; @@ -763,9 +764,10 @@ DbRetVal DatabaseManagerImpl::createIndex(const char *indName, IndexInitInfo *in } else if (info->indType == treeIndex) { - //TODO::tree index - printError(ErrNotYet, "Tree Index not supported\n"); - return ErrNotYet; + HashIndexInitInfo *hInfo = (HashIndexInitInfo*) info; + rv = createTreeIndex(indName, info->tableName, info->list, + hInfo->bucketSize, info->isUnique, info->isPrimary); + }else { printError(ErrBadCall, "Index type not supported\n"); return ErrBadCall; @@ -952,6 +954,110 @@ DbRetVal DatabaseManagerImpl::createHashIndex(const char *indName, const char *t logFinest(logger, "Creating HashIndex %s on %s with bucket size %d", indName, tblName, buckets); return OK; } +DbRetVal DatabaseManagerImpl::createTreeIndex(const char *indName, const char *tblName, + FieldNameList &fldList, int nodeSize, bool isUnique, bool isPrimary) +{ + if (nodeSize < 20 || nodeSize > 20000) + { + printError(ErrBadRange,"Tree Index Node size %d not in range 20-20000", + nodeSize); + return ErrBadRange; + } + int totFlds = fldList.size(); + if (totFlds == 0) + { + printError(ErrBadCall, "No Field name specified"); + return ErrBadCall; + } + void *tptr =NULL; + void *chunk = NULL; + DbRetVal rv = systemDatabase_->getDatabaseMutex(); + if (OK != rv) + { + printError(ErrSysInternal, "Unable to get database mutex"); + return ErrSysInternal; + } + //check whether table exists + + CatalogTableTABLE cTable(systemDatabase_); + cTable.getChunkAndTblPtr(tblName, chunk, tptr); + if (NULL == tptr) + { + systemDatabase_->releaseDatabaseMutex(); + printError(ErrNotExists, "Table does not exist %s", tblName); + return ErrNotExists; + } + char **fptr = new char* [totFlds]; + CatalogTableFIELD cField(systemDatabase_); + rv = cField.getFieldPtrs(fldList, tptr, fptr); + if (OK != rv) + { + delete[] fptr; + systemDatabase_->releaseDatabaseMutex(); + if (rv != ErrBadCall) { + printError(ErrNotExists, "Field does not exist"); + return ErrNotExists; + } + } + for (int i=0; i isNull_ && isPrimary ) + { + printError(ErrBadArg, "Primary Index cannot be created on field without NOTNULL constraint"); + delete[] fptr; + systemDatabase_->releaseDatabaseMutex(); + return ErrBadArg; + } + } + int chunkSize = sizeof(TreeNode)+(nodeSize * sizeof(void*)); + printDebug(DM_HashIndex, "Creating chunk for storing tree nodes of size %d\n", chunkSize); + + Chunk* chunkInfo = createUserChunk(chunkSize); + if (NULL == chunkInfo) + { + delete[] fptr; + systemDatabase_->releaseDatabaseMutex(); + printError(ErrSysInternal, "Unable to create chunk"); + return ErrSysInternal; + } + void *tupleptr = NULL; + CatalogTableINDEX cIndex(systemDatabase_); + rv = cIndex.insert(indName, tptr, fldList.size(), isUnique, + chunkInfo, nodeSize, NULL, tupleptr); + if (OK != rv) + { + delete[] fptr; + deleteUserChunk(chunkInfo); + systemDatabase_->releaseDatabaseMutex(); + printError(ErrSysInternal, "Catalog table updation failed in INDEX table"); + return ErrSysInternal; + } + CatalogTableINDEXFIELD cIndexField(systemDatabase_); + rv = cIndexField.insert(fldList, tupleptr, tptr, fptr); + + if (OK != rv) + { + delete[] fptr; + void *hChunk = NULL; + cIndex.remove(indName, (void *&)chunkInfo, (void *&)hChunk, (void *&)tupleptr); + deleteUserChunk(chunkInfo); + systemDatabase_->releaseDatabaseMutex(); + printError(ErrSysInternal, "Catalog table updation failed in INDEXFIELD table"); + return ErrSysInternal; + } + delete[] fptr; + //TODO::if tuples already present in this table, then create tree index ' + //nodes + systemDatabase_->releaseDatabaseMutex(); + printDebug(DM_Database, "Creating Tree Index Name:%s tblname:%s node size:%x", + indName, tblName, nodeSize); + logFinest(logger, "Creating TreeIndex %s on %s with node size %d", + indName, tblName, nodeSize); + return OK; +} + + void DatabaseManagerImpl::initHashBuckets(Bucket *buck, int bucketSize) { @@ -1006,6 +1112,7 @@ DbRetVal DatabaseManagerImpl::dropIndexInt(const char *name, bool takeLock) printDebug(DM_Database, "Removing from INDEXFIELD %s",name); //delete the index chunk + CINDEX *iptr = (CINDEX*)tptr; rv = deleteUserChunk((Chunk*)chunk); if (OK != rv) { @@ -1014,17 +1121,21 @@ DbRetVal DatabaseManagerImpl::dropIndexInt(const char *name, bool takeLock) return ErrSysInternal; } //delete the index hash node chunk - rv = deleteUserChunk((Chunk*)hchunk); - if (OK != rv) - { - if (takeLock) systemDatabase_->releaseDatabaseMutex(); - printError(ErrSysInternal, "Unable to delete the index hash node chunk"); - return ErrSysInternal; + if (iptr->indexType_ == hashIndex) { + rv = deleteUserChunk((Chunk*)hchunk); + if (OK != rv) + { + if (takeLock) systemDatabase_->releaseDatabaseMutex(); + printError(ErrSysInternal, "Unable to delete the index hash node chunk"); + return ErrSysInternal; + } } if (takeLock) systemDatabase_->releaseDatabaseMutex(); Chunk *chunkNode = systemDatabase_->getSystemDatabaseChunk(UserChunkTableId); chunkNode->free(systemDatabase_, (Chunk *) chunk); - chunkNode->free(systemDatabase_, (Chunk *) hchunk); + if (iptr->indexType_ == hashIndex) { + chunkNode->free(systemDatabase_, (Chunk *) hchunk); + } //TODO::If tuples present in this table, then //free all hash index nodes for this table. diff --git a/src/storage/Debug.cxx b/src/storage/Debug.cxx index dfaaaab4..845e0d5e 100644 --- a/src/storage/Debug.cxx +++ b/src/storage/Debug.cxx @@ -23,6 +23,7 @@ int DebugDM_UndoLog = 0; int DebugDM_RedoLog = 0; int DebugDM_Index = 0; int DebugDM_HashIndex = 0; +int DebugDM_TreeIndex = 0; int DebugDM_SystemDatabase = 0; int DebugDM_Database = 0; int DebugDM_Table = 0; @@ -68,6 +69,7 @@ int printDebug1(int module, char *fname, int lno, char *format, ...) case DM_UndoLog: { if (!DebugDM_UndoLog) return 1; break; } case DM_RedoLog: { if (!DebugDM_RedoLog) return 1; break; } case DM_HashIndex: { if (!DebugDM_HashIndex) return 1; break; } + case DM_TreeIndex: { if (!DebugDM_TreeIndex) return 1; break; } case DM_SystemDatabase: { if (!DebugDM_SystemDatabase) return 1; break; } case DM_Database: { if (!DebugDM_Database) return 1; break; } case DM_Table: { if (!DebugDM_Table) return 1; break; } diff --git a/src/storage/Index.cxx b/src/storage/Index.cxx index 01d886c0..e86bb07f 100644 --- a/src/storage/Index.cxx +++ b/src/storage/Index.cxx @@ -19,6 +19,7 @@ #include HashIndex* Index::hIdx = NULL; +TreeIndex* Index::tIdx = NULL; long Index::usageCount = 0; Index* Index::getIndex(IndexType type) @@ -27,8 +28,9 @@ Index* Index::getIndex(IndexType type) { if (NULL == hIdx) hIdx = new HashIndex(); return hIdx; + }else if (type == treeIndex) { + if (NULL == tIdx) tIdx = new TreeIndex(); + return tIdx; } return NULL; } - - diff --git a/src/storage/JoinTableImpl.cxx b/src/storage/JoinTableImpl.cxx new file mode 100644 index 00000000..d933b844 --- /dev/null +++ b/src/storage/JoinTableImpl.cxx @@ -0,0 +1,268 @@ +/*************************************************************************** + * Copyright (C) 2007 by www.databasecache.com * + * Contact: praba_tuty@databasecache.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + ***************************************************************************/ +#include +#include +#include +#include + +JoinTableImpl::JoinTableImpl() +{ + isNestedLoop= true; +} +JoinTableImpl::~JoinTableImpl() +{ +} +void JoinTableImpl::getFieldNameAlone(char *fname, char *name) { + bool dotFound= false; + char *fullname = fname; + while(*fullname != '\0') + { + if (*fullname == '.') { dotFound = true; break; } + fullname++; + } + if (dotFound) strcpy(name, ++fullname); else strcpy(name, fname); + +} +void JoinTableImpl::getTableNameAlone(char *fname, char *name) { + strcpy(name, fname); + while(*name != '\0') + { + if (*name == '.') { *name='\0'; break; } + name++; + } + return; +} +DbRetVal JoinTableImpl::bindFld(const char *fldname, void *val) +{ + FieldInfo *info = new FieldInfo(); + char tableName[IDENTIFIER_LENGTH]; + char fieldName[IDENTIFIER_LENGTH]; + getTableNameAlone((char*)fldname, tableName); + getFieldNameAlone((char*)fldname, fieldName); + printf("%s %s \n", tableName, fieldName); + + ListIterator iter = projList.getIterator(); + JoinProjFieldInfo *elem; + while (iter.hasElement()) + { + elem = (JoinProjFieldInfo*) iter.nextElement(); + if (strcmp(elem->fieldName, fieldName)==0 && + strcmp(elem->tableName, tableName) ==0) + { + printError(ErrBadCall, "Field already binded %s\n", fldname); + delete info; + return ErrBadCall; + } + } + JoinProjFieldInfo *def = new JoinProjFieldInfo(); + strcpy(def->tableName, tableName); + strcpy(def->fieldName, fieldName); + def->appBuf = val; + def->bindBuf = AllDataType::alloc(def->type, def->length); + + if (strcmp(tableName, leftTableHdl->getName()) == 0) + { + leftTableHdl->getFieldInfo(fieldName, info); + def->bindBuf = AllDataType::alloc(info->type, info->length); + leftTableHdl->bindFld(fieldName, def->bindBuf); + + }else if (strcmp(tableName, rightTableHdl->getName()) == 0) + { + rightTableHdl->getFieldInfo(fieldName, info); + def->bindBuf = AllDataType::alloc(info->type, info->length); + rightTableHdl->bindFld(fieldName, def->bindBuf); + }else + { + printError(ErrBadCall, "TableName is invalid\n"); + delete info; + return ErrBadCall; + } + def->type = info->type; + def->length= info->length; + projList.append(def); + delete info; + return OK; +} +DbRetVal JoinTableImpl::setJoinCondition(const char *fldname1, + ComparisionOp op, + const char *fldname2) +{ + getTableNameAlone((char*)fldname1, jCondition.tableName1); + getFieldNameAlone((char*)fldname1, jCondition.fieldName1); + getTableNameAlone((char*)fldname2, jCondition.tableName2); + getFieldNameAlone((char*)fldname2, jCondition.fieldName2); + + //check if it is already binded + ListIterator iter = projList.getIterator(); + JoinProjFieldInfo *elem; + jCondition.alreadyBinded1 = false; + jCondition.alreadyBinded2 = false; + jCondition.op = op; + while (iter.hasElement()) + { + elem = (JoinProjFieldInfo*) iter.nextElement(); + if (strcmp(elem->fieldName, jCondition.fieldName1)==0 && + strcmp(elem->tableName, jCondition.tableName1) ==0) + { + jCondition.alreadyBinded1 = true; + jCondition.bindBuf1 = elem->bindBuf; + jCondition.type1 = elem->type; + jCondition.length1 = elem->length; + } + if (strcmp(elem->fieldName, jCondition.fieldName2)==0 && + strcmp(elem->tableName, jCondition.tableName2) ==0) + { + jCondition.alreadyBinded2 = true; + jCondition.bindBuf2 = elem->bindBuf; + jCondition.type2 = elem->type; + jCondition.length2 = elem->length; + } + } + + FieldInfo *info = new FieldInfo(); + if (!jCondition.alreadyBinded1) { + if (strcmp(jCondition.tableName1, leftTableHdl->getName()) == 0) + { + leftTableHdl->getFieldInfo(jCondition.fieldName1, info); + jCondition.bindBuf1 = AllDataType::alloc(info->type, info->length); + leftTableHdl->bindFld(jCondition.fieldName1, jCondition.bindBuf1); + + }else if (strcmp(jCondition.tableName1, rightTableHdl->getName()) == 0) + { + rightTableHdl->getFieldInfo(jCondition.fieldName1, info); + jCondition.bindBuf1 = AllDataType::alloc(info->type, info->length); + rightTableHdl->bindFld(jCondition.fieldName1, jCondition.bindBuf1); + }else + { + printError(ErrBadCall, "TableName is invalid\n"); + delete info; + return ErrBadCall; + } + } + if (!jCondition.alreadyBinded2) { + if (strcmp(jCondition.tableName2, leftTableHdl->getName()) == 0) + { + leftTableHdl->getFieldInfo(jCondition.fieldName2, info); + jCondition.bindBuf2 = AllDataType::alloc(info->type, info->length); + leftTableHdl->bindFld(jCondition.fieldName2, jCondition.bindBuf2); + + }else if (strcmp(jCondition.tableName2, rightTableHdl->getName()) == 0) + { + rightTableHdl->getFieldInfo(jCondition.fieldName2, info); + jCondition.bindBuf2 = AllDataType::alloc(info->type, info->length); + rightTableHdl->bindFld(jCondition.fieldName2, jCondition.bindBuf2); + }else + { + printError(ErrBadCall, "TableName is invalid\n"); + delete info; + return ErrBadCall; + } + } + return OK; +} + + +DbRetVal JoinTableImpl::execute() +{ + isNestedLoop = true; + leftTableHdl->execute(); + rightTableHdl->execute(); + leftTableHdl->fetch(); + //TODO + //if join condition is not set then do nl + //if it is inner join, hen do nl + //nl cannot be done for outer join + return OK; +} + +void* JoinTableImpl::fetch() +{ + if (isNestedLoop) + { + void *rec = rightTableHdl->fetch(); + if (rec==NULL) + { + rightTableHdl->close(); + rightTableHdl->execute(); + rec = rightTableHdl->fetch(); + if (rec == NULL) return NULL; + rec = leftTableHdl->fetch(); + if (rec == NULL) return NULL; + bool result = evaluate(); + if (! result) return fetch(); + copyValuesToBindBuffer(NULL); + return rec; + } + else { + bool result = evaluate(); + if (! result) return fetch(); + copyValuesToBindBuffer(NULL); + return rec; + } + + } + return NULL; +} +bool JoinTableImpl::evaluate() +{ + if (!jCondition.bindBuf1 || !jCondition.bindBuf2) return true; + return AllDataType::compareVal(jCondition.bindBuf1, jCondition.bindBuf2, + jCondition.op, + jCondition.type1, jCondition.length1); +} +void* JoinTableImpl::fetch(DbRetVal &rv) +{ + rv = OK; + return fetch(); +} + +void* JoinTableImpl::fetchNoBind() +{ + return NULL; +} + +void* JoinTableImpl::fetchNoBind(DbRetVal &rv) +{ + rv = OK; + return fetchNoBind(); +} + +DbRetVal JoinTableImpl::copyValuesToBindBuffer(void *elem) +{ + //Iterate through the bind list and copy the value here + ListIterator fIter = projList.getIterator(); + JoinProjFieldInfo *def; + while (fIter.hasElement()) + { + def = (JoinProjFieldInfo*) fIter.nextElement(); + if (NULL != def->appBuf) { + AllDataType::copyVal(def->appBuf, def->bindBuf, def->type, def->length); + } + } + return OK; +} + +long JoinTableImpl::numTuples() +{ + return 0; +} +void JoinTableImpl::closeScan() +{ +} +DbRetVal JoinTableImpl::close() +{ + return OK; +} diff --git a/src/storage/Makefile.am b/src/storage/Makefile.am index e7070aed..43ed7fd8 100644 --- a/src/storage/Makefile.am +++ b/src/storage/Makefile.am @@ -2,8 +2,8 @@ INCLUDES = -I$(top_srcdir)/include $(all_includes) METASOURCES = AUTO lib_LTLIBRARIES = libcsql.la libcsql_la_LDFLAGS = -avoid-version -module -libcsql_la_SOURCES = BucketIter.cxx BucketList.cxx CatalogTables.cxx Chunk.cxx \ +libcsql_la_SOURCES = BucketIter.cxx TreeIter.cxx BucketList.cxx CatalogTables.cxx Chunk.cxx \ ChunkIterator.cxx Condition.cxx Connection.cxx Database.cxx DatabaseManagerImpl.cxx DataType.cxx \ Debug.cxx FieldList.cxx Index.cxx LockListIter.cxx LockManager.cxx Logger.cxx Mutex.cxx os.cxx \ PageInfo.cxx PredicateImpl.cxx SessionImpl.cxx TableDef.cxx TableImpl.cxx Transaction.cxx \ - TransactionManager.cxx TupleIterator.cxx UserManagerImpl.cxx HashIndex.cxx Config.cxx Process.cxx AggTableImpl.cxx JoinTableImpl.cxx + TransactionManager.cxx TupleIterator.cxx UserManagerImpl.cxx HashIndex.cxx TreeIndex.cxx Config.cxx Process.cxx AggTableImpl.cxx JoinTableImpl.cxx diff --git a/src/storage/Makefile.in b/src/storage/Makefile.in index 6a5e08a0..c1915ec6 100644 --- a/src/storage/Makefile.in +++ b/src/storage/Makefile.in @@ -55,14 +55,15 @@ am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libcsql_la_LIBADD = -am_libcsql_la_OBJECTS = BucketIter.lo BucketList.lo CatalogTables.lo \ - Chunk.lo ChunkIterator.lo Condition.lo Connection.lo \ - Database.lo DatabaseManagerImpl.lo DataType.lo Debug.lo \ - FieldList.lo Index.lo LockListIter.lo LockManager.lo Logger.lo \ - Mutex.lo os.lo PageInfo.lo PredicateImpl.lo SessionImpl.lo \ - TableDef.lo TableImpl.lo Transaction.lo TransactionManager.lo \ - TupleIterator.lo UserManagerImpl.lo HashIndex.lo Config.lo \ - Process.lo AggTableImpl.lo +am_libcsql_la_OBJECTS = BucketIter.lo TreeIter.lo BucketList.lo \ + CatalogTables.lo Chunk.lo ChunkIterator.lo Condition.lo \ + Connection.lo Database.lo DatabaseManagerImpl.lo DataType.lo \ + Debug.lo FieldList.lo Index.lo LockListIter.lo LockManager.lo \ + Logger.lo Mutex.lo os.lo PageInfo.lo PredicateImpl.lo \ + SessionImpl.lo TableDef.lo TableImpl.lo Transaction.lo \ + TransactionManager.lo TupleIterator.lo UserManagerImpl.lo \ + HashIndex.lo TreeIndex.lo Config.lo Process.lo AggTableImpl.lo \ + JoinTableImpl.lo libcsql_la_OBJECTS = $(am_libcsql_la_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -190,11 +191,11 @@ INCLUDES = -I$(top_srcdir)/include $(all_includes) METASOURCES = AUTO lib_LTLIBRARIES = libcsql.la libcsql_la_LDFLAGS = -avoid-version -module -libcsql_la_SOURCES = BucketIter.cxx BucketList.cxx CatalogTables.cxx Chunk.cxx \ +libcsql_la_SOURCES = BucketIter.cxx TreeIter.cxx BucketList.cxx CatalogTables.cxx Chunk.cxx \ ChunkIterator.cxx Condition.cxx Connection.cxx Database.cxx DatabaseManagerImpl.cxx DataType.cxx \ Debug.cxx FieldList.cxx Index.cxx LockListIter.cxx LockManager.cxx Logger.cxx Mutex.cxx os.cxx \ PageInfo.cxx PredicateImpl.cxx SessionImpl.cxx TableDef.cxx TableImpl.cxx Transaction.cxx \ - TransactionManager.cxx TupleIterator.cxx UserManagerImpl.cxx HashIndex.cxx Config.cxx Process.cxx AggTableImpl.cxx + TransactionManager.cxx TupleIterator.cxx UserManagerImpl.cxx HashIndex.cxx TreeIndex.cxx Config.cxx Process.cxx AggTableImpl.cxx JoinTableImpl.cxx all: all-am @@ -281,6 +282,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FieldList.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HashIndex.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Index.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/JoinTableImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LockListIter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LockManager.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Plo@am__quote@ @@ -293,6 +295,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TableImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Transaction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransactionManager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TreeIndex.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TreeIter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TupleIterator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UserManagerImpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os.Plo@am__quote@ @@ -498,4 +502,6 @@ uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES tags uninstall uninstall-am uninstall-info-am \ uninstall-libLTLIBRARIES +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/storage/PredicateImpl.cxx b/src/storage/PredicateImpl.cxx index 94fe3983..f0694c0a 100644 --- a/src/storage/PredicateImpl.cxx +++ b/src/storage/PredicateImpl.cxx @@ -255,6 +255,48 @@ bool PredicateImpl::pointLookupInvolved(const char *fname) } return false; } +bool PredicateImpl::rangeQueryInvolved(const char *fname) +{ + bool rhsResult, lhsResult; + if (NULL != lhs) + { + lhsResult = lhs->rangeQueryInvolved(fname); + } + if (NULL != rhs) + { + rhsResult = rhs->rangeQueryInvolved(fname); + } + if (NULL != lhs) + { + switch(logicalOp) + { + case OpAnd: + if (lhsResult || rhsResult) return true; else return false; + break; + case OpOr: + return false; + break; + case OpNot: + default: + return false; + break; + } + } + //Means it is relational expression + //first operand is always field identifier + if (OpLessThan == compOp || OpLessThanEquals == compOp || + OpGreaterThan == compOp || OpGreaterThanEquals == compOp) + { + //for expressions f1 == f2 use full scan, so return false + if(NULL == operand && NULL == operandPtr) return false; + if(0 == strcmp(fldName1, fname)) + { + return true; + } + } + return false; +} + void* PredicateImpl::valPtrForIndexField(const char *fname) { @@ -275,7 +317,7 @@ void* PredicateImpl::valPtrForIndexField(const char *fname) } //Means it is relational expression //first operand is always field identifier - if (OpEquals == compOp) + //if (OpEquals == compOp) { if(0 == strcmp(fldName1, fname)) { @@ -284,3 +326,26 @@ void* PredicateImpl::valPtrForIndexField(const char *fname) } return NULL; } +ComparisionOp PredicateImpl::opForIndexField(const char *fname) +{ + ComparisionOp lhsRet, rhsRet; + if (NULL != lhs) + { + lhsRet = lhs->opForIndexField(fname); + } + if (NULL != rhs) + { + rhsRet = rhs->opForIndexField(fname); + } + if (NULL != lhs) + { + if ( lhsRet != NULL) return lhsRet; + if ( rhsRet != NULL) return rhsRet; + } + if(0 == strcmp(fldName1, fname)) + { + return compOp; + } + return OpInvalidComparisionOp; +} + diff --git a/src/storage/TableImpl.cxx b/src/storage/TableImpl.cxx index 45081ce5..b7c67bc8 100644 --- a/src/storage/TableImpl.cxx +++ b/src/storage/TableImpl.cxx @@ -180,12 +180,22 @@ DbRetVal TableImpl::createPlan() if (pred->pointLookupInvolved(def.fldName_)) { printDebug(DM_Predicate, "point lookup involved for field %s",def.fldName_); - scanType_ = hashIndexScan; + if(hashIndex == info->indType) scanType_ = hashIndexScan; + else scanType_ = treeIndexScan; isPlanCreated = true; useIndex_ = i; } - else + else if (pred->rangeQueryInvolved(def.fldName_)) { + printDebug(DM_Predicate, "range lookup involved for field %s",def.fldName_); + if (treeIndex == info->indType) + { + scanType_ = treeIndexScan; + isPlanCreated = true; + useIndex_ = i; + break; //no composite index for tree index + } + }else { useIndex_ = -1; break; } @@ -451,6 +461,7 @@ DbRetVal TableImpl::deleteTuple() ((Chunk*)chunkPtr_)->free(db_, curTuple_); if (undoFlag) ret = (*trans)->appendUndoLog(sysDB_, DeleteOperation, curTuple_, length_); + iter->prev(); return ret; } @@ -697,8 +708,6 @@ void TableImpl::printSQLIndexString() for (int i = 0; i < numIndexes_ ; i++) { CINDEX *iptr = (CINDEX*) indexPtr_[i]; - //cIndexField.getFieldNameAndType((void*)iptr, fldName, type); - //printf("CREATE INDEX %s on %s ( %s ) ", iptr->indName_, getName(), fldName); printf("CREATE INDEX %s on %s ( ", iptr->indName_, getName()); FieldList fldList; cIndexField.getFieldInfo(iptr, fldList); @@ -711,6 +720,8 @@ void TableImpl::printSQLIndexString() else printf(" ,%s ", def.fldName_); } printf(" ) "); + if (iptr->indexType_ == hashIndex) printf(" HASH "); + else printf(" TREE "); if (((HashIndexInfo*) idxInfo[i])->isUnique) printf(" UNIQUE;\n"); else printf(";\n"); } } diff --git a/src/storage/TreeIndex.cxx b/src/storage/TreeIndex.cxx new file mode 100644 index 00000000..bd137233 --- /dev/null +++ b/src/storage/TreeIndex.cxx @@ -0,0 +1,518 @@ +/*************************************************************************** + * Copyright (C) 2007 by www.databasecache.com * + * Contact: praba_tuty@databasecache.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + ***************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +DbRetVal TreeIndex::insert(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *indInfo, void *tuple, bool undoFlag) +{ + printDebug(DM_TreeIndex, "\nInside TreeNode::Insert - 1"); + HashIndexInfo *info = (HashIndexInfo*) indInfo; + CINDEX *iptr = (CINDEX*)indexPtr; + TreeNode *start = (TreeNode*) iptr->hashNodeChunk_; + DbRetVal rc = OK; + int offset = info->fldOffset; + DataType type = info->type; + printDebug(DM_TreeIndex, "Inserting tree index node for %s", iptr->indName_); + void *keyPtr =(void*)((char*)tuple + offset); + if (start == NULL) + { + //TODO::there is chance that two threads can insert first node at + //same time causing the first tree node to leak. + printDebug(DM_TreeIndex, "\nInside if - start=NULL"); + Chunk *chunk = (Chunk*) iptr->chunkPtr_; + TreeNode *tnode = (TreeNode*) chunk->allocate(tbl->db_, &rc); + if (tnode == NULL) + { + printDebug(DM_TreeIndex, "\nExit TreeNode::Insert - 1 tnode=NULL"); + return rc; + } + tnode->mutex_.init(); + tnode->min_ = tuple; + tnode->max_ = tuple; + tnode->noElements_ =1; + tnode->next_ = NULL; + tnode->prev_ = NULL; + tnode->balance_ = 0; + char **rec = (char**)((char*) tnode + sizeof(TreeNode)); + printDebug(DM_TreeIndex, "\nStoring first record at %x\n", rec); + *rec = (char*) tuple; + iptr->hashNodeChunk_ = tnode; + }else { + start->insert(tbl->db_, indInfo, indexPtr, tuple); + } + + printDebug(DM_TreeIndex, "\nExit TreeNode::Insert - 1"); + return rc; +} +void TreeNode::displayAll(int fldOffset) +{ + TreeNode *iter = this; + int loc=0; + while(iter->prev_) + { + printf("PRABA::ITERATING\n"); + iter = iter->prev_; + } + printf("\nDISPLAY NODES:START\n"); + while(iter != NULL) + { + char **rec = (char**)((char*) iter + sizeof(TreeNode)); + printf("\n>>>"); + for(loc=0;locnoElements_;loc++) + { + printf("%d,",*((int*)((char*) *(rec + loc )+fldOffset))); + } + iter = iter->next_; + } + printf("-----\n"); + printf("DISPLAY NODES:END\n"); +} +void TreeNode::displayAll(IndexInfo *indInfo, void *indexPtr) +{ + HashIndexInfo *info = (HashIndexInfo*) indInfo; + CINDEX *iptr = (CINDEX*)indexPtr; + TreeNode *start = (TreeNode*) iptr->hashNodeChunk_; + int offset = info->fldOffset; + DataType type = info->type; + int noOfBuckets = info->noOfBuckets; + TreeNode *iter =start; + int loc=0; + while(iter->prev_) + { + iter = iter->prev_; + } + printf("\nDISPLAY NODES:START\n"); + while(iter != NULL) + { + char **rec = (char**)((char*) iter + sizeof(TreeNode)); + printf("\n>>>"); + for(loc=0;locnoElements_;loc++) + { + printf("%d,",*((int*)((char*) *(rec + loc )+info->fldOffset))); + } + iter = iter->next_; + } + printf("-----\n"); + printf("DISPLAY NODES:END\n"); +} +DbRetVal TreeNode::insert(Database *db, IndexInfo *indInfo, void *indexPtr, void *tuple) +{ + HashIndexInfo *info = (HashIndexInfo*) indInfo; + CINDEX *iptr = (CINDEX*)indexPtr; + TreeNode *start = (TreeNode*) iptr->hashNodeChunk_; + int offset = info->fldOffset; + DataType type = info->type; + int noOfBuckets = info->noOfBuckets; + TreeNode *iter =start; void *record = NULL; + TreeNode *prev = start; + char *keyVal = (char*) tuple + info->fldOffset; + DbRetVal rc = OK; + bool recordInserted = false; + printDebug(DM_TreeIndex, "\nInside TreeNode::Insert - 2"); + int count =0; + int direction = 0; //0:current,1:right,2:rightLeft,-1:left,-2:leftRight + while(iter != NULL) + { + record = ((char*)iter->max_)+ info->fldOffset; + printDebug(DM_TreeIndex, "\n%d---%d", *((int*)keyVal), *((int*)record)); + bool result = AllDataType::compareVal(keyVal, record, OpGreaterThan, + info->type, info->compLength); + if (result) + { + if(direction == -1) + { + direction = -2; + break; + } + direction = 1; + prev = iter; + iter = iter->next_; + printDebug(DM_TreeIndex, "\n2Insert- > "); + }else + { + record = ((char*)iter->min_)+ info->fldOffset; + result = AllDataType::compareVal(keyVal, record, OpLessThan, + info->type, info->compLength); + if (result) { + if(direction == 1) + { + direction = 2; + break; + } + direction = -1; + prev = iter; + iter = iter->prev_; + printDebug(DM_TreeIndex, "\n2Insert- < "); + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- = "); + direction=0; + break; + } + } + } + + if(direction == 2) + { + //Check the size of the prev node.... + //if not full then move the iter to prev and call insertLast() + //else call insertFirst(); + + if((iter->prev_ != NULL) && (iter->prev_->noElements_ < noOfBuckets) ) + { + printDebug(DM_TreeIndex, "\n2Insert- d=2 if "); + iter = iter->prev_; + insert(1, db, indInfo, iptr, tuple, iter); + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- d=2 else "); + insert(-1, db, indInfo, iptr, tuple, iter); + } + } + else if(direction == 1) + { + iter = prev; + if((iter->noElements_ >= noOfBuckets) && (iter->next_ != NULL) + && (iter->next_->noElements_ < noOfBuckets) ) + { + printDebug(DM_TreeIndex, "\n2Insert- d=1 if "); + iter = iter->next_; + insert(-1, db, indInfo, iptr, tuple, iter); + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- d=1 else "); + insert(1, db, indInfo, iptr, tuple, iter); + } + } + else if(direction == -2) + { + if(iter->next_ != NULL && iter->next_->noElements_ < noOfBuckets ) + { + printDebug(DM_TreeIndex, "\n2Insert- d=-2 if "); + iter = iter->next_; + insert(-1, db, indInfo, iptr, tuple, iter); + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- d=-2 else "); + insert(1, db, indInfo, iptr, tuple, iter); + } + } + else if(direction == -1) + { + iter = prev; + if((iter->noElements_ >= noOfBuckets) && (iter->prev_ != NULL) + && (iter->prev_->noElements_ < noOfBuckets) ) + { + printDebug(DM_TreeIndex, "\n2Insert- d=-1 if "); + iter = iter->prev_; + insert(1, db, indInfo, iptr, tuple, iter); + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- d=-1 else "); + insert(-1, db, indInfo, iptr, tuple, iter); + } + } + else + { + printDebug(DM_TreeIndex, "\n2Insert- d=0 "); + insert(0, db, indInfo, iptr, tuple, iter); + } + printDebug(DM_TreeIndex, "\n %d While ..Exit TreeNode::Insert - 2",count); + return OK; +} +DbRetVal TreeNode::insert(int position, Database * db, IndexInfo * indInfo, + CINDEX * iptr, void * tuple, TreeNode * iter) +{ + //position--- -1:First,0:Middle,1:Last + + HashIndexInfo *info = (HashIndexInfo*) indInfo; + TreeNode *start = (TreeNode*) iptr->hashNodeChunk_; + int offset = info->fldOffset; + DataType type = info->type; + int noOfBuckets = info->noOfBuckets; + void *record = NULL; + TreeNode *prev = start; + TreeNode *next = start; + char *keyVal = (char*) tuple + info->fldOffset; + DbRetVal rc = OK; + bool recordInserted = false; + iter->mutex_.getLock(db->procSlot); + if(position == -1) + { + if(iter->noElements_ >= noOfBuckets) + { + Chunk *chunk = (Chunk*) iptr->chunkPtr_; + TreeNode *tnode = (TreeNode*) chunk->allocate(db, &rc); + if (tnode == NULL) + { + printDebug(DM_TreeIndex, "\nExit TreeNode::Insert Position tnode=NULL"); + return rc; + } + tnode->mutex_.init(); + tnode->min_ = tuple; + tnode->max_ = tuple; + tnode->noElements_ =1; + tnode->next_ = iter; + tnode->prev_ = iter->prev_; + iter->prev_ = tnode; + tnode->balance_ = 0; + char **rec = (char**)((char*)tnode + sizeof(TreeNode)); + *rec = (char*) tuple; + } + else + { + printDebug(DM_TreeIndex, "\n3Insert- p=-1 else "); + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + char *tmp = (char *)malloc(sizeof(void **) * iter->noElements_); + memcpy(tmp, (char*)rec, sizeof(void **)* iter->noElements_); + memcpy((char*)rec + sizeof(void **), tmp, sizeof(void **) * (iter->noElements_)); + free(tmp); + iter->min_ = tuple; + iter->noElements_++; + *rec = (char*) tuple; + } + } + else if(position == 1) + { + if(iter->noElements_ >= noOfBuckets) + { + printDebug(DM_TreeIndex, "\n3Insert- p=1 if "); + Chunk *chunk = (Chunk*) iptr->chunkPtr_; + TreeNode *tnode = (TreeNode*) chunk->allocate(db, &rc); + if (tnode == NULL) + { + printDebug(DM_TreeIndex, "\nExit TreeNode::Insert Position tnode=NULL"); + return rc; + } + tnode->mutex_.init(); + tnode->min_ = tuple; + tnode->max_ = tuple; + tnode->noElements_ =1; + tnode->next_ = iter->next_; + tnode->prev_ = iter; + iter->next_ = tnode; + if(tnode->next_) + { + tnode->next_->prev_ = tnode; + } + tnode->balance_ = 0; + char **rec = (char**)((char*)tnode + sizeof(TreeNode)); + *rec = (char*) tuple; + } + else + { + printDebug(DM_TreeIndex, "\n3Insert- p=1 else "); + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + rec = (char **)((char *)rec + (iter->noElements_ * sizeof(void **))); + iter->max_ = tuple; + iter->noElements_++; + *rec = (char*) tuple; + rec = (char**)((char*)iter + sizeof(TreeNode)); + rec = (char**)((char *)rec + ((iter->noElements_-1) * sizeof(void **))); + } + } + else + { + printDebug(DM_TreeIndex, "\n3Insert- p=0 "); + + int start = 0; + int end = iter->noElements_ - 1; + int middle; + int loc = 0; + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + char *tmp = NULL; + loc=0; + for(middle = (start + end) / 2; start <= end ; middle = (start +end )/2) + { + loc = middle; + record = ((char*)*(rec+middle)) + info->fldOffset; + printDebug(DM_TreeIndex, "\n3Insert- p=0 get record \n"); + printDebug(DM_TreeIndex, "%d-%d\n\n", *((int*)keyVal), *((int*)record)); + bool res = AllDataType::compareVal(keyVal, record, OpEquals, info->type, info->compLength); + if(res) + { + loc = middle; + break; + } + res = AllDataType::compareVal(keyVal, record, OpLessThan, info->type, info->compLength); + if(res ) + { + end = middle - 1; + } + else + { + start = middle + 1; + loc = start; + } + } + if(iter->noElements_ >= noOfBuckets) + { + printDebug(DM_TreeIndex, "\n3Insert- p=0 if "); + Chunk *chunk = (Chunk*) iptr->chunkPtr_; + TreeNode *tnode = (TreeNode*) chunk->allocate(db, &rc); + if (tnode == NULL) + { + printDebug(DM_TreeIndex, "\nExit TreeNode::Insert Position tnode=NULL"); + return rc; + } + tnode->mutex_.init(); + tnode->next_ = iter->next_; + tnode->prev_ = iter; + iter->next_ = tnode; + if(tnode->next_) + { + tnode->next_->prev_ = tnode; + } + tnode->balance_ = 0; + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + char *tmp = (char *)malloc(sizeof(void *) * (iter->noElements_ - loc)); + memcpy(tmp, (char*)rec + (loc * sizeof(void *)), sizeof(void *) * (iter->noElements_ - loc));///////// Check the type cast char * + rec = (char**)((char *)rec + (loc * sizeof(void *))); + *rec = (char*)tuple; + tnode->noElements_ = iter->noElements_ - loc; + iter->noElements_ = loc + 1; + rec = (char**)((char*)iter + sizeof(TreeNode)); + iter->min_ = *rec; + iter->max_ = tuple; + rec = (char**)((char*)tnode + sizeof(TreeNode)); + memcpy((char*)rec, tmp, (tnode->noElements_) * sizeof(void *)); + tnode->min_ = *rec; + rec = (char**)((char *)rec + ((tnode->noElements_ - 1) * sizeof(void *))); + tnode->max_ = *rec ; + free(tmp); + } + else + { + printDebug(DM_TreeIndex, "\n3Insert- p=0 else pos-%d",loc); + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + char *tmp = (char *)malloc(sizeof(void *) * (iter->noElements_ - loc)); + memcpy(tmp, (char*)rec + (loc * sizeof(void *)), sizeof(void *) * (iter->noElements_ - loc));///////// Check the type cast char * + memcpy((char*)rec + ((loc+1) * sizeof(void *)), tmp, sizeof(void *) * (iter->noElements_ - loc)); + free(tmp); + if(loc==0) + { + iter->min_ = tuple; + } + iter->noElements_++; + rec = (char **)((char*)rec + (loc * sizeof(void *))); + *rec = (char*)tuple; + } + } + iter->mutex_.releaseLock(db->procSlot); + return rc; +} + +DbRetVal TreeIndex::remove(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *indInfo, void *tuple, bool undoFlag) +{ + printf("Tree index remove called\n"); + HashIndexInfo *info = (HashIndexInfo*) indInfo; + CINDEX *iptr = (CINDEX*)indexPtr; + TreeNode *start = (TreeNode*) iptr->hashNodeChunk_; + TreeNode *iter = locateNode(start, tuple, indInfo); + if (NULL == iter) return OK; //element not found + removeElement(iter, tuple, info); + return OK; +} +TreeNode* TreeIndex::locateNode(TreeNode *iter, void *tuple, IndexInfo *indInfo) +{ + HashIndexInfo *info = (HashIndexInfo*) indInfo; + void *searchKey =(void*)((char*)tuple + info->fldOffset); + while(iter != NULL) + { + char *record = ((char*)iter->max_)+ info->fldOffset; + bool result = AllDataType::compareVal(searchKey, record, + OpGreaterThan, + info->type, info->compLength); + if (result) + { + iter = iter->next_; + }else + { + record = ((char*)iter->min_)+ info->fldOffset; + result = AllDataType::compareVal(searchKey, record, + OpGreaterThanEquals, + info->type, info->compLength); + if (result) { + //current node contains the key + return iter; + } + else + { + //need to move left + iter = iter->prev_; + } + } + } + return NULL; +} +DbRetVal TreeIndex::removeElement(TreeNode *iter, void *tuple, HashIndexInfo *info) +{ + void *searchKey =(void*)((char*)tuple + info->fldOffset); + int loc=0, middle=0, start=0, end=iter->noElements_-1; + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + for(middle = (start + end) / 2; start <= end ; middle = (start +end )/2) + { + loc = middle; + char *record = ((char*)*(rec+middle)) + info->fldOffset; + bool res = AllDataType::compareVal(searchKey, record, OpEquals, + info->type, info->compLength); + if(res) + { + loc = middle; + break; + } + res = AllDataType::compareVal(searchKey, record, OpLessThan, + info->type, info->compLength); + if(res) + { + end = middle - 1; + } + else + { + start = middle + 1; + loc = start; + } + } + char *tmp = (char *)malloc(sizeof(void *) * (iter->noElements_ - loc)); + memcpy(tmp, (char*)rec + ((loc+1) * sizeof(void *)), sizeof(void *) * (iter->noElements_ - loc)); + memcpy((char*)rec + ((loc) * sizeof(void *)), tmp, sizeof(void *) * (iter->noElements_ - loc)); + free(tmp); + if(loc==0) + { + iter->min_ = tuple; + } + //TODO::if noElement is zero then deallocate the tree node + iter->noElements_--; + return OK; +} + + +DbRetVal TreeIndex::update(TableImpl *tbl, Transaction *tr, void *indexPtr, IndexInfo *indInfo, void *tuple, bool undoFlag) +{ + return ErrNotYet; +} + diff --git a/src/storage/TreeIter.cxx b/src/storage/TreeIter.cxx new file mode 100644 index 00000000..e91b97be --- /dev/null +++ b/src/storage/TreeIter.cxx @@ -0,0 +1,155 @@ +/*************************************************************************** + * Copyright (C) 2007 by www.databasecache.com * + * Contact: praba_tuty@databasecache.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + ***************************************************************************/ +#include +#include + +void* TreeIter::prev() +{ + if (0 != nodeOffset ) + { + nodeOffset--; + + }else + { + iter=iter->prev_; + if (NULL == iter) return NULL; + nodeOffset = iter->noElements_; + } + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + rec = (char**)((char *)rec + ((nodeOffset) * sizeof(void **))); + return *rec; +} +void* TreeIter::next() +{ + int direction=0; + if (recordsOver) return NULL; + if (NULL== iter) return NULL; + if (firstCall) + { + if (OpLessThan ==op || OpLessThanEquals == op) + { + while(iter->prev_) + { + iter = iter->prev_; + } + firstCall = false; + nodeOffset = 1; + char **rec = (char**)((char*) iter + sizeof(TreeNode)); + iter->displayAll(fldOffset); + return *rec; + } + else if (OpGreaterThan == op || OpGreaterThanEquals == op || + OpEquals == op) + { + void *rec = locateNode(); + firstCall = false; + iter->displayAll(fldOffset); + return rec; + } + firstCall = false; + }else + { + if (nodeOffset == iter->noElements_) + { + if (NULL == iter->next_) {recordsOver = true; return NULL;} + char* record = ((char*)iter->next_->min_)+ fldOffset; + bool result = AllDataType::compareVal(searchKey, record, + OpGreaterThanEquals, + type, length); + if (!result && (OpLessThan ==op || OpLessThanEquals == op)) + { + recordsOver= true; return NULL; + }else if (result && (OpGreaterThan == op || + OpGreaterThanEquals == op)) + { + recordsOver= true; return NULL; + } + iter=iter->next_; + if (NULL == iter) return NULL; + nodeOffset=0; + } + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + rec = (char**)((char *)rec + ((nodeOffset) * sizeof(void **))); + nodeOffset++; + return *rec; + } + return NULL; +} +void* TreeIter::locateNode() +{ + while(iter != NULL) + { + char *record = ((char*)iter->max_)+ fldOffset; + bool result = AllDataType::compareVal(searchKey, record, + OpGreaterThan, + type, length); + if (result) + { + //need to move right + iter = iter->next_; + }else + { + record = ((char*)iter->min_)+ fldOffset; + result = AllDataType::compareVal(searchKey, record, + OpGreaterThanEquals, + type, length); + if (result) { + //current node contains the key + void *rec = locateElement(); + return rec; + } + else + { + //need to move left + iter = iter->prev_; + } + } + } + return NULL; +} +void* TreeIter::locateElement() +{ + //do binary search and locate the element + int loc=0, middle=0, start=0, end=iter->noElements_-1; + char **rec = (char**)((char*)iter + sizeof(TreeNode)); + for(middle = (start + end) / 2; start <= end ; middle = (start +end )/2) + { + loc = middle; + char *record = ((char*)*(rec+middle)) + fldOffset; + bool res = AllDataType::compareVal(searchKey, record, OpEquals, + type, length); + if(res) + { + loc = middle; + break; + } + res = AllDataType::compareVal(searchKey, record, OpLessThan, + type, length); + if(res) + { + end = middle - 1; + } + else + { + start = middle + 1; + loc = start; + } + } + nodeOffset=loc; + char **tuple = (char**)((char*)rec + (loc * sizeof(void *))); + nodeOffset++; + return *tuple; +} diff --git a/src/storage/TupleIterator.cxx b/src/storage/TupleIterator.cxx index 2ef266d4..908191e8 100644 --- a/src/storage/TupleIterator.cxx +++ b/src/storage/TupleIterator.cxx @@ -64,11 +64,47 @@ DbRetVal TupleIterator::open() printDebug(DM_HashIndex, "open:head for bucket %x is :%x", bucket, head); bIter = new BucketIter(head); bucket->mutex_.releaseLock(procSlot); - + }else if (treeIndexScan == scanType_) + { + HashIndexInfo *hIdxInfo = (HashIndexInfo*)info; + PredicateImpl *predImpl = (PredicateImpl*) pred_; + bool isPtr = false; + FieldIterator iter = hIdxInfo->idxFldList.getIterator(); + void *keyPtr; ComparisionOp op; + if(iter.hasElement()) + { + FieldDef def = iter.nextElement(); + keyPtr = (void*)predImpl->valPtrForIndexField(def.fldName_); + op = predImpl->opForIndexField(def.fldName_); + } + CINDEX *iptr = (CINDEX*) hIdxInfo->indexPtr; + tIter = new TreeIter((TreeNode*)iptr->hashNodeChunk_); + tIter->setSearchKey(keyPtr, op); + tIter->setFldOffset(hIdxInfo->fldOffset); + tIter->setTypeLength(hIdxInfo->type, hIdxInfo->compLength); } + + return OK; } +//not returing previous tuple for all iterators and for tree iterator. +//it just decrements the nodeOffset for tree iterator. +void* TupleIterator::prev() +{ + PredicateImpl *predImpl = (PredicateImpl*) pred_; + void *tuple = NULL; + if (treeIndexScan == scanType_) + { + if (NULL == tIter) return NULL; + tuple = tIter->prev(); + predImpl->setTuple(tuple); + if(NULL == tuple) { + printDebug(DM_HashIndex, "prev::tuple is null"); + } + } + return tuple; +} void* TupleIterator::next() { @@ -128,6 +164,21 @@ void* TupleIterator::next() // return tuple; } + }else if (treeIndexScan == scanType_) + { + if (NULL == tIter) return NULL; + bool result = false; + while (!result) + { + tuple = tIter->next(); + if(NULL == tuple) { + printDebug(DM_HashIndex, "next::tuple is null"); + return NULL; + } + predImpl->setTuple(tuple); + rv = predImpl->evaluate(result); + if (rv != OK) return NULL; + } } return tuple; } @@ -142,7 +193,12 @@ DbRetVal TupleIterator::close() { delete bIter; bIter = NULL; - } + } else if (scanType_ == treeIndexScan) + { + delete tIter; + tIter = NULL; + } + scanType_ = unknownScan; return OK; } diff --git a/test/cache/Bidirectional/test001.ksh b/test/cache/Bidirectional/test001.ksh index e8532ae4..a227961d 100755 --- a/test/cache/Bidirectional/test001.ksh +++ b/test/cache/Bidirectional/test001.ksh @@ -49,7 +49,7 @@ isql myodbc3 < ${REL_PATH}/drop.sql >/dev/null 2>&1 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db touch /tmp/csql/csqltable.conf /tmp/csql/csql.db -kill -2 $pid +kill -9 $pid ipcrm -M 4000 -M 4500 exit 0; diff --git a/test/cache/Bidirectional/test013.ksh b/test/cache/Bidirectional/test013.ksh index 6914b036..07ccdc58 100755 --- a/test/cache/Bidirectional/test013.ksh +++ b/test/cache/Bidirectional/test013.ksh @@ -72,7 +72,7 @@ done >> /tmp/csql/csqltable.conf $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 & pid=$! -sleep 5 +sleep 30 echo "server started" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql @@ -91,7 +91,7 @@ fi echo "Insert some record in target database" isql myodbc3 < ${REL_PATH}/insertinto100.sql >/dev/null 2>&1 -sleep 15 +sleep 30 echo "Records in csql after insert in target DB" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql diff --git a/test/cache/Bidirectional/test014.ksh b/test/cache/Bidirectional/test014.ksh index 203d18a1..900f6be8 100755 --- a/test/cache/Bidirectional/test014.ksh +++ b/test/cache/Bidirectional/test014.ksh @@ -71,7 +71,7 @@ done >> /tmp/csql/csqltable.conf $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 & pid=$! -sleep 5 +sleep 30 echo "server started" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql @@ -90,7 +90,7 @@ fi echo "Update some record in target database" isql myodbc3 < ${REL_PATH}/update100table.sql >/dev/null 2>&1 -sleep 15 +sleep 30 echo "Records in csql after update in target DB" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql diff --git a/test/cache/Bidirectional/test015.ksh b/test/cache/Bidirectional/test015.ksh index 5f04852c..b230254f 100755 --- a/test/cache/Bidirectional/test015.ksh +++ b/test/cache/Bidirectional/test015.ksh @@ -71,7 +71,7 @@ done >> /tmp/csql/csqltable.conf $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 & pid=$! -sleep 5 +sleep 30 echo "server started" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql @@ -90,7 +90,7 @@ fi echo "Delete some record in target database" isql myodbc3 < ${REL_PATH}/deletefrom100table.sql >/dev/null 2>&1 -sleep 15 +sleep 30 echo "Records in csql after Delete some recode from target DB" $CSQL_INSTALL_ROOT/bin/csql -s $REL_PATH/selectfrom100.sql diff --git a/test/cache/CacheTable/exp.test003.ksh b/test/cache/CacheTable/exp.test003.ksh index 502e3d15..6303076c 100644 --- a/test/cache/CacheTable/exp.test003.ksh +++ b/test/cache/CacheTable/exp.test003.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 SMALLINT NOT NULL , f2 INT ); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1111); INSERT INTO t1 VALUES(2,2222); diff --git a/test/cache/CacheTable/exp.test008.ksh b/test/cache/CacheTable/exp.test008.ksh index 8880850b..e064ae9b 100644 --- a/test/cache/CacheTable/exp.test008.ksh +++ b/test/cache/CacheTable/exp.test008.ksh @@ -1,11 +1,11 @@ CREATE TABLE t1 (f1 SMALLINT NOT NULL , f2 INT ); -CREATE INDEX t1_PRIMARY on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_PRIMARY on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1111); INSERT INTO t1 VALUES(2,2222); COMMIT; CREATE TABLE t1 (f1 SMALLINT NOT NULL , f2 INT ); -CREATE INDEX t1_PRIMARY on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_PRIMARY on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1111); INSERT INTO t1 VALUES(2,2222); diff --git a/test/cache/CacheTable/inputtest4.sql b/test/cache/CacheTable/inputtest4.sql index 394f3f2d..9658c505 100644 --- a/test/cache/CacheTable/inputtest4.sql +++ b/test/cache/CacheTable/inputtest4.sql @@ -1,3 +1,4 @@ +drop table t1; CREATE TABLE t1 (f1 SMALLINT, f2 INT, primary key (f1)); INSERT INTO t1 VALUES(1, 1111); INSERT INTO t1 VALUES(2, 2222); diff --git a/test/cache/Recovery/exp.test002.ksh b/test/cache/Recovery/exp.test002.ksh index 50a466ea..c7a4faf7 100644 --- a/test/cache/Recovery/exp.test002.ksh +++ b/test/cache/Recovery/exp.test002.ksh @@ -1,203 +1,203 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t1_PRIMARY on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_PRIMARY on t1 ( f1 ) HASH UNIQUE; CREATE TABLE t2 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t2_PRIMARY on t2 ( f1 ) UNIQUE; +CREATE INDEX t2_PRIMARY on t2 ( f1 ) HASH UNIQUE; CREATE TABLE t3 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t3_PRIMARY on t3 ( f1 ) UNIQUE; +CREATE INDEX t3_PRIMARY on t3 ( f1 ) HASH UNIQUE; CREATE TABLE t4 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t4_PRIMARY on t4 ( f1 ) UNIQUE; +CREATE INDEX t4_PRIMARY on t4 ( f1 ) HASH UNIQUE; CREATE TABLE t5 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t5_PRIMARY on t5 ( f1 ) UNIQUE; +CREATE INDEX t5_PRIMARY on t5 ( f1 ) HASH UNIQUE; CREATE TABLE t6 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t6_PRIMARY on t6 ( f1 ) UNIQUE; +CREATE INDEX t6_PRIMARY on t6 ( f1 ) HASH UNIQUE; CREATE TABLE t7 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t7_PRIMARY on t7 ( f1 ) UNIQUE; +CREATE INDEX t7_PRIMARY on t7 ( f1 ) HASH UNIQUE; CREATE TABLE t8 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t8_PRIMARY on t8 ( f1 ) UNIQUE; +CREATE INDEX t8_PRIMARY on t8 ( f1 ) HASH UNIQUE; CREATE TABLE t9 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t9_PRIMARY on t9 ( f1 ) UNIQUE; +CREATE INDEX t9_PRIMARY on t9 ( f1 ) HASH UNIQUE; CREATE TABLE t10 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t10_PRIMARY on t10 ( f1 ) UNIQUE; +CREATE INDEX t10_PRIMARY on t10 ( f1 ) HASH UNIQUE; CREATE TABLE t11 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t11_PRIMARY on t11 ( f1 ) UNIQUE; +CREATE INDEX t11_PRIMARY on t11 ( f1 ) HASH UNIQUE; CREATE TABLE t12 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t12_PRIMARY on t12 ( f1 ) UNIQUE; +CREATE INDEX t12_PRIMARY on t12 ( f1 ) HASH UNIQUE; CREATE TABLE t13 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t13_PRIMARY on t13 ( f1 ) UNIQUE; +CREATE INDEX t13_PRIMARY on t13 ( f1 ) HASH UNIQUE; CREATE TABLE t14 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t14_PRIMARY on t14 ( f1 ) UNIQUE; +CREATE INDEX t14_PRIMARY on t14 ( f1 ) HASH UNIQUE; CREATE TABLE t15 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t15_PRIMARY on t15 ( f1 ) UNIQUE; +CREATE INDEX t15_PRIMARY on t15 ( f1 ) HASH UNIQUE; CREATE TABLE t16 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t16_PRIMARY on t16 ( f1 ) UNIQUE; +CREATE INDEX t16_PRIMARY on t16 ( f1 ) HASH UNIQUE; CREATE TABLE t17 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t17_PRIMARY on t17 ( f1 ) UNIQUE; +CREATE INDEX t17_PRIMARY on t17 ( f1 ) HASH UNIQUE; CREATE TABLE t18 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t18_PRIMARY on t18 ( f1 ) UNIQUE; +CREATE INDEX t18_PRIMARY on t18 ( f1 ) HASH UNIQUE; CREATE TABLE t19 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t19_PRIMARY on t19 ( f1 ) UNIQUE; +CREATE INDEX t19_PRIMARY on t19 ( f1 ) HASH UNIQUE; CREATE TABLE t20 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t20_PRIMARY on t20 ( f1 ) UNIQUE; +CREATE INDEX t20_PRIMARY on t20 ( f1 ) HASH UNIQUE; CREATE TABLE t21 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t21_PRIMARY on t21 ( f1 ) UNIQUE; +CREATE INDEX t21_PRIMARY on t21 ( f1 ) HASH UNIQUE; CREATE TABLE t22 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t22_PRIMARY on t22 ( f1 ) UNIQUE; +CREATE INDEX t22_PRIMARY on t22 ( f1 ) HASH UNIQUE; CREATE TABLE t23 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t23_PRIMARY on t23 ( f1 ) UNIQUE; +CREATE INDEX t23_PRIMARY on t23 ( f1 ) HASH UNIQUE; CREATE TABLE t24 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t24_PRIMARY on t24 ( f1 ) UNIQUE; +CREATE INDEX t24_PRIMARY on t24 ( f1 ) HASH UNIQUE; CREATE TABLE t25 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t25_PRIMARY on t25 ( f1 ) UNIQUE; +CREATE INDEX t25_PRIMARY on t25 ( f1 ) HASH UNIQUE; CREATE TABLE t26 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t26_PRIMARY on t26 ( f1 ) UNIQUE; +CREATE INDEX t26_PRIMARY on t26 ( f1 ) HASH UNIQUE; CREATE TABLE t27 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t27_PRIMARY on t27 ( f1 ) UNIQUE; +CREATE INDEX t27_PRIMARY on t27 ( f1 ) HASH UNIQUE; CREATE TABLE t28 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t28_PRIMARY on t28 ( f1 ) UNIQUE; +CREATE INDEX t28_PRIMARY on t28 ( f1 ) HASH UNIQUE; CREATE TABLE t29 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t29_PRIMARY on t29 ( f1 ) UNIQUE; +CREATE INDEX t29_PRIMARY on t29 ( f1 ) HASH UNIQUE; CREATE TABLE t30 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t30_PRIMARY on t30 ( f1 ) UNIQUE; +CREATE INDEX t30_PRIMARY on t30 ( f1 ) HASH UNIQUE; CREATE TABLE t31 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t31_PRIMARY on t31 ( f1 ) UNIQUE; +CREATE INDEX t31_PRIMARY on t31 ( f1 ) HASH UNIQUE; CREATE TABLE t32 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t32_PRIMARY on t32 ( f1 ) UNIQUE; +CREATE INDEX t32_PRIMARY on t32 ( f1 ) HASH UNIQUE; CREATE TABLE t33 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t33_PRIMARY on t33 ( f1 ) UNIQUE; +CREATE INDEX t33_PRIMARY on t33 ( f1 ) HASH UNIQUE; CREATE TABLE t34 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t34_PRIMARY on t34 ( f1 ) UNIQUE; +CREATE INDEX t34_PRIMARY on t34 ( f1 ) HASH UNIQUE; CREATE TABLE t35 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t35_PRIMARY on t35 ( f1 ) UNIQUE; +CREATE INDEX t35_PRIMARY on t35 ( f1 ) HASH UNIQUE; CREATE TABLE t36 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t36_PRIMARY on t36 ( f1 ) UNIQUE; +CREATE INDEX t36_PRIMARY on t36 ( f1 ) HASH UNIQUE; CREATE TABLE t37 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t37_PRIMARY on t37 ( f1 ) UNIQUE; +CREATE INDEX t37_PRIMARY on t37 ( f1 ) HASH UNIQUE; CREATE TABLE t38 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t38_PRIMARY on t38 ( f1 ) UNIQUE; +CREATE INDEX t38_PRIMARY on t38 ( f1 ) HASH UNIQUE; CREATE TABLE t39 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t39_PRIMARY on t39 ( f1 ) UNIQUE; +CREATE INDEX t39_PRIMARY on t39 ( f1 ) HASH UNIQUE; CREATE TABLE t40 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t40_PRIMARY on t40 ( f1 ) UNIQUE; +CREATE INDEX t40_PRIMARY on t40 ( f1 ) HASH UNIQUE; CREATE TABLE t41 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t41_PRIMARY on t41 ( f1 ) UNIQUE; +CREATE INDEX t41_PRIMARY on t41 ( f1 ) HASH UNIQUE; CREATE TABLE t42 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t42_PRIMARY on t42 ( f1 ) UNIQUE; +CREATE INDEX t42_PRIMARY on t42 ( f1 ) HASH UNIQUE; CREATE TABLE t43 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t43_PRIMARY on t43 ( f1 ) UNIQUE; +CREATE INDEX t43_PRIMARY on t43 ( f1 ) HASH UNIQUE; CREATE TABLE t44 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t44_PRIMARY on t44 ( f1 ) UNIQUE; +CREATE INDEX t44_PRIMARY on t44 ( f1 ) HASH UNIQUE; CREATE TABLE t45 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t45_PRIMARY on t45 ( f1 ) UNIQUE; +CREATE INDEX t45_PRIMARY on t45 ( f1 ) HASH UNIQUE; CREATE TABLE t46 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t46_PRIMARY on t46 ( f1 ) UNIQUE; +CREATE INDEX t46_PRIMARY on t46 ( f1 ) HASH UNIQUE; CREATE TABLE t47 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t47_PRIMARY on t47 ( f1 ) UNIQUE; +CREATE INDEX t47_PRIMARY on t47 ( f1 ) HASH UNIQUE; CREATE TABLE t48 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t48_PRIMARY on t48 ( f1 ) UNIQUE; +CREATE INDEX t48_PRIMARY on t48 ( f1 ) HASH UNIQUE; CREATE TABLE t49 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t49_PRIMARY on t49 ( f1 ) UNIQUE; +CREATE INDEX t49_PRIMARY on t49 ( f1 ) HASH UNIQUE; CREATE TABLE t50 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t50_PRIMARY on t50 ( f1 ) UNIQUE; +CREATE INDEX t50_PRIMARY on t50 ( f1 ) HASH UNIQUE; CREATE TABLE t51 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t51_PRIMARY on t51 ( f1 ) UNIQUE; +CREATE INDEX t51_PRIMARY on t51 ( f1 ) HASH UNIQUE; CREATE TABLE t52 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t52_PRIMARY on t52 ( f1 ) UNIQUE; +CREATE INDEX t52_PRIMARY on t52 ( f1 ) HASH UNIQUE; CREATE TABLE t53 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t53_PRIMARY on t53 ( f1 ) UNIQUE; +CREATE INDEX t53_PRIMARY on t53 ( f1 ) HASH UNIQUE; CREATE TABLE t54 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t54_PRIMARY on t54 ( f1 ) UNIQUE; +CREATE INDEX t54_PRIMARY on t54 ( f1 ) HASH UNIQUE; CREATE TABLE t55 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t55_PRIMARY on t55 ( f1 ) UNIQUE; +CREATE INDEX t55_PRIMARY on t55 ( f1 ) HASH UNIQUE; CREATE TABLE t56 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t56_PRIMARY on t56 ( f1 ) UNIQUE; +CREATE INDEX t56_PRIMARY on t56 ( f1 ) HASH UNIQUE; CREATE TABLE t57 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t57_PRIMARY on t57 ( f1 ) UNIQUE; +CREATE INDEX t57_PRIMARY on t57 ( f1 ) HASH UNIQUE; CREATE TABLE t58 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t58_PRIMARY on t58 ( f1 ) UNIQUE; +CREATE INDEX t58_PRIMARY on t58 ( f1 ) HASH UNIQUE; CREATE TABLE t59 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t59_PRIMARY on t59 ( f1 ) UNIQUE; +CREATE INDEX t59_PRIMARY on t59 ( f1 ) HASH UNIQUE; CREATE TABLE t60 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t60_PRIMARY on t60 ( f1 ) UNIQUE; +CREATE INDEX t60_PRIMARY on t60 ( f1 ) HASH UNIQUE; CREATE TABLE t61 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t61_PRIMARY on t61 ( f1 ) UNIQUE; +CREATE INDEX t61_PRIMARY on t61 ( f1 ) HASH UNIQUE; CREATE TABLE t62 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t62_PRIMARY on t62 ( f1 ) UNIQUE; +CREATE INDEX t62_PRIMARY on t62 ( f1 ) HASH UNIQUE; CREATE TABLE t63 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t63_PRIMARY on t63 ( f1 ) UNIQUE; +CREATE INDEX t63_PRIMARY on t63 ( f1 ) HASH UNIQUE; CREATE TABLE t64 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t64_PRIMARY on t64 ( f1 ) UNIQUE; +CREATE INDEX t64_PRIMARY on t64 ( f1 ) HASH UNIQUE; CREATE TABLE t65 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t65_PRIMARY on t65 ( f1 ) UNIQUE; +CREATE INDEX t65_PRIMARY on t65 ( f1 ) HASH UNIQUE; CREATE TABLE t66 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t66_PRIMARY on t66 ( f1 ) UNIQUE; +CREATE INDEX t66_PRIMARY on t66 ( f1 ) HASH UNIQUE; CREATE TABLE t67 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t67_PRIMARY on t67 ( f1 ) UNIQUE; +CREATE INDEX t67_PRIMARY on t67 ( f1 ) HASH UNIQUE; CREATE TABLE t68 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t68_PRIMARY on t68 ( f1 ) UNIQUE; +CREATE INDEX t68_PRIMARY on t68 ( f1 ) HASH UNIQUE; CREATE TABLE t69 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t69_PRIMARY on t69 ( f1 ) UNIQUE; +CREATE INDEX t69_PRIMARY on t69 ( f1 ) HASH UNIQUE; CREATE TABLE t70 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t70_PRIMARY on t70 ( f1 ) UNIQUE; +CREATE INDEX t70_PRIMARY on t70 ( f1 ) HASH UNIQUE; CREATE TABLE t71 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t71_PRIMARY on t71 ( f1 ) UNIQUE; +CREATE INDEX t71_PRIMARY on t71 ( f1 ) HASH UNIQUE; CREATE TABLE t72 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t72_PRIMARY on t72 ( f1 ) UNIQUE; +CREATE INDEX t72_PRIMARY on t72 ( f1 ) HASH UNIQUE; CREATE TABLE t73 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t73_PRIMARY on t73 ( f1 ) UNIQUE; +CREATE INDEX t73_PRIMARY on t73 ( f1 ) HASH UNIQUE; CREATE TABLE t74 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t74_PRIMARY on t74 ( f1 ) UNIQUE; +CREATE INDEX t74_PRIMARY on t74 ( f1 ) HASH UNIQUE; CREATE TABLE t75 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t75_PRIMARY on t75 ( f1 ) UNIQUE; +CREATE INDEX t75_PRIMARY on t75 ( f1 ) HASH UNIQUE; CREATE TABLE t76 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t76_PRIMARY on t76 ( f1 ) UNIQUE; +CREATE INDEX t76_PRIMARY on t76 ( f1 ) HASH UNIQUE; CREATE TABLE t77 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t77_PRIMARY on t77 ( f1 ) UNIQUE; +CREATE INDEX t77_PRIMARY on t77 ( f1 ) HASH UNIQUE; CREATE TABLE t78 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t78_PRIMARY on t78 ( f1 ) UNIQUE; +CREATE INDEX t78_PRIMARY on t78 ( f1 ) HASH UNIQUE; CREATE TABLE t79 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t79_PRIMARY on t79 ( f1 ) UNIQUE; +CREATE INDEX t79_PRIMARY on t79 ( f1 ) HASH UNIQUE; CREATE TABLE t80 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t80_PRIMARY on t80 ( f1 ) UNIQUE; +CREATE INDEX t80_PRIMARY on t80 ( f1 ) HASH UNIQUE; CREATE TABLE t81 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t81_PRIMARY on t81 ( f1 ) UNIQUE; +CREATE INDEX t81_PRIMARY on t81 ( f1 ) HASH UNIQUE; CREATE TABLE t82 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t82_PRIMARY on t82 ( f1 ) UNIQUE; +CREATE INDEX t82_PRIMARY on t82 ( f1 ) HASH UNIQUE; CREATE TABLE t83 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t83_PRIMARY on t83 ( f1 ) UNIQUE; +CREATE INDEX t83_PRIMARY on t83 ( f1 ) HASH UNIQUE; CREATE TABLE t84 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t84_PRIMARY on t84 ( f1 ) UNIQUE; +CREATE INDEX t84_PRIMARY on t84 ( f1 ) HASH UNIQUE; CREATE TABLE t85 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t85_PRIMARY on t85 ( f1 ) UNIQUE; +CREATE INDEX t85_PRIMARY on t85 ( f1 ) HASH UNIQUE; CREATE TABLE t86 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t86_PRIMARY on t86 ( f1 ) UNIQUE; +CREATE INDEX t86_PRIMARY on t86 ( f1 ) HASH UNIQUE; CREATE TABLE t87 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t87_PRIMARY on t87 ( f1 ) UNIQUE; +CREATE INDEX t87_PRIMARY on t87 ( f1 ) HASH UNIQUE; CREATE TABLE t88 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t88_PRIMARY on t88 ( f1 ) UNIQUE; +CREATE INDEX t88_PRIMARY on t88 ( f1 ) HASH UNIQUE; CREATE TABLE t89 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t89_PRIMARY on t89 ( f1 ) UNIQUE; +CREATE INDEX t89_PRIMARY on t89 ( f1 ) HASH UNIQUE; CREATE TABLE t90 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t90_PRIMARY on t90 ( f1 ) UNIQUE; +CREATE INDEX t90_PRIMARY on t90 ( f1 ) HASH UNIQUE; CREATE TABLE t91 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t91_PRIMARY on t91 ( f1 ) UNIQUE; +CREATE INDEX t91_PRIMARY on t91 ( f1 ) HASH UNIQUE; CREATE TABLE t92 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t92_PRIMARY on t92 ( f1 ) UNIQUE; +CREATE INDEX t92_PRIMARY on t92 ( f1 ) HASH UNIQUE; CREATE TABLE t93 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t93_PRIMARY on t93 ( f1 ) UNIQUE; +CREATE INDEX t93_PRIMARY on t93 ( f1 ) HASH UNIQUE; CREATE TABLE t94 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t94_PRIMARY on t94 ( f1 ) UNIQUE; +CREATE INDEX t94_PRIMARY on t94 ( f1 ) HASH UNIQUE; CREATE TABLE t95 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t95_PRIMARY on t95 ( f1 ) UNIQUE; +CREATE INDEX t95_PRIMARY on t95 ( f1 ) HASH UNIQUE; CREATE TABLE t96 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t96_PRIMARY on t96 ( f1 ) UNIQUE; +CREATE INDEX t96_PRIMARY on t96 ( f1 ) HASH UNIQUE; CREATE TABLE t97 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t97_PRIMARY on t97 ( f1 ) UNIQUE; +CREATE INDEX t97_PRIMARY on t97 ( f1 ) HASH UNIQUE; CREATE TABLE t98 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t98_PRIMARY on t98 ( f1 ) UNIQUE; +CREATE INDEX t98_PRIMARY on t98 ( f1 ) HASH UNIQUE; CREATE TABLE t99 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t99_PRIMARY on t99 ( f1 ) UNIQUE; +CREATE INDEX t99_PRIMARY on t99 ( f1 ) HASH UNIQUE; CREATE TABLE t100 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t100_PRIMARY on t100 ( f1 ) UNIQUE; +CREATE INDEX t100_PRIMARY on t100 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,11); INSERT INTO t1 VALUES(2,21); diff --git a/test/cache/Recovery/exp.test003.ksh b/test/cache/Recovery/exp.test003.ksh index b77c47f0..be1685ed 100644 --- a/test/cache/Recovery/exp.test003.ksh +++ b/test/cache/Recovery/exp.test003.ksh @@ -1,6 +1,6 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t1_PRIMARY on t1 ( f1 ) UNIQUE; -CREATE INDEX t1_idx2 on t1 ( f2 ) ; +CREATE INDEX t1_PRIMARY on t1 ( f1 ) HASH UNIQUE; +CREATE INDEX t1_idx2 on t1 ( f2 ) HASH ; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,11); INSERT INTO t1 VALUES(2,21); diff --git a/test/cache/Recovery/exp.test004.ksh b/test/cache/Recovery/exp.test004.ksh index b77c47f0..be1685ed 100644 --- a/test/cache/Recovery/exp.test004.ksh +++ b/test/cache/Recovery/exp.test004.ksh @@ -1,6 +1,6 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t1_PRIMARY on t1 ( f1 ) UNIQUE; -CREATE INDEX t1_idx2 on t1 ( f2 ) ; +CREATE INDEX t1_PRIMARY on t1 ( f1 ) HASH UNIQUE; +CREATE INDEX t1_idx2 on t1 ( f2 ) HASH ; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,11); INSERT INTO t1 VALUES(2,21); diff --git a/test/cache/Recovery/test002.ksh b/test/cache/Recovery/test002.ksh index 82c5cd5d..c9dddfb2 100755 --- a/test/cache/Recovery/test002.ksh +++ b/test/cache/Recovery/test002.ksh @@ -28,7 +28,7 @@ done >> /tmp/csql/csqltable.conf $CSQL_INSTALL_ROOT/bin/csqlserver -c >/dev/null 2>&1 & pid=$! -sleep 5 +sleep 60 rm -f /tmp/csql/csqltable.conf /tmp/csql/csql.db touch /tmp/csql/csqltable.conf /tmp/csql/csql.db diff --git a/test/tools/csql/exp.test007.ksh b/test/tools/csql/exp.test007.ksh index 3a9b5a22..c48898b7 100644 --- a/test/tools/csql/exp.test007.ksh +++ b/test/tools/csql/exp.test007.ksh @@ -4,6 +4,6 @@ Statement Executed Statement Executed Statement Executed Statement Executed -Statement execute failed with error -17 -Statement execute failed with error -17 +Statement Executed +Statement Executed Statement Executed diff --git a/test/tools/csql/exp.test030.ksh b/test/tools/csql/exp.test030.ksh index c632c35f..57ef1cc1 100644 --- a/test/tools/csql/exp.test030.ksh +++ b/test/tools/csql/exp.test030.ksh @@ -46,7 +46,7 @@ echo select * from t1 where f1=10 and f2=6 and f3=10; --------------------------------------------------------- CREATE TABLE t1 (f1 INT NOT NULL , f2 INT NOT NULL , f3 INT ); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ,f2 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ,f2 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1,1); INSERT INTO t1 VALUES(2,1,2); diff --git a/test/tools/csql/exp.test031.ksh b/test/tools/csql/exp.test031.ksh index 366da6cb..c615d2a9 100644 --- a/test/tools/csql/exp.test031.ksh +++ b/test/tools/csql/exp.test031.ksh @@ -48,7 +48,7 @@ echo select * from t1 where f1=10 and f2=6 and f3=10; --------------------------------------------------------- CREATE TABLE t1 (f1 INT NOT NULL , f2 INT NOT NULL , f3 INT ); -CREATE INDEX idx on t1 ( f1 ,f2 ) ; +CREATE INDEX idx on t1 ( f1 ,f2 ) HASH ; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1,1); INSERT INTO t1 VALUES(2,1,2); diff --git a/test/tools/csql/exp.test032.ksh b/test/tools/csql/exp.test032.ksh index 8dd85298..ce557b89 100644 --- a/test/tools/csql/exp.test032.ksh +++ b/test/tools/csql/exp.test032.ksh @@ -47,7 +47,7 @@ echo select * from t1 where f1=10 and f2=6 and f3=10; --------------------------------------------------------- CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (10) NOT NULL , f3 INT ); -CREATE INDEX idx on t1 ( f1 ,f2 ) UNIQUE; +CREATE INDEX idx on t1 ( f1 ,f2 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1, '1',1); INSERT INTO t1 VALUES(2, '1',2); diff --git a/test/tools/csql/exp.test033.ksh b/test/tools/csql/exp.test033.ksh index 2f45a35b..cff205b2 100644 --- a/test/tools/csql/exp.test033.ksh +++ b/test/tools/csql/exp.test033.ksh @@ -1,5 +1,5 @@ Statement Executed -Statement execute failed with error -17 +Statement Executed Statement Executed: Rows Affected = 1 Statement Executed: Rows Affected = 1 echo select count(f1) from t1; @@ -9,6 +9,7 @@ echo select count(f1) from t1; 2 CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (10) NOT NULL , f3 INT ); +CREATE INDEX idx on t1 ( f1 ,f2 ) TREE UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1, '1',1); INSERT INTO t1 VALUES(3, '1',3); diff --git a/test/tools/csql/exp.test034.ksh b/test/tools/csql/exp.test034.ksh index d9f72e20..40f29fee 100644 --- a/test/tools/csql/exp.test034.ksh +++ b/test/tools/csql/exp.test034.ksh @@ -19,7 +19,7 @@ echo select * from t1 where f1 = 5; 5 5 CREATE TABLE t1 (f1 INT , f2 INT ); -CREATE INDEX ind on t1 ( f1 ) ; +CREATE INDEX ind on t1 ( f1 ) HASH ; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(1,1); INSERT INTO t1 VALUES(1,2); diff --git a/test/tools/csqldump/exp.test002.ksh b/test/tools/csqldump/exp.test002.ksh index 84f243d4..0507ef7c 100644 --- a/test/tools/csqldump/exp.test002.ksh +++ b/test/tools/csqldump/exp.test002.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (30)); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(51, 'Praba'); INSERT INTO t1 VALUES(2, 'Lakshya2'); diff --git a/test/tools/csqldump/exp.test003.ksh b/test/tools/csqldump/exp.test003.ksh index 56570e14..34ba2f11 100644 --- a/test/tools/csqldump/exp.test003.ksh +++ b/test/tools/csqldump/exp.test003.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (30)); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(123, 'india'); INSERT INTO t1 VALUES(72, 'Lakshya72'); diff --git a/test/tools/csqldump/exp.test004.ksh b/test/tools/csqldump/exp.test004.ksh index 83da6813..577ee901 100644 --- a/test/tools/csqldump/exp.test004.ksh +++ b/test/tools/csqldump/exp.test004.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (30)); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(123, 'india'); INSERT INTO t1 VALUES(72, 'Laxman72'); diff --git a/test/tools/csqldump/exp.test005.ksh b/test/tools/csqldump/exp.test005.ksh index 8c810a73..bfcedaec 100644 --- a/test/tools/csqldump/exp.test005.ksh +++ b/test/tools/csqldump/exp.test005.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (30)); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(123, 'india'); INSERT INTO t1 VALUES(72, 'Laxwoman72'); diff --git a/test/tools/csqldump/exp.test006.ksh b/test/tools/csqldump/exp.test006.ksh index 4d91dd2e..bc5c27b6 100644 --- a/test/tools/csqldump/exp.test006.ksh +++ b/test/tools/csqldump/exp.test006.ksh @@ -1,6 +1,6 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT DEFAULT '10' ); -CREATE INDEX indx1 on t1 ( f1 ) ; -CREATE INDEX indx2 on t1 ( f2 ) ; +CREATE INDEX indx1 on t1 ( f1 ) HASH ; +CREATE INDEX indx2 on t1 ( f2 ) HASH ; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(131,10); INSERT INTO t1 VALUES(141,10); diff --git a/test/tools/csqldump/exp.test007.ksh b/test/tools/csqldump/exp.test007.ksh index 07c9f6f4..26c7f848 100644 --- a/test/tools/csqldump/exp.test007.ksh +++ b/test/tools/csqldump/exp.test007.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX indx on t1 ( f1 ) UNIQUE; +CREATE INDEX indx on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(0,5); INSERT INTO t1 VALUES(1,5); diff --git a/test/tools/csqldump/exp.test008.ksh b/test/tools/csqldump/exp.test008.ksh index ebf60e86..5df211c5 100644 --- a/test/tools/csqldump/exp.test008.ksh +++ b/test/tools/csqldump/exp.test008.ksh @@ -1,23 +1,23 @@ CREATE TABLE kishor (fld1 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX kishor_idx1_Primary on kishor ( fld1 ) UNIQUE; +CREATE INDEX kishor_idx1_Primary on kishor ( fld1 ) HASH UNIQUE; CREATE TABLE ravi (fld2 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX ravi_idx1_Primary on ravi ( fld2 ) UNIQUE; +CREATE INDEX ravi_idx1_Primary on ravi ( fld2 ) HASH UNIQUE; CREATE TABLE kiran (fld3 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX kiran_idx1_Primary on kiran ( fld3 ) UNIQUE; +CREATE INDEX kiran_idx1_Primary on kiran ( fld3 ) HASH UNIQUE; CREATE TABLE anand (fld4 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX anand_idx1_Primary on anand ( fld4 ) UNIQUE; +CREATE INDEX anand_idx1_Primary on anand ( fld4 ) HASH UNIQUE; CREATE TABLE vikas (fld5 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX vikas_idx1_Primary on vikas ( fld5 ) UNIQUE; +CREATE INDEX vikas_idx1_Primary on vikas ( fld5 ) HASH UNIQUE; CREATE TABLE vikram (fld6 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX vikram_idx1_Primary on vikram ( fld6 ) UNIQUE; +CREATE INDEX vikram_idx1_Primary on vikram ( fld6 ) HASH UNIQUE; CREATE TABLE vinod (fld7 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX vinod_idx1_Primary on vinod ( fld7 ) UNIQUE; +CREATE INDEX vinod_idx1_Primary on vinod ( fld7 ) HASH UNIQUE; CREATE TABLE jayant (fld8 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX jayant_idx1_Primary on jayant ( fld8 ) UNIQUE; +CREATE INDEX jayant_idx1_Primary on jayant ( fld8 ) HASH UNIQUE; CREATE TABLE rahul (fld9 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX rahul_idx1_Primary on rahul ( fld9 ) UNIQUE; +CREATE INDEX rahul_idx1_Primary on rahul ( fld9 ) HASH UNIQUE; CREATE TABLE ramesh (fld10 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX ramesh_idx1_Primary on ramesh ( fld10 ) UNIQUE; +CREATE INDEX ramesh_idx1_Primary on ramesh ( fld10 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO kishor VALUES(11, 'raksha1'); INSERT INTO kishor VALUES(2, 'Laxkshya2'); diff --git a/test/tools/csqldump/exp.test010.ksh b/test/tools/csqldump/exp.test010.ksh index d231185c..4c5dc869 100644 --- a/test/tools/csqldump/exp.test010.ksh +++ b/test/tools/csqldump/exp.test010.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 CHAR (30)); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(51, 'Praba'); INSERT INTO t1 VALUES(2, 'Lakshya2'); diff --git a/test/tools/csqldump/exp.test011.ksh b/test/tools/csqldump/exp.test011.ksh index 1986c4a3..8cafe027 100644 --- a/test/tools/csqldump/exp.test011.ksh +++ b/test/tools/csqldump/exp.test011.ksh @@ -1,5 +1,5 @@ CREATE TABLE vikas (fld5 INT NOT NULL , name1 CHAR (30)); -CREATE INDEX vikas_idx1_Primary on vikas ( fld5 ) UNIQUE; +CREATE INDEX vikas_idx1_Primary on vikas ( fld5 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO vikas VALUES(1, 'Lakshya1'); INSERT INTO vikas VALUES(2, 'Lakshya2'); diff --git a/test/tools/csqldump/exp.test012.ksh b/test/tools/csqldump/exp.test012.ksh index 0ba5b717..56e83945 100644 --- a/test/tools/csqldump/exp.test012.ksh +++ b/test/tools/csqldump/exp.test012.ksh @@ -1,5 +1,5 @@ CREATE TABLE t1 (f1 INT NOT NULL , f2 INT ); -CREATE INDEX t1_idx1_Primary on t1 ( f1 ) UNIQUE; +CREATE INDEX t1_idx1_Primary on t1 ( f1 ) HASH UNIQUE; SET AUTOCOMMIT OFF; INSERT INTO t1 VALUES(0,1); INSERT INTO t1 VALUES(1,11); diff --git a/tmptest/Makefile b/tmptest/Makefile index 19e58ad2..381754dd 100644 --- a/tmptest/Makefile +++ b/tmptest/Makefile @@ -24,8 +24,10 @@ LIBS= -L$(CSQL_INSTALL_ROOT)/lib -L.. -lcsql -lcsqlsql -lcsqlnw -lcsqlsqllog -lc TARGETS = \ test \ + t \ testproc \ create\ + index\ upd\ del\ select @@ -37,6 +39,8 @@ endif test: test.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +t: t.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) testproc: testproc.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) del: del.c @@ -46,6 +50,8 @@ upd: upd.c create: create.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +index: index.c + $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) select: select.c $(CPlus) $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) clean: -- 2.11.4.GIT