00001 /* Copyright (C) 2003 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 #include <NdbDictionary.hpp> 00018 #include "NdbDictionaryImpl.hpp" 00019 #include <NdbOut.hpp> 00020 00021 NdbDictionary::ObjectId::ObjectId() 00022 : m_impl(* new NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined)) 00023 { 00024 } 00025 00026 NdbDictionary::ObjectId::~ObjectId() 00027 { 00028 NdbDictObjectImpl * tmp = &m_impl; 00029 delete tmp; 00030 } 00031 00032 NdbDictionary::Object::Status 00033 NdbDictionary::ObjectId::getObjectStatus() const { 00034 return m_impl.m_status; 00035 } 00036 00037 int 00038 NdbDictionary::ObjectId::getObjectVersion() const { 00039 return m_impl.m_version; 00040 } 00041 00042 int 00043 NdbDictionary::ObjectId::getObjectId() const { 00044 return m_impl.m_id; 00045 } 00046 00047 /***************************************************************** 00048 * Column facade 00049 */ 00050 NdbDictionary::Column::Column(const char * name) 00051 : m_impl(* new NdbColumnImpl(* this)) 00052 { 00053 setName(name); 00054 } 00055 00056 NdbDictionary::Column::Column(const NdbDictionary::Column & org) 00057 : m_impl(* new NdbColumnImpl(* this)) 00058 { 00059 m_impl = org.m_impl; 00060 } 00061 00062 NdbDictionary::Column::Column(NdbColumnImpl& impl) 00063 : m_impl(impl) 00064 { 00065 } 00066 00067 NdbDictionary::Column::~Column(){ 00068 NdbColumnImpl * tmp = &m_impl; 00069 if(this != tmp){ 00070 delete tmp; 00071 } 00072 } 00073 00074 NdbDictionary::Column& 00075 NdbDictionary::Column::operator=(const NdbDictionary::Column& column) 00076 { 00077 m_impl = column.m_impl; 00078 00079 return *this; 00080 } 00081 00082 void 00083 NdbDictionary::Column::setName(const char * name){ 00084 m_impl.m_name.assign(name); 00085 } 00086 00087 const char* 00088 NdbDictionary::Column::getName() const { 00089 return m_impl.m_name.c_str(); 00090 } 00091 00092 void 00093 NdbDictionary::Column::setType(Type t){ 00094 m_impl.init(t); 00095 } 00096 00097 NdbDictionary::Column::Type 00098 NdbDictionary::Column::getType() const { 00099 return m_impl.m_type; 00100 } 00101 00102 void 00103 NdbDictionary::Column::setPrecision(int val){ 00104 m_impl.m_precision = val; 00105 } 00106 00107 int 00108 NdbDictionary::Column::getPrecision() const { 00109 return m_impl.m_precision; 00110 } 00111 00112 void 00113 NdbDictionary::Column::setScale(int val){ 00114 m_impl.m_scale = val; 00115 } 00116 00117 int 00118 NdbDictionary::Column::getScale() const{ 00119 return m_impl.m_scale; 00120 } 00121 00122 void 00123 NdbDictionary::Column::setLength(int length){ 00124 m_impl.m_length = length; 00125 } 00126 00127 int 00128 NdbDictionary::Column::getLength() const{ 00129 return m_impl.m_length; 00130 } 00131 00132 void 00133 NdbDictionary::Column::setInlineSize(int size) 00134 { 00135 m_impl.m_precision = size; 00136 } 00137 00138 void 00139 NdbDictionary::Column::setCharset(CHARSET_INFO* cs) 00140 { 00141 m_impl.m_cs = cs; 00142 } 00143 00144 CHARSET_INFO* 00145 NdbDictionary::Column::getCharset() const 00146 { 00147 return m_impl.m_cs; 00148 } 00149 00150 int 00151 NdbDictionary::Column::getInlineSize() const 00152 { 00153 return m_impl.m_precision; 00154 } 00155 00156 void 00157 NdbDictionary::Column::setPartSize(int size) 00158 { 00159 m_impl.m_scale = size; 00160 } 00161 00162 int 00163 NdbDictionary::Column::getPartSize() const 00164 { 00165 return m_impl.m_scale; 00166 } 00167 00168 void 00169 NdbDictionary::Column::setStripeSize(int size) 00170 { 00171 m_impl.m_length = size; 00172 } 00173 00174 int 00175 NdbDictionary::Column::getStripeSize() const 00176 { 00177 return m_impl.m_length; 00178 } 00179 00180 int 00181 NdbDictionary::Column::getSize() const{ 00182 return m_impl.m_attrSize; 00183 } 00184 00185 void 00186 NdbDictionary::Column::setNullable(bool val){ 00187 m_impl.m_nullable = val; 00188 } 00189 00190 bool 00191 NdbDictionary::Column::getNullable() const { 00192 return m_impl.m_nullable; 00193 } 00194 00195 void 00196 NdbDictionary::Column::setPrimaryKey(bool val){ 00197 m_impl.m_pk = val; 00198 } 00199 00200 bool 00201 NdbDictionary::Column::getPrimaryKey() const { 00202 return m_impl.m_pk; 00203 } 00204 00205 void 00206 NdbDictionary::Column::setPartitionKey(bool val){ 00207 m_impl.m_distributionKey = (val ? 2 : 0); 00208 } 00209 00210 bool 00211 NdbDictionary::Column::getPartitionKey() const{ 00212 return (bool)m_impl.m_distributionKey; 00213 } 00214 00215 const NdbDictionary::Table * 00216 NdbDictionary::Column::getBlobTable() const { 00217 NdbTableImpl * t = m_impl.m_blobTable; 00218 if (t) 00219 return t->m_facade; 00220 return 0; 00221 } 00222 00223 void 00224 NdbDictionary::Column::setAutoIncrement(bool val){ 00225 m_impl.m_autoIncrement = val; 00226 } 00227 00228 bool 00229 NdbDictionary::Column::getAutoIncrement() const { 00230 return m_impl.m_autoIncrement; 00231 } 00232 00233 void 00234 NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){ 00235 m_impl.m_autoIncrementInitialValue = val; 00236 } 00237 00238 void 00239 NdbDictionary::Column::setDefaultValue(const char* defaultValue) 00240 { 00241 m_impl.m_defaultValue.assign(defaultValue); 00242 } 00243 00244 const char* 00245 NdbDictionary::Column::getDefaultValue() const 00246 { 00247 return m_impl.m_defaultValue.c_str(); 00248 } 00249 00250 int 00251 NdbDictionary::Column::getColumnNo() const { 00252 return m_impl.m_column_no; 00253 } 00254 00255 int 00256 NdbDictionary::Column::getAttrId() const { 00257 return m_impl.m_attrId;; 00258 } 00259 00260 bool 00261 NdbDictionary::Column::equal(const NdbDictionary::Column & col) const { 00262 return m_impl.equal(col.m_impl); 00263 } 00264 00265 int 00266 NdbDictionary::Column::getSizeInBytes() const 00267 { 00268 return m_impl.m_attrSize * m_impl.m_arraySize; 00269 } 00270 00271 void 00272 NdbDictionary::Column::setArrayType(ArrayType type) 00273 { 00274 m_impl.m_arrayType = type; 00275 } 00276 00277 NdbDictionary::Column::ArrayType 00278 NdbDictionary::Column::getArrayType() const 00279 { 00280 return (ArrayType)m_impl.m_arrayType; 00281 } 00282 00283 void 00284 NdbDictionary::Column::setStorageType(StorageType type) 00285 { 00286 m_impl.m_storageType = type; 00287 } 00288 00289 NdbDictionary::Column::StorageType 00290 NdbDictionary::Column::getStorageType() const 00291 { 00292 return (StorageType)m_impl.m_storageType; 00293 } 00294 00295 /***************************************************************** 00296 * Table facade 00297 */ 00298 NdbDictionary::Table::Table(const char * name) 00299 : m_impl(* new NdbTableImpl(* this)) 00300 { 00301 setName(name); 00302 } 00303 00304 NdbDictionary::Table::Table(const NdbDictionary::Table & org) 00305 : Object(org), m_impl(* new NdbTableImpl(* this)) 00306 { 00307 m_impl.assign(org.m_impl); 00308 } 00309 00310 NdbDictionary::Table::Table(NdbTableImpl & impl) 00311 : m_impl(impl) 00312 { 00313 } 00314 00315 NdbDictionary::Table::~Table(){ 00316 NdbTableImpl * tmp = &m_impl; 00317 if(this != tmp){ 00318 delete tmp; 00319 } 00320 } 00321 00322 NdbDictionary::Table& 00323 NdbDictionary::Table::operator=(const NdbDictionary::Table& table) 00324 { 00325 m_impl.assign(table.m_impl); 00326 00327 m_impl.m_facade = this; 00328 return *this; 00329 } 00330 00331 void 00332 NdbDictionary::Table::setName(const char * name){ 00333 m_impl.setName(name); 00334 } 00335 00336 const char * 00337 NdbDictionary::Table::getName() const { 00338 return m_impl.getName(); 00339 } 00340 00341 const char * 00342 NdbDictionary::Table::getMysqlName() const { 00343 return m_impl.getMysqlName(); 00344 } 00345 00346 int 00347 NdbDictionary::Table::getTableId() const { 00348 return m_impl.m_id; 00349 } 00350 00351 void 00352 NdbDictionary::Table::addColumn(const Column & c){ 00353 NdbColumnImpl* col = new NdbColumnImpl; 00354 (* col) = NdbColumnImpl::getImpl(c); 00355 m_impl.m_columns.push_back(col); 00356 m_impl.computeAggregates(); 00357 m_impl.buildColumnHash(); 00358 } 00359 00360 const NdbDictionary::Column* 00361 NdbDictionary::Table::getColumn(const char * name) const { 00362 return m_impl.getColumn(name); 00363 } 00364 00365 const NdbDictionary::Column* 00366 NdbDictionary::Table::getColumn(const int attrId) const { 00367 return m_impl.getColumn(attrId); 00368 } 00369 00370 NdbDictionary::Column* 00371 NdbDictionary::Table::getColumn(const char * name) 00372 { 00373 return m_impl.getColumn(name); 00374 } 00375 00376 NdbDictionary::Column* 00377 NdbDictionary::Table::getColumn(const int attrId) 00378 { 00379 return m_impl.getColumn(attrId); 00380 } 00381 00382 void 00383 NdbDictionary::Table::setLogging(bool val){ 00384 m_impl.m_logging = val; 00385 } 00386 00387 bool 00388 NdbDictionary::Table::getLogging() const { 00389 return m_impl.m_logging; 00390 } 00391 00392 void 00393 NdbDictionary::Table::setFragmentType(FragmentType ft){ 00394 m_impl.m_fragmentType = ft; 00395 } 00396 00397 NdbDictionary::Object::FragmentType 00398 NdbDictionary::Table::getFragmentType() const { 00399 return m_impl.m_fragmentType; 00400 } 00401 00402 void 00403 NdbDictionary::Table::setKValue(int kValue){ 00404 m_impl.m_kvalue = kValue; 00405 } 00406 00407 int 00408 NdbDictionary::Table::getKValue() const { 00409 return m_impl.m_kvalue; 00410 } 00411 00412 void 00413 NdbDictionary::Table::setMinLoadFactor(int lf){ 00414 m_impl.m_minLoadFactor = lf; 00415 } 00416 00417 int 00418 NdbDictionary::Table::getMinLoadFactor() const { 00419 return m_impl.m_minLoadFactor; 00420 } 00421 00422 void 00423 NdbDictionary::Table::setMaxLoadFactor(int lf){ 00424 m_impl.m_maxLoadFactor = lf; 00425 } 00426 00427 int 00428 NdbDictionary::Table::getMaxLoadFactor() const { 00429 return m_impl.m_maxLoadFactor; 00430 } 00431 00432 int 00433 NdbDictionary::Table::getNoOfColumns() const { 00434 return m_impl.m_columns.size(); 00435 } 00436 00437 int 00438 NdbDictionary::Table::getNoOfPrimaryKeys() const { 00439 return m_impl.m_noOfKeys; 00440 } 00441 00442 void 00443 NdbDictionary::Table::setMaxRows(Uint64 maxRows) 00444 { 00445 m_impl.m_max_rows = maxRows; 00446 } 00447 00448 Uint64 00449 NdbDictionary::Table::getMaxRows() const 00450 { 00451 return m_impl.m_max_rows; 00452 } 00453 00454 void 00455 NdbDictionary::Table::setMinRows(Uint64 minRows) 00456 { 00457 m_impl.m_min_rows = minRows; 00458 } 00459 00460 Uint64 00461 NdbDictionary::Table::getMinRows() const 00462 { 00463 return m_impl.m_min_rows; 00464 } 00465 00466 void 00467 NdbDictionary::Table::setDefaultNoPartitionsFlag(Uint32 flag) 00468 { 00469 m_impl.m_default_no_part_flag = flag;; 00470 } 00471 00472 Uint32 00473 NdbDictionary::Table::getDefaultNoPartitionsFlag() const 00474 { 00475 return m_impl.m_default_no_part_flag; 00476 } 00477 00478 const char* 00479 NdbDictionary::Table::getPrimaryKey(int no) const { 00480 int count = 0; 00481 for (unsigned i = 0; i < m_impl.m_columns.size(); i++) { 00482 if (m_impl.m_columns[i]->m_pk) { 00483 if (count++ == no) 00484 return m_impl.m_columns[i]->m_name.c_str(); 00485 } 00486 } 00487 return 0; 00488 } 00489 00490 const void* 00491 NdbDictionary::Table::getFrmData() const { 00492 return m_impl.getFrmData(); 00493 } 00494 00495 Uint32 00496 NdbDictionary::Table::getFrmLength() const { 00497 return m_impl.getFrmLength(); 00498 } 00499 00500 void 00501 NdbDictionary::Table::setTablespaceNames(const void *data, Uint32 len) 00502 { 00503 m_impl.setTablespaceNames(data, len); 00504 } 00505 00506 const void* 00507 NdbDictionary::Table::getTablespaceNames() 00508 { 00509 return m_impl.getTablespaceNames(); 00510 } 00511 00512 Uint32 00513 NdbDictionary::Table::getTablespaceNamesLen() const 00514 { 00515 return m_impl.getTablespaceNamesLen(); 00516 } 00517 00518 void 00519 NdbDictionary::Table::setLinearFlag(Uint32 flag) 00520 { 00521 m_impl.m_linear_flag = flag; 00522 } 00523 00524 bool 00525 NdbDictionary::Table::getLinearFlag() const 00526 { 00527 return m_impl.m_linear_flag; 00528 } 00529 00530 void 00531 NdbDictionary::Table::setFragmentCount(Uint32 count) 00532 { 00533 m_impl.setFragmentCount(count); 00534 } 00535 00536 Uint32 00537 NdbDictionary::Table::getFragmentCount() const 00538 { 00539 return m_impl.getFragmentCount(); 00540 } 00541 00542 void 00543 NdbDictionary::Table::setFrm(const void* data, Uint32 len){ 00544 m_impl.setFrm(data, len); 00545 } 00546 00547 const void* 00548 NdbDictionary::Table::getFragmentData() const { 00549 return m_impl.getFragmentData(); 00550 } 00551 00552 Uint32 00553 NdbDictionary::Table::getFragmentDataLen() const { 00554 return m_impl.getFragmentDataLen(); 00555 } 00556 00557 void 00558 NdbDictionary::Table::setFragmentData(const void* data, Uint32 len) 00559 { 00560 m_impl.setFragmentData(data, len); 00561 } 00562 00563 const void* 00564 NdbDictionary::Table::getTablespaceData() const { 00565 return m_impl.getTablespaceData(); 00566 } 00567 00568 Uint32 00569 NdbDictionary::Table::getTablespaceDataLen() const { 00570 return m_impl.getTablespaceDataLen(); 00571 } 00572 00573 void 00574 NdbDictionary::Table::setTablespaceData(const void* data, Uint32 len) 00575 { 00576 m_impl.setTablespaceData(data, len); 00577 } 00578 00579 const void* 00580 NdbDictionary::Table::getRangeListData() const { 00581 return m_impl.getRangeListData(); 00582 } 00583 00584 Uint32 00585 NdbDictionary::Table::getRangeListDataLen() const { 00586 return m_impl.getRangeListDataLen(); 00587 } 00588 00589 void 00590 NdbDictionary::Table::setRangeListData(const void* data, Uint32 len) 00591 { 00592 m_impl.setRangeListData(data, len); 00593 } 00594 00595 NdbDictionary::Object::Status 00596 NdbDictionary::Table::getObjectStatus() const { 00597 return m_impl.m_status; 00598 } 00599 00600 void 00601 NdbDictionary::Table::setStatusInvalid() const { 00602 m_impl.m_status = NdbDictionary::Object::Invalid; 00603 } 00604 00605 int 00606 NdbDictionary::Table::getObjectVersion() const { 00607 return m_impl.m_version; 00608 } 00609 00610 int 00611 NdbDictionary::Table::getObjectId() const { 00612 return m_impl.m_id; 00613 } 00614 00615 bool 00616 NdbDictionary::Table::equal(const NdbDictionary::Table & col) const { 00617 return m_impl.equal(col.m_impl); 00618 } 00619 00620 int 00621 NdbDictionary::Table::getRowSizeInBytes() const { 00622 int sz = 0; 00623 for(int i = 0; i<getNoOfColumns(); i++){ 00624 const NdbDictionary::Column * c = getColumn(i); 00625 sz += (c->getSizeInBytes()+ 3) / 4; 00626 } 00627 return sz * 4; 00628 } 00629 00630 int 00631 NdbDictionary::Table::getReplicaCount() const { 00632 return m_impl.m_replicaCount; 00633 } 00634 00635 int 00636 NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const { 00637 const NdbDictionary::Table * pTab = 00638 pNdb->getDictionary()->getTable(getName()); 00639 if(pTab != 0 && equal(* pTab)) 00640 return 0; 00641 if(pTab != 0 && !equal(* pTab)) 00642 return -1; 00643 return pNdb->getDictionary()->createTable(* this); 00644 } 00645 00646 bool 00647 NdbDictionary::Table::getTablespace(Uint32 *id, Uint32 *version) const 00648 { 00649 if (m_impl.m_tablespace_id == RNIL) 00650 return false; 00651 if (id) 00652 *id= m_impl.m_tablespace_id; 00653 if (version) 00654 *version= m_impl.m_version; 00655 return true; 00656 } 00657 00658 void 00659 NdbDictionary::Table::setTablespace(const char * name){ 00660 m_impl.m_tablespace_id = ~0; 00661 m_impl.m_tablespace_version = ~0; 00662 m_impl.m_tablespace_name.assign(name); 00663 } 00664 00665 void 00666 NdbDictionary::Table::setTablespace(const NdbDictionary::Tablespace & ts){ 00667 m_impl.m_tablespace_id = NdbTablespaceImpl::getImpl(ts).m_id; 00668 m_impl.m_tablespace_version = ts.getObjectVersion(); 00669 m_impl.m_tablespace_name.assign(ts.getName()); 00670 } 00671 00672 void 00673 NdbDictionary::Table::setRowChecksumIndicator(bool val){ 00674 m_impl.m_row_checksum = val; 00675 } 00676 00677 bool 00678 NdbDictionary::Table::getRowChecksumIndicator() const { 00679 return m_impl.m_row_checksum; 00680 } 00681 00682 void 00683 NdbDictionary::Table::setRowGCIIndicator(bool val){ 00684 m_impl.m_row_gci = val; 00685 } 00686 00687 bool 00688 NdbDictionary::Table::getRowGCIIndicator() const { 00689 return m_impl.m_row_gci; 00690 } 00691 00692 00693 /***************************************************************** 00694 * Index facade 00695 */ 00696 NdbDictionary::Index::Index(const char * name) 00697 : m_impl(* new NdbIndexImpl(* this)) 00698 { 00699 setName(name); 00700 } 00701 00702 NdbDictionary::Index::Index(NdbIndexImpl & impl) 00703 : m_impl(impl) 00704 { 00705 } 00706 00707 NdbDictionary::Index::~Index(){ 00708 NdbIndexImpl * tmp = &m_impl; 00709 if(this != tmp){ 00710 delete tmp; 00711 } 00712 } 00713 00714 void 00715 NdbDictionary::Index::setName(const char * name){ 00716 m_impl.setName(name); 00717 } 00718 00719 const char * 00720 NdbDictionary::Index::getName() const { 00721 return m_impl.getName(); 00722 } 00723 00724 void 00725 NdbDictionary::Index::setTable(const char * table){ 00726 m_impl.setTable(table); 00727 } 00728 00729 const char * 00730 NdbDictionary::Index::getTable() const { 00731 return m_impl.getTable(); 00732 } 00733 00734 unsigned 00735 NdbDictionary::Index::getNoOfColumns() const { 00736 return m_impl.m_columns.size(); 00737 } 00738 00739 int 00740 NdbDictionary::Index::getNoOfIndexColumns() const { 00741 return m_impl.m_columns.size(); 00742 } 00743 00744 const NdbDictionary::Column * 00745 NdbDictionary::Index::getColumn(unsigned no) const { 00746 if(no < m_impl.m_columns.size()) 00747 return m_impl.m_columns[no]; 00748 return NULL; 00749 } 00750 00751 const char * 00752 NdbDictionary::Index::getIndexColumn(int no) const { 00753 const NdbDictionary::Column* col = getColumn(no); 00754 00755 if (col) 00756 return col->getName(); 00757 else 00758 return NULL; 00759 } 00760 00761 void 00762 NdbDictionary::Index::addColumn(const Column & c){ 00763 NdbColumnImpl* col = new NdbColumnImpl; 00764 (* col) = NdbColumnImpl::getImpl(c); 00765 m_impl.m_columns.push_back(col); 00766 } 00767 00768 void 00769 NdbDictionary::Index::addColumnName(const char * name){ 00770 const Column c(name); 00771 addColumn(c); 00772 } 00773 00774 void 00775 NdbDictionary::Index::addIndexColumn(const char * name){ 00776 const Column c(name); 00777 addColumn(c); 00778 } 00779 00780 void 00781 NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){ 00782 for(unsigned i = 0; i < noOfNames; i++) { 00783 const Column c(names[i]); 00784 addColumn(c); 00785 } 00786 } 00787 00788 void 00789 NdbDictionary::Index::addIndexColumns(int noOfNames, const char ** names){ 00790 for(int i = 0; i < noOfNames; i++) { 00791 const Column c(names[i]); 00792 addColumn(c); 00793 } 00794 } 00795 00796 void 00797 NdbDictionary::Index::setType(NdbDictionary::Index::Type t){ 00798 m_impl.m_type = (NdbDictionary::Object::Type)t; 00799 } 00800 00801 NdbDictionary::Index::Type 00802 NdbDictionary::Index::getType() const { 00803 return (NdbDictionary::Index::Type)m_impl.m_type; 00804 } 00805 00806 void 00807 NdbDictionary::Index::setLogging(bool val){ 00808 m_impl.m_logging = val; 00809 } 00810 00811 bool 00812 NdbDictionary::Index::getLogging() const { 00813 return m_impl.m_logging; 00814 } 00815 00816 NdbDictionary::Object::Status 00817 NdbDictionary::Index::getObjectStatus() const { 00818 return m_impl.m_table->m_status; 00819 } 00820 00821 int 00822 NdbDictionary::Index::getObjectVersion() const { 00823 return m_impl.m_table->m_version; 00824 } 00825 00826 int 00827 NdbDictionary::Index::getObjectId() const { 00828 return m_impl.m_table->m_id; 00829 } 00830 00831 00832 /***************************************************************** 00833 * Event facade 00834 */ 00835 NdbDictionary::Event::Event(const char * name) 00836 : m_impl(* new NdbEventImpl(* this)) 00837 { 00838 setName(name); 00839 } 00840 00841 NdbDictionary::Event::Event(const char * name, const Table& table) 00842 : m_impl(* new NdbEventImpl(* this)) 00843 { 00844 setName(name); 00845 setTable(table); 00846 } 00847 00848 NdbDictionary::Event::Event(NdbEventImpl & impl) 00849 : m_impl(impl) 00850 { 00851 } 00852 00853 NdbDictionary::Event::~Event() 00854 { 00855 NdbEventImpl * tmp = &m_impl; 00856 if(this != tmp){ 00857 delete tmp; 00858 } 00859 } 00860 00861 void 00862 NdbDictionary::Event::setName(const char * name) 00863 { 00864 m_impl.setName(name); 00865 } 00866 00867 const char * 00868 NdbDictionary::Event::getName() const 00869 { 00870 return m_impl.getName(); 00871 } 00872 00873 void 00874 NdbDictionary::Event::setTable(const Table& table) 00875 { 00876 m_impl.setTable(table); 00877 } 00878 00879 const NdbDictionary::Table * 00880 NdbDictionary::Event::getTable() const 00881 { 00882 return m_impl.getTable(); 00883 } 00884 00885 void 00886 NdbDictionary::Event::setTable(const char * table) 00887 { 00888 m_impl.setTable(table); 00889 } 00890 00891 const char* 00892 NdbDictionary::Event::getTableName() const 00893 { 00894 return m_impl.getTableName(); 00895 } 00896 00897 void 00898 NdbDictionary::Event::addTableEvent(const TableEvent t) 00899 { 00900 m_impl.addTableEvent(t); 00901 } 00902 00903 bool 00904 NdbDictionary::Event::getTableEvent(const TableEvent t) const 00905 { 00906 return m_impl.getTableEvent(t); 00907 } 00908 00909 void 00910 NdbDictionary::Event::setDurability(EventDurability d) 00911 { 00912 m_impl.setDurability(d); 00913 } 00914 00915 NdbDictionary::Event::EventDurability 00916 NdbDictionary::Event::getDurability() const 00917 { 00918 return m_impl.getDurability(); 00919 } 00920 00921 void 00922 NdbDictionary::Event::setReport(EventReport r) 00923 { 00924 m_impl.setReport(r); 00925 } 00926 00927 NdbDictionary::Event::EventReport 00928 NdbDictionary::Event::getReport() const 00929 { 00930 return m_impl.getReport(); 00931 } 00932 00933 void 00934 NdbDictionary::Event::addColumn(const Column & c){ 00935 NdbColumnImpl* col = new NdbColumnImpl; 00936 (* col) = NdbColumnImpl::getImpl(c); 00937 m_impl.m_columns.push_back(col); 00938 } 00939 00940 void 00941 NdbDictionary::Event::addEventColumn(unsigned attrId) 00942 { 00943 m_impl.m_attrIds.push_back(attrId); 00944 } 00945 00946 void 00947 NdbDictionary::Event::addEventColumn(const char * name) 00948 { 00949 const Column c(name); 00950 addColumn(c); 00951 } 00952 00953 void 00954 NdbDictionary::Event::addEventColumns(int n, const char ** names) 00955 { 00956 for (int i = 0; i < n; i++) 00957 addEventColumn(names[i]); 00958 } 00959 00960 int NdbDictionary::Event::getNoOfEventColumns() const 00961 { 00962 return m_impl.getNoOfEventColumns(); 00963 } 00964 00965 const NdbDictionary::Column * 00966 NdbDictionary::Event::getEventColumn(unsigned no) const 00967 { 00968 return m_impl.getEventColumn(no); 00969 } 00970 00971 void NdbDictionary::Event::mergeEvents(bool flag) 00972 { 00973 m_impl.m_mergeEvents = flag; 00974 } 00975 00976 NdbDictionary::Object::Status 00977 NdbDictionary::Event::getObjectStatus() const 00978 { 00979 return m_impl.m_status; 00980 } 00981 00982 int 00983 NdbDictionary::Event::getObjectVersion() const 00984 { 00985 return m_impl.m_version; 00986 } 00987 00988 int 00989 NdbDictionary::Event::getObjectId() const { 00990 return m_impl.m_id; 00991 } 00992 00993 void NdbDictionary::Event::print() 00994 { 00995 m_impl.print(); 00996 } 00997 00998 /***************************************************************** 00999 * Tablespace facade 01000 */ 01001 NdbDictionary::Tablespace::Tablespace() 01002 : m_impl(* new NdbTablespaceImpl(* this)) 01003 { 01004 } 01005 01006 NdbDictionary::Tablespace::Tablespace(NdbTablespaceImpl & impl) 01007 : m_impl(impl) 01008 { 01009 } 01010 01011 NdbDictionary::Tablespace::Tablespace(const NdbDictionary::Tablespace & org) 01012 : Object(org), m_impl(* new NdbTablespaceImpl(* this)) 01013 { 01014 m_impl.assign(org.m_impl); 01015 } 01016 01017 NdbDictionary::Tablespace::~Tablespace(){ 01018 NdbTablespaceImpl * tmp = &m_impl; 01019 if(this != tmp){ 01020 delete tmp; 01021 } 01022 } 01023 01024 void 01025 NdbDictionary::Tablespace::setName(const char * name){ 01026 m_impl.m_name.assign(name); 01027 } 01028 01029 const char * 01030 NdbDictionary::Tablespace::getName() const { 01031 return m_impl.m_name.c_str(); 01032 } 01033 01034 void 01035 NdbDictionary::Tablespace::setAutoGrowSpecification 01036 (const NdbDictionary::AutoGrowSpecification& spec){ 01037 m_impl.m_grow_spec = spec; 01038 } 01039 const NdbDictionary::AutoGrowSpecification& 01040 NdbDictionary::Tablespace::getAutoGrowSpecification() const { 01041 return m_impl.m_grow_spec; 01042 } 01043 01044 void 01045 NdbDictionary::Tablespace::setExtentSize(Uint32 sz){ 01046 m_impl.m_extent_size = sz; 01047 } 01048 01049 Uint32 01050 NdbDictionary::Tablespace::getExtentSize() const { 01051 return m_impl.m_extent_size; 01052 } 01053 01054 void 01055 NdbDictionary::Tablespace::setDefaultLogfileGroup(const char * name){ 01056 m_impl.m_logfile_group_id = ~0; 01057 m_impl.m_logfile_group_version = ~0; 01058 m_impl.m_logfile_group_name.assign(name); 01059 } 01060 01061 void 01062 NdbDictionary::Tablespace::setDefaultLogfileGroup 01063 (const NdbDictionary::LogfileGroup & lg){ 01064 m_impl.m_logfile_group_id = NdbLogfileGroupImpl::getImpl(lg).m_id; 01065 m_impl.m_logfile_group_version = lg.getObjectVersion(); 01066 m_impl.m_logfile_group_name.assign(lg.getName()); 01067 } 01068 01069 const char * 01070 NdbDictionary::Tablespace::getDefaultLogfileGroup() const { 01071 return m_impl.m_logfile_group_name.c_str(); 01072 } 01073 01074 Uint32 01075 NdbDictionary::Tablespace::getDefaultLogfileGroupId() const { 01076 return m_impl.m_logfile_group_id; 01077 } 01078 01079 NdbDictionary::Object::Status 01080 NdbDictionary::Tablespace::getObjectStatus() const { 01081 return m_impl.m_status; 01082 } 01083 01084 int 01085 NdbDictionary::Tablespace::getObjectVersion() const { 01086 return m_impl.m_version; 01087 } 01088 01089 int 01090 NdbDictionary::Tablespace::getObjectId() const { 01091 return m_impl.m_id; 01092 } 01093 01094 /***************************************************************** 01095 * LogfileGroup facade 01096 */ 01097 NdbDictionary::LogfileGroup::LogfileGroup() 01098 : m_impl(* new NdbLogfileGroupImpl(* this)) 01099 { 01100 } 01101 01102 NdbDictionary::LogfileGroup::LogfileGroup(NdbLogfileGroupImpl & impl) 01103 : m_impl(impl) 01104 { 01105 } 01106 01107 NdbDictionary::LogfileGroup::LogfileGroup(const NdbDictionary::LogfileGroup & org) 01108 : Object(org), m_impl(* new NdbLogfileGroupImpl(* this)) 01109 { 01110 m_impl.assign(org.m_impl); 01111 } 01112 01113 NdbDictionary::LogfileGroup::~LogfileGroup(){ 01114 NdbLogfileGroupImpl * tmp = &m_impl; 01115 if(this != tmp){ 01116 delete tmp; 01117 } 01118 } 01119 01120 void 01121 NdbDictionary::LogfileGroup::setName(const char * name){ 01122 m_impl.m_name.assign(name); 01123 } 01124 01125 const char * 01126 NdbDictionary::LogfileGroup::getName() const { 01127 return m_impl.m_name.c_str(); 01128 } 01129 01130 void 01131 NdbDictionary::LogfileGroup::setUndoBufferSize(Uint32 sz){ 01132 m_impl.m_undo_buffer_size = sz; 01133 } 01134 01135 Uint32 01136 NdbDictionary::LogfileGroup::getUndoBufferSize() const { 01137 return m_impl.m_undo_buffer_size; 01138 } 01139 01140 void 01141 NdbDictionary::LogfileGroup::setAutoGrowSpecification 01142 (const NdbDictionary::AutoGrowSpecification& spec){ 01143 m_impl.m_grow_spec = spec; 01144 } 01145 const NdbDictionary::AutoGrowSpecification& 01146 NdbDictionary::LogfileGroup::getAutoGrowSpecification() const { 01147 return m_impl.m_grow_spec; 01148 } 01149 01150 Uint64 NdbDictionary::LogfileGroup::getUndoFreeWords() const { 01151 return m_impl.m_undo_free_words; 01152 } 01153 01154 NdbDictionary::Object::Status 01155 NdbDictionary::LogfileGroup::getObjectStatus() const { 01156 return m_impl.m_status; 01157 } 01158 01159 int 01160 NdbDictionary::LogfileGroup::getObjectVersion() const { 01161 return m_impl.m_version; 01162 } 01163 01164 int 01165 NdbDictionary::LogfileGroup::getObjectId() const { 01166 return m_impl.m_id; 01167 } 01168 01169 /***************************************************************** 01170 * Datafile facade 01171 */ 01172 NdbDictionary::Datafile::Datafile() 01173 : m_impl(* new NdbDatafileImpl(* this)) 01174 { 01175 } 01176 01177 NdbDictionary::Datafile::Datafile(NdbDatafileImpl & impl) 01178 : m_impl(impl) 01179 { 01180 } 01181 01182 NdbDictionary::Datafile::Datafile(const NdbDictionary::Datafile & org) 01183 : Object(org), m_impl(* new NdbDatafileImpl(* this)) 01184 { 01185 m_impl.assign(org.m_impl); 01186 } 01187 01188 NdbDictionary::Datafile::~Datafile(){ 01189 NdbDatafileImpl * tmp = &m_impl; 01190 if(this != tmp){ 01191 delete tmp; 01192 } 01193 } 01194 01195 void 01196 NdbDictionary::Datafile::setPath(const char * path){ 01197 m_impl.m_path.assign(path); 01198 } 01199 01200 const char * 01201 NdbDictionary::Datafile::getPath() const { 01202 return m_impl.m_path.c_str(); 01203 } 01204 01205 void 01206 NdbDictionary::Datafile::setSize(Uint64 sz){ 01207 m_impl.m_size = sz; 01208 } 01209 01210 Uint64 01211 NdbDictionary::Datafile::getSize() const { 01212 return m_impl.m_size; 01213 } 01214 01215 Uint64 01216 NdbDictionary::Datafile::getFree() const { 01217 return m_impl.m_free; 01218 } 01219 01220 void 01221 NdbDictionary::Datafile::setTablespace(const char * tablespace){ 01222 m_impl.m_filegroup_id = ~0; 01223 m_impl.m_filegroup_version = ~0; 01224 m_impl.m_filegroup_name.assign(tablespace); 01225 } 01226 01227 void 01228 NdbDictionary::Datafile::setTablespace(const NdbDictionary::Tablespace & ts){ 01229 m_impl.m_filegroup_id = NdbTablespaceImpl::getImpl(ts).m_id; 01230 m_impl.m_filegroup_version = ts.getObjectVersion(); 01231 m_impl.m_filegroup_name.assign(ts.getName()); 01232 } 01233 01234 const char * 01235 NdbDictionary::Datafile::getTablespace() const { 01236 return m_impl.m_filegroup_name.c_str(); 01237 } 01238 01239 void 01240 NdbDictionary::Datafile::getTablespaceId(NdbDictionary::ObjectId* dst) const 01241 { 01242 if (dst) 01243 { 01244 NdbDictObjectImpl::getImpl(* dst).m_id = m_impl.m_filegroup_id; 01245 NdbDictObjectImpl::getImpl(* dst).m_version = m_impl.m_filegroup_version; 01246 } 01247 } 01248 01249 NdbDictionary::Object::Status 01250 NdbDictionary::Datafile::getObjectStatus() const { 01251 return m_impl.m_status; 01252 } 01253 01254 int 01255 NdbDictionary::Datafile::getObjectVersion() const { 01256 return m_impl.m_version; 01257 } 01258 01259 int 01260 NdbDictionary::Datafile::getObjectId() const { 01261 return m_impl.m_id; 01262 } 01263 01264 /***************************************************************** 01265 * Undofile facade 01266 */ 01267 NdbDictionary::Undofile::Undofile() 01268 : m_impl(* new NdbUndofileImpl(* this)) 01269 { 01270 } 01271 01272 NdbDictionary::Undofile::Undofile(NdbUndofileImpl & impl) 01273 : m_impl(impl) 01274 { 01275 } 01276 01277 NdbDictionary::Undofile::Undofile(const NdbDictionary::Undofile & org) 01278 : Object(org), m_impl(* new NdbUndofileImpl(* this)) 01279 { 01280 m_impl.assign(org.m_impl); 01281 } 01282 01283 NdbDictionary::Undofile::~Undofile(){ 01284 NdbUndofileImpl * tmp = &m_impl; 01285 if(this != tmp){ 01286 delete tmp; 01287 } 01288 } 01289 01290 void 01291 NdbDictionary::Undofile::setPath(const char * path){ 01292 m_impl.m_path.assign(path); 01293 } 01294 01295 const char * 01296 NdbDictionary::Undofile::getPath() const { 01297 return m_impl.m_path.c_str(); 01298 } 01299 01300 void 01301 NdbDictionary::Undofile::setSize(Uint64 sz){ 01302 m_impl.m_size = sz; 01303 } 01304 01305 Uint64 01306 NdbDictionary::Undofile::getSize() const { 01307 return m_impl.m_size; 01308 } 01309 01310 void 01311 NdbDictionary::Undofile::setLogfileGroup(const char * logfileGroup){ 01312 m_impl.m_filegroup_id = ~0; 01313 m_impl.m_filegroup_version = ~0; 01314 m_impl.m_filegroup_name.assign(logfileGroup); 01315 } 01316 01317 void 01318 NdbDictionary::Undofile::setLogfileGroup 01319 (const NdbDictionary::LogfileGroup & ts){ 01320 m_impl.m_filegroup_id = NdbLogfileGroupImpl::getImpl(ts).m_id; 01321 m_impl.m_filegroup_version = ts.getObjectVersion(); 01322 m_impl.m_filegroup_name.assign(ts.getName()); 01323 } 01324 01325 const char * 01326 NdbDictionary::Undofile::getLogfileGroup() const { 01327 return m_impl.m_filegroup_name.c_str(); 01328 } 01329 01330 void 01331 NdbDictionary::Undofile::getLogfileGroupId(NdbDictionary::ObjectId * dst)const 01332 { 01333 if (dst) 01334 { 01335 NdbDictObjectImpl::getImpl(* dst).m_id = m_impl.m_filegroup_id; 01336 NdbDictObjectImpl::getImpl(* dst).m_version = m_impl.m_filegroup_version; 01337 } 01338 } 01339 01340 NdbDictionary::Object::Status 01341 NdbDictionary::Undofile::getObjectStatus() const { 01342 return m_impl.m_status; 01343 } 01344 01345 int 01346 NdbDictionary::Undofile::getObjectVersion() const { 01347 return m_impl.m_version; 01348 } 01349 01350 int 01351 NdbDictionary::Undofile::getObjectId() const { 01352 return m_impl.m_id; 01353 } 01354 01355 /***************************************************************** 01356 * Dictionary facade 01357 */ 01358 NdbDictionary::Dictionary::Dictionary(Ndb & ndb) 01359 : m_impl(* new NdbDictionaryImpl(ndb, *this)) 01360 { 01361 } 01362 01363 NdbDictionary::Dictionary::Dictionary(NdbDictionaryImpl & impl) 01364 : m_impl(impl) 01365 { 01366 } 01367 NdbDictionary::Dictionary::~Dictionary(){ 01368 NdbDictionaryImpl * tmp = &m_impl; 01369 if(this != tmp){ 01370 delete tmp; 01371 } 01372 } 01373 01374 int 01375 NdbDictionary::Dictionary::createTable(const Table & t) 01376 { 01377 DBUG_ENTER("NdbDictionary::Dictionary::createTable"); 01378 DBUG_RETURN(m_impl.createTable(NdbTableImpl::getImpl(t))); 01379 } 01380 01381 int 01382 NdbDictionary::Dictionary::dropTable(Table & t){ 01383 return m_impl.dropTable(NdbTableImpl::getImpl(t)); 01384 } 01385 01386 int 01387 NdbDictionary::Dictionary::dropTableGlobal(const Table & t){ 01388 return m_impl.dropTableGlobal(NdbTableImpl::getImpl(t)); 01389 } 01390 01391 int 01392 NdbDictionary::Dictionary::dropTable(const char * name){ 01393 return m_impl.dropTable(name); 01394 } 01395 01396 int 01397 NdbDictionary::Dictionary::alterTable(const Table & t){ 01398 return m_impl.alterTable(NdbTableImpl::getImpl(t)); 01399 } 01400 01401 int 01402 NdbDictionary::Dictionary::alterTableGlobal(const Table & f, 01403 const Table & t) 01404 { 01405 return m_impl.alterTableGlobal(NdbTableImpl::getImpl(f), 01406 NdbTableImpl::getImpl(t)); 01407 } 01408 01409 const NdbDictionary::Table * 01410 NdbDictionary::Dictionary::getTable(const char * name, void **data) const 01411 { 01412 NdbTableImpl * t = m_impl.getTable(name, data); 01413 if(t) 01414 return t->m_facade; 01415 return 0; 01416 } 01417 01418 const NdbDictionary::Index * 01419 NdbDictionary::Dictionary::getIndexGlobal(const char * indexName, 01420 const Table &ndbtab) const 01421 { 01422 NdbIndexImpl * i = m_impl.getIndexGlobal(indexName, 01423 NdbTableImpl::getImpl(ndbtab)); 01424 if(i) 01425 return i->m_facade; 01426 return 0; 01427 } 01428 01429 const NdbDictionary::Table * 01430 NdbDictionary::Dictionary::getTableGlobal(const char * name) const 01431 { 01432 NdbTableImpl * t = m_impl.getTableGlobal(name); 01433 if(t) 01434 return t->m_facade; 01435 return 0; 01436 } 01437 01438 int 01439 NdbDictionary::Dictionary::removeIndexGlobal(const Index &ndbidx, 01440 int invalidate) const 01441 { 01442 return m_impl.releaseIndexGlobal(NdbIndexImpl::getImpl(ndbidx), invalidate); 01443 } 01444 01445 int 01446 NdbDictionary::Dictionary::removeTableGlobal(const Table &ndbtab, 01447 int invalidate) const 01448 { 01449 return m_impl.releaseTableGlobal(NdbTableImpl::getImpl(ndbtab), invalidate); 01450 } 01451 01452 void NdbDictionary::Dictionary::putTable(const NdbDictionary::Table * table) 01453 { 01454 NdbDictionary::Table *copy_table = new NdbDictionary::Table; 01455 *copy_table = *table; 01456 m_impl.putTable(&NdbTableImpl::getImpl(*copy_table)); 01457 } 01458 01459 void NdbDictionary::Dictionary::set_local_table_data_size(unsigned sz) 01460 { 01461 m_impl.m_local_table_data_size= sz; 01462 } 01463 01464 const NdbDictionary::Table * 01465 NdbDictionary::Dictionary::getTable(const char * name) const 01466 { 01467 return getTable(name, 0); 01468 } 01469 01470 const NdbDictionary::Table * 01471 NdbDictionary::Dictionary::getBlobTable(const NdbDictionary::Table* table, 01472 const char* col_name) 01473 { 01474 const NdbDictionary::Column* col = table->getColumn(col_name); 01475 if (col == NULL) { 01476 m_impl.m_error.code = 4318; 01477 return NULL; 01478 } 01479 return getBlobTable(table, col->getColumnNo()); 01480 } 01481 01482 const NdbDictionary::Table * 01483 NdbDictionary::Dictionary::getBlobTable(const NdbDictionary::Table* table, 01484 Uint32 col_no) 01485 { 01486 return m_impl.getBlobTable(NdbTableImpl::getImpl(*table), col_no); 01487 } 01488 01489 void 01490 NdbDictionary::Dictionary::invalidateTable(const char * name){ 01491 DBUG_ENTER("NdbDictionaryImpl::invalidateTable"); 01492 NdbTableImpl * t = m_impl.getTable(name); 01493 if(t) 01494 m_impl.invalidateObject(* t); 01495 DBUG_VOID_RETURN; 01496 } 01497 01498 void 01499 NdbDictionary::Dictionary::invalidateTable(const Table *table){ 01500 NdbTableImpl &t = NdbTableImpl::getImpl(*table); 01501 m_impl.invalidateObject(t); 01502 } 01503 01504 void 01505 NdbDictionary::Dictionary::removeCachedTable(const char * name){ 01506 NdbTableImpl * t = m_impl.getTable(name); 01507 if(t) 01508 m_impl.removeCachedObject(* t); 01509 } 01510 01511 void 01512 NdbDictionary::Dictionary::removeCachedTable(const Table *table){ 01513 NdbTableImpl &t = NdbTableImpl::getImpl(*table); 01514 m_impl.removeCachedObject(t); 01515 } 01516 01517 int 01518 NdbDictionary::Dictionary::createIndex(const Index & ind) 01519 { 01520 return m_impl.createIndex(NdbIndexImpl::getImpl(ind)); 01521 } 01522 01523 int 01524 NdbDictionary::Dictionary::createIndex(const Index & ind, const Table & tab) 01525 { 01526 return m_impl.createIndex(NdbIndexImpl::getImpl(ind), 01527 NdbTableImpl::getImpl(tab)); 01528 } 01529 01530 int 01531 NdbDictionary::Dictionary::dropIndex(const char * indexName, 01532 const char * tableName) 01533 { 01534 return m_impl.dropIndex(indexName, tableName); 01535 } 01536 01537 int 01538 NdbDictionary::Dictionary::dropIndexGlobal(const Index &ind) 01539 { 01540 return m_impl.dropIndexGlobal(NdbIndexImpl::getImpl(ind)); 01541 } 01542 01543 const NdbDictionary::Index * 01544 NdbDictionary::Dictionary::getIndex(const char * indexName, 01545 const char * tableName) const 01546 { 01547 NdbIndexImpl * i = m_impl.getIndex(indexName, tableName); 01548 if(i) 01549 return i->m_facade; 01550 return 0; 01551 } 01552 01553 void 01554 NdbDictionary::Dictionary::invalidateIndex(const Index *index){ 01555 DBUG_ENTER("NdbDictionary::Dictionary::invalidateIndex"); 01556 NdbIndexImpl &i = NdbIndexImpl::getImpl(*index); 01557 assert(i.m_table != 0); 01558 m_impl.invalidateObject(* i.m_table); 01559 DBUG_VOID_RETURN; 01560 } 01561 01562 void 01563 NdbDictionary::Dictionary::invalidateIndex(const char * indexName, 01564 const char * tableName){ 01565 DBUG_ENTER("NdbDictionaryImpl::invalidateIndex"); 01566 NdbIndexImpl * i = m_impl.getIndex(indexName, tableName); 01567 if(i) { 01568 assert(i->m_table != 0); 01569 m_impl.invalidateObject(* i->m_table); 01570 } 01571 DBUG_VOID_RETURN; 01572 } 01573 01574 int 01575 NdbDictionary::Dictionary::forceGCPWait() 01576 { 01577 return m_impl.forceGCPWait(); 01578 } 01579 01580 void 01581 NdbDictionary::Dictionary::removeCachedIndex(const Index *index){ 01582 DBUG_ENTER("NdbDictionary::Dictionary::removeCachedIndex"); 01583 NdbIndexImpl &i = NdbIndexImpl::getImpl(*index); 01584 assert(i.m_table != 0); 01585 m_impl.removeCachedObject(* i.m_table); 01586 DBUG_VOID_RETURN; 01587 } 01588 01589 void 01590 NdbDictionary::Dictionary::removeCachedIndex(const char * indexName, 01591 const char * tableName){ 01592 NdbIndexImpl * i = m_impl.getIndex(indexName, tableName); 01593 if(i) { 01594 assert(i->m_table != 0); 01595 m_impl.removeCachedObject(* i->m_table); 01596 } 01597 } 01598 01599 const NdbDictionary::Table * 01600 NdbDictionary::Dictionary::getIndexTable(const char * indexName, 01601 const char * tableName) const 01602 { 01603 NdbIndexImpl * i = m_impl.getIndex(indexName, tableName); 01604 NdbTableImpl * t = m_impl.getTable(tableName); 01605 if(i && t) { 01606 NdbTableImpl * it = m_impl.getIndexTable(i, t); 01607 return it->m_facade; 01608 } 01609 return 0; 01610 } 01611 01612 01613 int 01614 NdbDictionary::Dictionary::createEvent(const Event & ev) 01615 { 01616 return m_impl.createEvent(NdbEventImpl::getImpl(ev)); 01617 } 01618 01619 int 01620 NdbDictionary::Dictionary::dropEvent(const char * eventName) 01621 { 01622 return m_impl.dropEvent(eventName); 01623 } 01624 01625 const NdbDictionary::Event * 01626 NdbDictionary::Dictionary::getEvent(const char * eventName) 01627 { 01628 NdbEventImpl * t = m_impl.getEvent(eventName); 01629 if(t) 01630 return t->m_facade; 01631 return 0; 01632 } 01633 01634 int 01635 NdbDictionary::Dictionary::listObjects(List& list, Object::Type type) 01636 { 01637 return m_impl.listObjects(list, type); 01638 } 01639 01640 int 01641 NdbDictionary::Dictionary::listObjects(List& list, Object::Type type) const 01642 { 01643 return m_impl.listObjects(list, type); 01644 } 01645 01646 int 01647 NdbDictionary::Dictionary::listIndexes(List& list, const char * tableName) 01648 { 01649 const NdbDictionary::Table* tab= getTable(tableName); 01650 if(tab == 0) 01651 { 01652 return -1; 01653 } 01654 return m_impl.listIndexes(list, tab->getTableId()); 01655 } 01656 01657 int 01658 NdbDictionary::Dictionary::listIndexes(List& list, 01659 const char * tableName) const 01660 { 01661 const NdbDictionary::Table* tab= getTable(tableName); 01662 if(tab == 0) 01663 { 01664 return -1; 01665 } 01666 return m_impl.listIndexes(list, tab->getTableId()); 01667 } 01668 01669 int 01670 NdbDictionary::Dictionary::listIndexes(List& list, 01671 const NdbDictionary::Table &table) const 01672 { 01673 return m_impl.listIndexes(list, table.getTableId()); 01674 } 01675 01676 01677 const struct NdbError & 01678 NdbDictionary::Dictionary::getNdbError() const { 01679 return m_impl.getNdbError(); 01680 } 01681 01682 // printers 01683 01684 NdbOut& 01685 operator<<(NdbOut& out, const NdbDictionary::Column& col) 01686 { 01687 const CHARSET_INFO *cs = col.getCharset(); 01688 const char *csname = cs ? cs->name : "?"; 01689 out << col.getName() << " "; 01690 switch (col.getType()) { 01691 case NdbDictionary::Column::Tinyint: 01692 out << "Tinyint"; 01693 break; 01694 case NdbDictionary::Column::Tinyunsigned: 01695 out << "Tinyunsigned"; 01696 break; 01697 case NdbDictionary::Column::Smallint: 01698 out << "Smallint"; 01699 break; 01700 case NdbDictionary::Column::Smallunsigned: 01701 out << "Smallunsigned"; 01702 break; 01703 case NdbDictionary::Column::Mediumint: 01704 out << "Mediumint"; 01705 break; 01706 case NdbDictionary::Column::Mediumunsigned: 01707 out << "Mediumunsigned"; 01708 break; 01709 case NdbDictionary::Column::Int: 01710 out << "Int"; 01711 break; 01712 case NdbDictionary::Column::Unsigned: 01713 out << "Unsigned"; 01714 break; 01715 case NdbDictionary::Column::Bigint: 01716 out << "Bigint"; 01717 break; 01718 case NdbDictionary::Column::Bigunsigned: 01719 out << "Bigunsigned"; 01720 break; 01721 case NdbDictionary::Column::Float: 01722 out << "Float"; 01723 break; 01724 case NdbDictionary::Column::Double: 01725 out << "Double"; 01726 break; 01727 case NdbDictionary::Column::Olddecimal: 01728 out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")"; 01729 break; 01730 case NdbDictionary::Column::Olddecimalunsigned: 01731 out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; 01732 break; 01733 case NdbDictionary::Column::Decimal: 01734 out << "Decimal(" << col.getPrecision() << "," << col.getScale() << ")"; 01735 break; 01736 case NdbDictionary::Column::Decimalunsigned: 01737 out << "Decimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; 01738 break; 01739 case NdbDictionary::Column::Char: 01740 out << "Char(" << col.getLength() << ";" << csname << ")"; 01741 break; 01742 case NdbDictionary::Column::Varchar: 01743 out << "Varchar(" << col.getLength() << ";" << csname << ")"; 01744 break; 01745 case NdbDictionary::Column::Binary: 01746 out << "Binary(" << col.getLength() << ")"; 01747 break; 01748 case NdbDictionary::Column::Varbinary: 01749 out << "Varbinary(" << col.getLength() << ")"; 01750 break; 01751 case NdbDictionary::Column::Datetime: 01752 out << "Datetime"; 01753 break; 01754 case NdbDictionary::Column::Date: 01755 out << "Date"; 01756 break; 01757 case NdbDictionary::Column::Blob: 01758 out << "Blob(" << col.getInlineSize() << "," << col.getPartSize() 01759 << ";" << col.getStripeSize() << ")"; 01760 break; 01761 case NdbDictionary::Column::Text: 01762 out << "Text(" << col.getInlineSize() << "," << col.getPartSize() 01763 << ";" << col.getStripeSize() << ";" << csname << ")"; 01764 break; 01765 case NdbDictionary::Column::Time: 01766 out << "Time"; 01767 break; 01768 case NdbDictionary::Column::Year: 01769 out << "Year"; 01770 break; 01771 case NdbDictionary::Column::Timestamp: 01772 out << "Timestamp"; 01773 break; 01774 case NdbDictionary::Column::Undefined: 01775 out << "Undefined"; 01776 break; 01777 case NdbDictionary::Column::Bit: 01778 out << "Bit(" << col.getLength() << ")"; 01779 break; 01780 case NdbDictionary::Column::Longvarchar: 01781 out << "Longvarchar(" << col.getLength() << ";" << csname << ")"; 01782 break; 01783 case NdbDictionary::Column::Longvarbinary: 01784 out << "Longvarbinary(" << col.getLength() << ")"; 01785 break; 01786 default: 01787 out << "Type" << (Uint32)col.getType(); 01788 break; 01789 } 01790 // show unusual (non-MySQL) array size 01791 if (col.getLength() != 1) { 01792 switch (col.getType()) { 01793 case NdbDictionary::Column::Char: 01794 case NdbDictionary::Column::Varchar: 01795 case NdbDictionary::Column::Binary: 01796 case NdbDictionary::Column::Varbinary: 01797 case NdbDictionary::Column::Blob: 01798 case NdbDictionary::Column::Text: 01799 case NdbDictionary::Column::Bit: 01800 case NdbDictionary::Column::Longvarchar: 01801 case NdbDictionary::Column::Longvarbinary: 01802 break; 01803 default: 01804 out << " [" << col.getLength() << "]"; 01805 break; 01806 } 01807 } 01808 01809 if (col.getPrimaryKey()) 01810 out << " PRIMARY KEY"; 01811 else if (! col.getNullable()) 01812 out << " NOT NULL"; 01813 else 01814 out << " NULL"; 01815 01816 if(col.getDistributionKey()) 01817 out << " DISTRIBUTION KEY"; 01818 01819 switch (col.getArrayType()) { 01820 case NDB_ARRAYTYPE_FIXED: 01821 out << " AT=FIXED"; 01822 break; 01823 case NDB_ARRAYTYPE_SHORT_VAR: 01824 out << " AT=SHORT_VAR"; 01825 break; 01826 case NDB_ARRAYTYPE_MEDIUM_VAR: 01827 out << " AT=MEDIUM_VAR"; 01828 break; 01829 default: 01830 out << " AT=" << (int)col.getArrayType() << "?"; 01831 break; 01832 } 01833 01834 switch (col.getStorageType()) { 01835 case NDB_STORAGETYPE_MEMORY: 01836 out << " ST=MEMORY"; 01837 break; 01838 case NDB_STORAGETYPE_DISK: 01839 out << " ST=DISK"; 01840 break; 01841 default: 01842 out << " ST=" << (int)col.getStorageType() << "?"; 01843 break; 01844 } 01845 01846 return out; 01847 } 01848 01849 int 01850 NdbDictionary::Dictionary::createLogfileGroup(const LogfileGroup & lg, 01851 ObjectId * obj) 01852 { 01853 return m_impl.createLogfileGroup(NdbLogfileGroupImpl::getImpl(lg), 01854 obj ? 01855 & NdbDictObjectImpl::getImpl(* obj) : 0); 01856 } 01857 01858 int 01859 NdbDictionary::Dictionary::dropLogfileGroup(const LogfileGroup & lg) 01860 { 01861 return m_impl.dropLogfileGroup(NdbLogfileGroupImpl::getImpl(lg)); 01862 } 01863 01864 NdbDictionary::LogfileGroup 01865 NdbDictionary::Dictionary::getLogfileGroup(const char * name) 01866 { 01867 NdbDictionary::LogfileGroup tmp; 01868 m_impl.m_receiver.get_filegroup(NdbLogfileGroupImpl::getImpl(tmp), 01869 NdbDictionary::Object::LogfileGroup, name); 01870 return tmp; 01871 } 01872 01873 int 01874 NdbDictionary::Dictionary::createTablespace(const Tablespace & lg, 01875 ObjectId * obj) 01876 { 01877 return m_impl.createTablespace(NdbTablespaceImpl::getImpl(lg), 01878 obj ? 01879 & NdbDictObjectImpl::getImpl(* obj) : 0); 01880 } 01881 01882 int 01883 NdbDictionary::Dictionary::dropTablespace(const Tablespace & lg) 01884 { 01885 return m_impl.dropTablespace(NdbTablespaceImpl::getImpl(lg)); 01886 } 01887 01888 NdbDictionary::Tablespace 01889 NdbDictionary::Dictionary::getTablespace(const char * name) 01890 { 01891 NdbDictionary::Tablespace tmp; 01892 m_impl.m_receiver.get_filegroup(NdbTablespaceImpl::getImpl(tmp), 01893 NdbDictionary::Object::Tablespace, name); 01894 return tmp; 01895 } 01896 01897 NdbDictionary::Tablespace 01898 NdbDictionary::Dictionary::getTablespace(Uint32 tablespaceId) 01899 { 01900 NdbDictionary::Tablespace tmp; 01901 m_impl.m_receiver.get_filegroup(NdbTablespaceImpl::getImpl(tmp), 01902 NdbDictionary::Object::Tablespace, 01903 tablespaceId); 01904 return tmp; 01905 } 01906 01907 int 01908 NdbDictionary::Dictionary::createDatafile(const Datafile & df, 01909 bool force, 01910 ObjectId * obj) 01911 { 01912 return m_impl.createDatafile(NdbDatafileImpl::getImpl(df), 01913 force, 01914 obj ? & NdbDictObjectImpl::getImpl(* obj) : 0); 01915 } 01916 01917 int 01918 NdbDictionary::Dictionary::dropDatafile(const Datafile& df) 01919 { 01920 return m_impl.dropDatafile(NdbDatafileImpl::getImpl(df)); 01921 } 01922 01923 NdbDictionary::Datafile 01924 NdbDictionary::Dictionary::getDatafile(Uint32 node, const char * path) 01925 { 01926 NdbDictionary::Datafile tmp; 01927 m_impl.m_receiver.get_file(NdbDatafileImpl::getImpl(tmp), 01928 NdbDictionary::Object::Datafile, 01929 node ? (int)node : -1, path); 01930 return tmp; 01931 } 01932 01933 int 01934 NdbDictionary::Dictionary::createUndofile(const Undofile & df, 01935 bool force, 01936 ObjectId * obj) 01937 { 01938 return m_impl.createUndofile(NdbUndofileImpl::getImpl(df), 01939 force, 01940 obj ? & NdbDictObjectImpl::getImpl(* obj) : 0); 01941 } 01942 01943 int 01944 NdbDictionary::Dictionary::dropUndofile(const Undofile& df) 01945 { 01946 return m_impl.dropUndofile(NdbUndofileImpl::getImpl(df)); 01947 } 01948 01949 NdbDictionary::Undofile 01950 NdbDictionary::Dictionary::getUndofile(Uint32 node, const char * path) 01951 { 01952 NdbDictionary::Undofile tmp; 01953 m_impl.m_receiver.get_file(NdbUndofileImpl::getImpl(tmp), 01954 NdbDictionary::Object::Undofile, 01955 node ? (int)node : -1, path); 01956 return tmp; 01957 } 01958
1.4.7

