#include <CatalogTables.h>
Collaboration diagram for CatalogTableTABLE:
Public Member Functions | |
CatalogTableTABLE (Database *db) | |
DbRetVal | insert (const char *name, int id, size_t size, int numFlds, void *chunk, void *&tptr) |
DbRetVal | remove (const char *name, void *&chunk, void *&tptr) |
DbRetVal | getChunkAndTblPtr (const char *name, void *&chunk, void *&tptr) |
List | getTableList () |
Definition at line 74 of file CatalogTables.h.
CatalogTableTABLE::CatalogTableTABLE | ( | Database * | db | ) | [inline] |
DbRetVal CatalogTableTABLE::getChunkAndTblPtr | ( | const char * | name, | |
void *& | chunk, | |||
void *& | tptr | |||
) |
Definition at line 75 of file CatalogTables.cxx.
References ErrNotFound, Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, and TableTableId.
Referenced by DatabaseManagerImpl::createTable(), DatabaseManagerImpl::dropTable(), and DatabaseManagerImpl::openTable().
00077 { 00078 Chunk *chk = systemDatabase_->getSystemDatabaseChunk(TableTableId); 00079 ChunkIterator iter = chk->getIterator();; 00080 while (NULL != (tptr = iter.nextElement())) 00081 { 00082 if (strcmp(((TABLE*)tptr)->tblName_, name) == 0) 00083 { 00084 //there will be only one row for this table(Primary key) 00085 chunk = (Chunk*) ((TABLE*)tptr)->chunkPtr_; 00086 return OK; 00087 } 00088 } 00089 //table not found in TABLE 00090 return ErrNotFound; 00091 }
Here is the call graph for this function:
Here is the caller graph for this function:
List CatalogTableTABLE::getTableList | ( | ) |
Definition at line 93 of file CatalogTables.cxx.
References List::append(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), Identifier::name, ChunkIterator::nextElement(), and TableTableId.
Referenced by DatabaseManagerImpl::getAllTableNames().
00094 { 00095 List tableList; 00096 Chunk *chk = systemDatabase_->getSystemDatabaseChunk(TableTableId); 00097 ChunkIterator iter = chk->getIterator(); 00098 void *tptr; 00099 while (NULL != (tptr = iter.nextElement())) 00100 { 00101 Identifier *elem = new Identifier(); 00102 strcpy(elem->name, ((TABLE*)tptr)->tblName_); 00103 tableList.append(elem); 00104 } 00105 return tableList; 00106 }
Here is the call graph for this function:
Here is the caller graph for this function:
DbRetVal CatalogTableTABLE::insert | ( | const char * | name, | |
int | id, | |||
size_t | size, | |||
int | numFlds, | |||
void * | chunk, | |||
void *& | tptr | |||
) |
Definition at line 22 of file CatalogTables.cxx.
References Chunk::allocate(), TABLE::chunkPtr_, DM_SystemDatabase, Database::getSystemDatabaseChunk(), TABLE::length_, TABLE::numFlds_, TABLE::numIndexes_, OK, printDebug, printError, TableTableId, TABLE::tblID_, and TABLE::tblName_.
Referenced by DatabaseManagerImpl::createTable().
00024 { 00025 Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(TableTableId); 00026 DbRetVal rv = OK; 00027 tptr = tChunk->allocate(systemDatabase_, &rv); 00028 if (NULL == tptr) 00029 { 00030 printError(rv, 00031 "Could not allocate memory for for TABLE catalog table"); 00032 return rv; 00033 } 00034 TABLE *tableInfo = (TABLE*)tptr; 00035 strcpy(tableInfo->tblName_, name); 00036 tableInfo->tblID_ = id; 00037 tableInfo->length_ = size; 00038 tableInfo->numFlds_ = numFlds; 00039 tableInfo->numIndexes_ = 0; 00040 tableInfo->chunkPtr_ = chunk; 00041 printDebug(DM_SystemDatabase,"One Row inserted into TABLE %x %s",tptr, name); 00042 return OK; 00043 }
Here is the call graph for this function:
Here is the caller graph for this function:
DbRetVal CatalogTableTABLE::remove | ( | const char * | name, | |
void *& | chunk, | |||
void *& | tptr | |||
) |
Definition at line 45 of file CatalogTables.cxx.
References TABLE::chunkPtr_, DM_SystemDatabase, ErrNotExists, Chunk::free(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, printDebug, printError, and TableTableId.
Referenced by DatabaseManagerImpl::createTable(), and DatabaseManagerImpl::dropTable().
00046 { 00047 Chunk *tChunk = systemDatabase_->getSystemDatabaseChunk(TableTableId); 00048 ChunkIterator iter = tChunk->getIterator(); 00049 00050 void *data = NULL; 00051 while ((data = iter.nextElement())!= NULL) 00052 { 00053 if (0 == strcmp(((TABLE*)data)->tblName_, name)) 00054 { 00055 //remove this element and store the tblPtr 00056 //there will be only one row for this table(Primary key) 00057 tptr = (void*) data; 00058 chunk = (Chunk*) ((TABLE*)data)->chunkPtr_; 00059 break; 00060 } 00061 } 00062 if (NULL != tptr) 00063 { 00064 tChunk->free(systemDatabase_, tptr); 00065 printDebug(DM_SystemDatabase,"One Row deleted from TABLE %x %s",tptr, name); 00066 } 00067 else 00068 { 00069 printError(ErrNotExists,"Table %s not exists in TABLE catalog table", name); 00070 return ErrNotExists; 00071 } 00072 return OK; 00073 }
Here is the call graph for this function:
Here is the caller graph for this function: