#include <CatalogTables.h>
Collaboration diagram for CatalogTableFIELD:
Public Member Functions | |
CatalogTableFIELD (Database *db) | |
DbRetVal | insert (FieldIterator &iter, int tblID, void *tblPtr) |
DbRetVal | remove (void *tblPtr) |
void | getFieldInfo (void *tblPtr, FieldList &list) |
DbRetVal | getFieldPtrs (FieldNameList &fldList, void *tptr, char **&array) |
Definition at line 117 of file CatalogTables.h.
CatalogTableFIELD::CatalogTableFIELD | ( | Database * | db | ) | [inline] |
void CatalogTableFIELD::getFieldInfo | ( | void * | tblPtr, | |
FieldList & | list | |||
) |
Definition at line 160 of file CatalogTables.cxx.
References FieldList::append(), DEFAULT_VALUE_BUF_LENGTH, FieldDef::defaultValueBuf_, FieldTableId, FieldDef::fldName_, Chunk::getIterator(), Database::getSystemDatabaseChunk(), IDENTIFIER_LENGTH, FieldDef::isDefault_, FieldDef::isNull_, FieldDef::isPrimary_, FieldDef::isUnique_, FieldDef::length_, os::memcpy(), ChunkIterator::nextElement(), and FieldDef::type_.
Referenced by DatabaseManagerImpl::openTable().
00161 { 00162 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(FieldTableId); 00163 ChunkIterator fIter = fChunk->getIterator();; 00164 void *data = NULL; 00165 while (NULL != (data = fIter.nextElement())) 00166 { 00167 if (((FIELD*)data)->tblPtr_ == tptr) 00168 { 00169 //add the information to the field list 00170 FIELD *fTuple = (FIELD*)data; 00171 FieldDef fldDef; 00172 strcpy(fldDef.fldName_, fTuple->fldName_); 00173 fldDef.fldName_[IDENTIFIER_LENGTH] = '\0'; 00174 fldDef.type_ = fTuple->type_; 00175 fldDef.length_ = fTuple->length_; 00176 fldDef.isDefault_ = fTuple->isDefault_; 00177 os::memcpy(fldDef.defaultValueBuf_, fTuple->defaultValueBuf_, 00178 DEFAULT_VALUE_BUF_LENGTH); 00179 fldDef.isNull_ = fTuple->isNull_; 00180 fldDef.isUnique_ = fTuple->isUnique_; 00181 fldDef.isPrimary_ = fTuple->isPrimary_; 00182 list.append(fldDef); 00183 } 00184 } 00185 return; 00186 }
Here is the call graph for this function:
Here is the caller graph for this function:
DbRetVal CatalogTableFIELD::getFieldPtrs | ( | FieldNameList & | fldList, | |
void * | tptr, | |||
char **& | array | |||
) |
Definition at line 188 of file CatalogTables.cxx.
References ErrNotFound, FieldTableId, Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), FieldNameList::nextFieldName(), OK, printError, and FieldNameList::resetIter().
00189 { 00190 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(FieldTableId); 00191 int i=0; 00192 char *fName = NULL; 00193 bool found = false; 00194 fldList.resetIter(); 00195 void *data = NULL; 00196 DbRetVal rv =OK; 00197 while (NULL != (fName = fldList.nextFieldName())) 00198 { 00199 ChunkIterator fIter = fChunk->getIterator(); 00200 found = false; 00201 while (NULL != (data = fIter.nextElement())) 00202 { 00203 if (((FIELD*)data)->tblPtr_ == tptr) 00204 { 00205 if(0 == strcmp((char*)((FIELD*)data)->fldName_, fName)) 00206 { 00207 found = true; 00208 //if (! ((FIELD*)data)->isNull_) rv = ErrBadCall; 00209 fptr[i++] = (char*) data; 00210 break; 00211 } 00212 } 00213 } 00214 if (!found) 00215 { 00216 printError(ErrNotFound, 00217 "No entries found in FIELD catalog table for the table specified"); 00218 return ErrNotFound; 00219 } 00220 } 00221 return rv; 00222 }
Here is the call graph for this function:
DbRetVal CatalogTableFIELD::insert | ( | FieldIterator & | iter, | |
int | tblID, | |||
void * | tblPtr | |||
) |
Definition at line 108 of file CatalogTables.cxx.
References Chunk::allocate(), DEFAULT_VALUE_BUF_LENGTH, FieldDef::defaultValueBuf_, FIELD::defaultValueBuf_, DM_SystemDatabase, FieldTableId, FieldDef::fldName_, FIELD::fldName_, Database::getSystemDatabaseChunk(), FieldIterator::hasElement(), FieldDef::isDefault_, FIELD::isDefault_, FieldDef::isNull_, FIELD::isNull_, FieldDef::isPrimary_, FIELD::isPrimary_, FieldDef::isUnique_, FIELD::isUnique_, FieldDef::length_, FIELD::length_, os::memcpy(), FieldIterator::nextElement(), FIELD::offset_, OK, printDebug, printError, FIELD::scale_, FIELD::tblID_, FIELD::tblPtr_, FieldDef::type_, FIELD::type_, and FIELD::width_.
Referenced by DatabaseManagerImpl::createTable().
00109 { 00110 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(FieldTableId); 00111 DbRetVal rv = OK; 00112 while (iter.hasElement()) 00113 { 00114 void *fptr = fChunk->allocate(systemDatabase_, &rv); 00115 if (NULL == fptr) 00116 { 00117 printError(rv, 00118 "Could not allocate for FIELD catalog table"); 00119 return rv; 00120 } 00121 FIELD *fldInfo = (FIELD*)fptr; 00122 FieldDef fDef = iter.nextElement(); 00123 strcpy(fldInfo->fldName_, fDef.fldName_); 00124 fldInfo->tblID_ = tblID; 00125 fldInfo->tblPtr_ = tptr; 00126 fldInfo->type_ = fDef.type_; 00127 fldInfo->length_ = fDef.length_; 00128 fldInfo->offset_ = 0; //TODO 00129 os::memcpy(fldInfo->defaultValueBuf_, fDef.defaultValueBuf_, 00130 DEFAULT_VALUE_BUF_LENGTH); 00131 fldInfo->isNull_ = fDef.isNull_; 00132 fldInfo->isPrimary_ = fDef.isPrimary_; 00133 fldInfo->isUnique_ = fDef.isUnique_; 00134 fldInfo->isDefault_ = fDef.isDefault_; 00135 fldInfo->width_ = 0; //TODO 00136 fldInfo->scale_ = 0; //TODO 00137 printDebug(DM_SystemDatabase,"One Row inserted into FIELD %x %s",fldInfo, fDef.fldName_); 00138 00139 } 00140 return OK; 00141 }
Here is the call graph for this function:
Here is the caller graph for this function:
DbRetVal CatalogTableFIELD::remove | ( | void * | tblPtr | ) |
Definition at line 143 of file CatalogTables.cxx.
References DM_SystemDatabase, FieldTableId, Chunk::free(), Chunk::getIterator(), Database::getSystemDatabaseChunk(), ChunkIterator::nextElement(), OK, and printDebug.
Referenced by DatabaseManagerImpl::dropTable().
00144 { 00145 Chunk *fChunk = systemDatabase_->getSystemDatabaseChunk(FieldTableId); 00146 ChunkIterator fIter = fChunk->getIterator(); 00147 void *data = NULL; 00148 while ((data = fIter.nextElement())!= NULL) 00149 { 00150 if (((FIELD*)data)->tblPtr_ == tptr) 00151 { 00152 //remove this element 00153 fChunk->free(systemDatabase_, data); 00154 printDebug(DM_SystemDatabase,"One Row deleted from FIELD %x",data); 00155 } 00156 } 00157 return OK; 00158 }
Here is the call graph for this function:
Here is the caller graph for this function: