CatalogTableINDEXFIELD Class Reference

#include <CatalogTables.h>

Collaboration diagram for CatalogTableINDEXFIELD:

Collaboration graph
[legend]

Public Member Functions

 CatalogTableINDEXFIELD (Database *db)
DbRetVal insert (FieldNameList &fldList, void *indexPtr, void *tblPtr, char **&fptr)
DbRetVal remove (void *iptr)
DbRetVal getFieldNameAndType (void *iptr, char *&name, DataType &type)

Detailed Description

Definition at line 237 of file CatalogTables.h.


Constructor & Destructor Documentation

CatalogTableINDEXFIELD::CatalogTableINDEXFIELD ( Database db  )  [inline]

Definition at line 241 of file CatalogTables.h.

00241 { systemDatabase_  = db; }


Member Function Documentation

DbRetVal CatalogTableINDEXFIELD::getFieldNameAndType ( void *  iptr,
char *&  name,
DataType type 
)

Definition at line 447 of file CatalogTables.cxx.

References ErrNotExists, Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexFieldTableId, ChunkIterator::nextElement(), OK, and printError.

Referenced by DatabaseManagerImpl::openTable(), and TableImpl::printSQLIndexString().

00449 {
00450     Chunk *ifChunk;
00451     ifChunk = systemDatabase_->getSystemDatabaseChunk(IndexFieldTableId);
00452     ChunkIterator ifIter = ifChunk->getIterator();
00453     void *data = NULL;
00454     while ((data = ifIter.nextElement())!= NULL)
00455     {
00456         if (((INDEXFIELD*)data)->indexPtr == index)
00457         {
00458             //store the field name
00459             name = ((FIELD*)(((INDEXFIELD*)data)->fieldPtr))->fldName_;
00460             type = ((FIELD*)(((INDEXFIELD*)data)->fieldPtr))->type_;
00461             return OK;
00462         }
00463     }
00464     printError(ErrNotExists,"Index %x not exists in catalog table", index);
00465     return ErrNotExists;
00466 }

Here is the call graph for this function:

Here is the caller graph for this function:

DbRetVal CatalogTableINDEXFIELD::insert ( FieldNameList fldList,
void *  indexPtr,
void *  tblPtr,
char **&  fptr 
)

Definition at line 392 of file CatalogTables.cxx.

References Chunk::allocate(), DM_SystemDatabase, ErrAlready, INDEXFIELD::fieldPtr, Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexFieldTableId, INDEXFIELD::indexPtr, ChunkIterator::nextElement(), FieldNameList::nextFieldName(), OK, printDebug, printError, FieldNameList::resetIter(), and INDEXFIELD::tablePtr.

00394 {
00395 
00396     Chunk *fChunk;
00397     fChunk = systemDatabase_->getSystemDatabaseChunk(IndexFieldTableId);
00398     fldList.resetIter();
00399     int i =0;
00400     char *fName =NULL;
00401     void *data = NULL;
00402     ChunkIterator ifIter = fChunk->getIterator();
00403     while (NULL != (fName = fldList.nextFieldName()))
00404     {
00405         ifIter = fChunk->getIterator();
00406         while ((data = ifIter.nextElement()) != NULL) {
00407             if (0 == strcmp(((FIELD *)((INDEXFIELD *) data)->fieldPtr)->fldName_, fName) && ((INDEXFIELD *)data)->tablePtr == tblPtr) {
00408                 printError(ErrAlready, "Index on field \'%s\' already exists on table \'%s\' by name \'%s\'", ((FIELD *)((INDEXFIELD *)data)->fieldPtr)->fldName_, ((TABLE *)((INDEXFIELD *)data)->tablePtr)->tblName_, ((INDEX *)((INDEXFIELD *)data)->indexPtr)->indName_);
00409                 return ErrAlready;
00410             }
00411         }  
00412         DbRetVal rv = OK;
00413         void *fieldptr = fChunk->allocate(systemDatabase_, &rv);
00414         if (NULL == fieldptr)
00415         {
00416             printError(rv,
00417                    "Could not allocate for USER catalog table");
00418             return rv;
00419         }
00420         INDEXFIELD *fldInfo = (INDEXFIELD*)fieldptr;
00421         fldInfo->tablePtr = tblPtr;
00422         fldInfo->fieldPtr = (FIELD*)fptr[i++];
00423         fldInfo->indexPtr = indexPtr;
00424         printDebug(DM_SystemDatabase,"One Row inserted into INDEXFIELD %x", fldInfo);
00425     }
00426     return OK;
00427 }

Here is the call graph for this function:

DbRetVal CatalogTableINDEXFIELD::remove ( void *  iptr  ) 

Definition at line 429 of file CatalogTables.cxx.

References DM_SystemDatabase, Chunk::free(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), IndexFieldTableId, ChunkIterator::nextElement(), OK, and printDebug.

00430 {
00431     Chunk *fChunk;
00432     fChunk = systemDatabase_->getSystemDatabaseChunk(IndexFieldTableId);
00433     ChunkIterator fIter = fChunk->getIterator();
00434     void *data = NULL;
00435     while ((data = fIter.nextElement())!= NULL)
00436     {
00437         if (((INDEXFIELD*)data)->indexPtr == iptr)
00438         {
00439             //remove this element
00440             fChunk->free(systemDatabase_, data);
00441             printDebug(DM_SystemDatabase,"One Row deleted from INDEXFIELD %x", data);
00442         }
00443     }
00444     return OK;
00445 }

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 22:44:09 2008 for csql by  doxygen 1.4.7