NdbDictionary.cpp 42.6 KB
Newer Older
1 2 3 4
/* Copyright (C) 2003 MySQL AB

   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
5
   the Free Software Foundation; version 2 of the License.
6 7 8 9 10 11 12 13 14 15 16 17 18 19

   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.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

#include <NdbDictionary.hpp>
#include "NdbDictionaryImpl.hpp"
#include <NdbOut.hpp>

jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
NdbDictionary::ObjectId::ObjectId()
  : m_impl(* new NdbDictObjectImpl(NdbDictionary::Object::TypeUndefined))
{
}

NdbDictionary::ObjectId::~ObjectId()
{
  NdbDictObjectImpl * tmp = &m_impl;  
  delete tmp;
}

NdbDictionary::Object::Status
NdbDictionary::ObjectId::getObjectStatus() const {
  return m_impl.m_status;
}

int 
NdbDictionary::ObjectId::getObjectVersion() const {
  return m_impl.m_version;
}

int 
NdbDictionary::ObjectId::getObjectId() const {
  return m_impl.m_id;
}

46 47 48 49 50 51 52 53 54 55 56 57
/*****************************************************************
 * Column facade
 */
NdbDictionary::Column::Column(const char * name) 
  : m_impl(* new NdbColumnImpl(* this))
{
  setName(name);
}

NdbDictionary::Column::Column(const NdbDictionary::Column & org)
  : m_impl(* new NdbColumnImpl(* this))
{
joreland@mysql.com's avatar
joreland@mysql.com committed
58
  m_impl = org.m_impl;
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
}

NdbDictionary::Column::Column(NdbColumnImpl& impl)
  : m_impl(impl)
{
}

NdbDictionary::Column::~Column(){
  NdbColumnImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

NdbDictionary::Column&
NdbDictionary::Column::operator=(const NdbDictionary::Column& column)
{
  m_impl = column.m_impl;
  
  return *this;
}

81
int
82
NdbDictionary::Column::setName(const char * name){
83
  return !m_impl.m_name.assign(name);
84 85 86 87 88 89 90 91 92
}

const char* 
NdbDictionary::Column::getName() const {
  return m_impl.m_name.c_str();
}

void
NdbDictionary::Column::setType(Type t){
93
  m_impl.init(t);
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
}

NdbDictionary::Column::Type 
NdbDictionary::Column::getType() const {
  return m_impl.m_type;
}

void 
NdbDictionary::Column::setPrecision(int val){
  m_impl.m_precision = val;
}

int 
NdbDictionary::Column::getPrecision() const {
  return m_impl.m_precision;
}

void 
NdbDictionary::Column::setScale(int val){
  m_impl.m_scale = val;
}

int 
NdbDictionary::Column::getScale() const{
  return m_impl.m_scale;
}

void
NdbDictionary::Column::setLength(int length){
  m_impl.m_length = length;
}

int 
NdbDictionary::Column::getLength() const{
  return m_impl.m_length;
}

131 132 133 134 135 136
void
NdbDictionary::Column::setInlineSize(int size)
{
  m_impl.m_precision = size;
}

pekka@mysql.com's avatar
pekka@mysql.com committed
137 138 139 140 141 142 143 144 145 146 147 148
void
NdbDictionary::Column::setCharset(CHARSET_INFO* cs)
{
  m_impl.m_cs = cs;
}

CHARSET_INFO*
NdbDictionary::Column::getCharset() const
{
  return m_impl.m_cs;
}

149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
int
NdbDictionary::Column::getInlineSize() const
{
  return m_impl.m_precision;
}

void
NdbDictionary::Column::setPartSize(int size)
{
  m_impl.m_scale = size;
}

int
NdbDictionary::Column::getPartSize() const
{
  return m_impl.m_scale;
}

void
NdbDictionary::Column::setStripeSize(int size)
{
  m_impl.m_length = size;
}

int
NdbDictionary::Column::getStripeSize() const
{
  return m_impl.m_length;
}

179 180 181 182 183
int 
NdbDictionary::Column::getSize() const{
  return m_impl.m_attrSize;
}

184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
void 
NdbDictionary::Column::setNullable(bool val){
  m_impl.m_nullable = val;
}

bool 
NdbDictionary::Column::getNullable() const {
  return m_impl.m_nullable;
}

void 
NdbDictionary::Column::setPrimaryKey(bool val){
  m_impl.m_pk = val;
}

bool 
NdbDictionary::Column::getPrimaryKey() const {
  return m_impl.m_pk;
}

void 
205
NdbDictionary::Column::setPartitionKey(bool val){
206
  m_impl.m_distributionKey = val;
207 208 209
}

bool 
210
NdbDictionary::Column::getPartitionKey() const{
211
  return m_impl.m_distributionKey;
212 213
}

mskold@mysql.com's avatar
mskold@mysql.com committed
214 215 216 217 218 219 220 221
const NdbDictionary::Table * 
NdbDictionary::Column::getBlobTable() const {
  NdbTableImpl * t = m_impl.m_blobTable;
  if (t)
    return t->m_facade;
  return 0;
}

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
void 
NdbDictionary::Column::setAutoIncrement(bool val){
  m_impl.m_autoIncrement = val;
}

bool 
NdbDictionary::Column::getAutoIncrement() const {
  return m_impl.m_autoIncrement;
}

void
NdbDictionary::Column::setAutoIncrementInitialValue(Uint64 val){
  m_impl.m_autoIncrementInitialValue = val;
}

237
int
238 239
NdbDictionary::Column::setDefaultValue(const char* defaultValue)
{
240
  return !m_impl.m_defaultValue.assign(defaultValue);
241 242 243 244 245 246 247 248 249 250
}

const char*
NdbDictionary::Column::getDefaultValue() const
{
  return m_impl.m_defaultValue.c_str();
}

int
NdbDictionary::Column::getColumnNo() const {
251 252 253 254 255 256
  return m_impl.m_column_no;
}

int
NdbDictionary::Column::getAttrId() const {
  return m_impl.m_attrId;;
257 258 259 260 261 262 263
}

bool
NdbDictionary::Column::equal(const NdbDictionary::Column & col) const {
  return m_impl.equal(col.m_impl);
}

264 265 266 267 268 269
int
NdbDictionary::Column::getSizeInBytes() const 
{
  return m_impl.m_attrSize * m_impl.m_arraySize;
}

270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
void
NdbDictionary::Column::setArrayType(ArrayType type)
{
  m_impl.m_arrayType = type;
}

NdbDictionary::Column::ArrayType
NdbDictionary::Column::getArrayType() const
{
  return (ArrayType)m_impl.m_arrayType;
}

void
NdbDictionary::Column::setStorageType(StorageType type)
{
  m_impl.m_storageType = type;
}

NdbDictionary::Column::StorageType
NdbDictionary::Column::getStorageType() const
{
  return (StorageType)m_impl.m_storageType;
}

294 295 296 297 298 299 300 301 302 303
/*****************************************************************
 * Table facade
 */
NdbDictionary::Table::Table(const char * name)
  : m_impl(* new NdbTableImpl(* this)) 
{
  setName(name);
}

NdbDictionary::Table::Table(const NdbDictionary::Table & org)
304
  : Object(org), m_impl(* new NdbTableImpl(* this))
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
{
  m_impl.assign(org.m_impl);
}

NdbDictionary::Table::Table(NdbTableImpl & impl)
  : m_impl(impl)
{
}

NdbDictionary::Table::~Table(){
  NdbTableImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

NdbDictionary::Table&
mysqldev@mysql.com's avatar
mysqldev@mysql.com committed
322
NdbDictionary::Table::operator=(const NdbDictionary::Table& table)
323 324 325 326 327 328 329
{
  m_impl.assign(table.m_impl);
  
  m_impl.m_facade = this;
  return *this;
}

330
int
331
NdbDictionary::Table::setName(const char * name){
332
  return m_impl.setName(name);
333 334 335 336 337 338 339
}

const char * 
NdbDictionary::Table::getName() const {
  return m_impl.getName();
}

340 341 342 343 344
const char *
NdbDictionary::Table::getMysqlName() const {
  return m_impl.getMysqlName();
}

345 346
int
NdbDictionary::Table::getTableId() const {
347
  return m_impl.m_id;
348 349
}

350
int
351 352
NdbDictionary::Table::addColumn(const Column & c){
  NdbColumnImpl* col = new NdbColumnImpl;
353 354 355 356 357
  if (col ==  NULL)
  {
    errno = ENOMEM;
    return -1;
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
358
  (* col) = NdbColumnImpl::getImpl(c);
359 360 361 362 363 364 365 366 367
  if (m_impl.m_columns.push_back(col))
  {
    return -1;
  }
  if (m_impl.buildColumnHash())
  {
    return -1;
  }
  return 0;
368 369 370 371 372 373 374 375 376 377 378 379
}

const NdbDictionary::Column*
NdbDictionary::Table::getColumn(const char * name) const {
  return m_impl.getColumn(name);
}

const NdbDictionary::Column* 
NdbDictionary::Table::getColumn(const int attrId) const {
  return m_impl.getColumn(attrId);
}

joreland@mysql.com's avatar
joreland@mysql.com committed
380 381 382 383 384 385 386 387 388 389 390 391
NdbDictionary::Column*
NdbDictionary::Table::getColumn(const char * name) 
{
  return m_impl.getColumn(name);
}

NdbDictionary::Column* 
NdbDictionary::Table::getColumn(const int attrId)
{
  return m_impl.getColumn(attrId);
}

392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
void
NdbDictionary::Table::setLogging(bool val){
  m_impl.m_logging = val;
}

bool 
NdbDictionary::Table::getLogging() const {
  return m_impl.m_logging;
}

void
NdbDictionary::Table::setFragmentType(FragmentType ft){
  m_impl.m_fragmentType = ft;
}

NdbDictionary::Object::FragmentType 
NdbDictionary::Table::getFragmentType() const {
  return m_impl.m_fragmentType;
}

void 
NdbDictionary::Table::setKValue(int kValue){
  m_impl.m_kvalue = kValue;
}

int
NdbDictionary::Table::getKValue() const {
  return m_impl.m_kvalue;
}

void 
NdbDictionary::Table::setMinLoadFactor(int lf){
  m_impl.m_minLoadFactor = lf;
}

int 
NdbDictionary::Table::getMinLoadFactor() const {
  return m_impl.m_minLoadFactor;
}

void 
NdbDictionary::Table::setMaxLoadFactor(int lf){
  m_impl.m_maxLoadFactor = lf;  
}

int 
NdbDictionary::Table::getMaxLoadFactor() const {
  return m_impl.m_maxLoadFactor;
}

int
NdbDictionary::Table::getNoOfColumns() const {
  return m_impl.m_columns.size();
}

int
NdbDictionary::Table::getNoOfPrimaryKeys() const {
  return m_impl.m_noOfKeys;
}

452 453 454 455 456 457 458
void
NdbDictionary::Table::setMaxRows(Uint64 maxRows)
{
  m_impl.m_max_rows = maxRows;
}

Uint64
459
NdbDictionary::Table::getMaxRows() const
460 461 462 463
{
  return m_impl.m_max_rows;
}

464
void
465 466 467 468 469 470 471 472 473 474 475
NdbDictionary::Table::setMinRows(Uint64 minRows)
{
  m_impl.m_min_rows = minRows;
}

Uint64
NdbDictionary::Table::getMinRows() const
{
  return m_impl.m_min_rows;
}

476 477 478 479 480 481 482
void
NdbDictionary::Table::setDefaultNoPartitionsFlag(Uint32 flag)
{
  m_impl.m_default_no_part_flag = flag;;
}

Uint32
483
NdbDictionary::Table::getDefaultNoPartitionsFlag() const
484 485 486 487
{
  return m_impl.m_default_no_part_flag;
}

488 489 490 491 492 493 494 495 496 497 498 499 500 501
const char*
NdbDictionary::Table::getPrimaryKey(int no) const {
  int count = 0;
  for (unsigned i = 0; i < m_impl.m_columns.size(); i++) {
    if (m_impl.m_columns[i]->m_pk) {
      if (count++ == no)
        return m_impl.m_columns[i]->m_name.c_str();
    }
  }
  return 0;
}

const void* 
NdbDictionary::Table::getFrmData() const {
502
  return m_impl.getFrmData();
503 504 505 506
}

Uint32
NdbDictionary::Table::getFrmLength() const {
507
  return m_impl.getFrmLength();
508 509
}

510 511 512 513 514 515 516 517 518 519 520 521
enum NdbDictionary::Table::SingleUserMode
NdbDictionary::Table::getSingleUserMode() const
{
  return (enum SingleUserMode)m_impl.m_single_user_mode;
}

void
NdbDictionary::Table::setSingleUserMode(enum NdbDictionary::Table::SingleUserMode mode)
{
  m_impl.m_single_user_mode = (Uint8)mode;
}

522
int
523 524
NdbDictionary::Table::setTablespaceNames(const void *data, Uint32 len)
{
525
  return m_impl.setTablespaceNames(data, len);
526 527 528 529 530 531 532 533 534
}

const void*
NdbDictionary::Table::getTablespaceNames()
{
  return m_impl.getTablespaceNames();
}

Uint32
535
NdbDictionary::Table::getTablespaceNamesLen() const
536 537 538 539
{
  return m_impl.getTablespaceNamesLen();
}

540 541 542 543 544 545 546 547 548 549 550 551
void
NdbDictionary::Table::setLinearFlag(Uint32 flag)
{
  m_impl.m_linear_flag = flag;
}

bool
NdbDictionary::Table::getLinearFlag() const
{
  return m_impl.m_linear_flag;
}

552 553 554 555 556 557 558 559 560 561 562 563
void
NdbDictionary::Table::setFragmentCount(Uint32 count)
{
  m_impl.setFragmentCount(count);
}

Uint32
NdbDictionary::Table::getFragmentCount() const
{
  return m_impl.getFragmentCount();
}

564
int
565
NdbDictionary::Table::setFrm(const void* data, Uint32 len){
566
  return m_impl.setFrm(data, len);
567 568
}

569
const void* 
570 571 572 573 574 575 576 577 578
NdbDictionary::Table::getFragmentData() const {
  return m_impl.getFragmentData();
}

Uint32
NdbDictionary::Table::getFragmentDataLen() const {
  return m_impl.getFragmentDataLen();
}

579
int
580 581
NdbDictionary::Table::setFragmentData(const void* data, Uint32 len)
{
582
  return m_impl.setFragmentData(data, len);
583 584 585 586 587 588 589 590 591 592 593 594
}

const void* 
NdbDictionary::Table::getTablespaceData() const {
  return m_impl.getTablespaceData();
}

Uint32
NdbDictionary::Table::getTablespaceDataLen() const {
  return m_impl.getTablespaceDataLen();
}

595
int
596 597
NdbDictionary::Table::setTablespaceData(const void* data, Uint32 len)
{
598
  return m_impl.setTablespaceData(data, len);
599 600 601 602 603
}

const void* 
NdbDictionary::Table::getRangeListData() const {
  return m_impl.getRangeListData();
604 605 606
}

Uint32
607 608
NdbDictionary::Table::getRangeListDataLen() const {
  return m_impl.getRangeListDataLen();
609 610
}

611
int
612
NdbDictionary::Table::setRangeListData(const void* data, Uint32 len)
613
{
614
  return m_impl.setRangeListData(data, len);
615 616
}

617 618 619 620 621
NdbDictionary::Object::Status
NdbDictionary::Table::getObjectStatus() const {
  return m_impl.m_status;
}

622 623 624 625 626
void
NdbDictionary::Table::setStatusInvalid() const {
  m_impl.m_status = NdbDictionary::Object::Invalid;
}

627 628 629 630 631
int 
NdbDictionary::Table::getObjectVersion() const {
  return m_impl.m_version;
}

632 633 634 635 636
int 
NdbDictionary::Table::getObjectId() const {
  return m_impl.m_id;
}

637 638 639 640 641 642 643 644 645 646
bool
NdbDictionary::Table::equal(const NdbDictionary::Table & col) const {
  return m_impl.equal(col.m_impl);
}

int
NdbDictionary::Table::getRowSizeInBytes() const {  
  int sz = 0;
  for(int i = 0; i<getNoOfColumns(); i++){
    const NdbDictionary::Column * c = getColumn(i);
647
    sz += (c->getSizeInBytes()+ 3) / 4;
648 649 650 651
  }
  return sz * 4;
}

652 653 654 655 656
int
NdbDictionary::Table::getReplicaCount() const {  
  return m_impl.m_replicaCount;
}

knielsen@ymer.(none)'s avatar
knielsen@ymer.(none) committed
657 658 659 660 661 662 663 664 665 666
bool
NdbDictionary::Table::getTemporary() {
  return m_impl.m_temporary;
}

void
NdbDictionary::Table::setTemporary(bool val) {
  m_impl.m_temporary = val;
}

667 668 669 670 671 672 673 674 675 676 677
int
NdbDictionary::Table::createTableInDb(Ndb* pNdb, bool equalOk) const {  
  const NdbDictionary::Table * pTab = 
    pNdb->getDictionary()->getTable(getName());
  if(pTab != 0 && equal(* pTab))
    return 0;
  if(pTab != 0 && !equal(* pTab))
    return -1;
  return pNdb->getDictionary()->createTable(* this);
}

678 679
bool
NdbDictionary::Table::getTablespace(Uint32 *id, Uint32 *version) const 
680
{
681 682 683 684 685 686 687
  if (m_impl.m_tablespace_id == RNIL)
    return false;
  if (id)
    *id= m_impl.m_tablespace_id;
  if (version)
    *version= m_impl.m_version;
  return true;
688 689
}

690 691 692 693 694 695
const char *
NdbDictionary::Table::getTablespaceName() const 
{
  return m_impl.m_tablespace_name.c_str();
}

696
int
697
NdbDictionary::Table::setTablespaceName(const char * name){
698 699
  m_impl.m_tablespace_id = ~0;
  m_impl.m_tablespace_version = ~0;
700
  return !m_impl.m_tablespace_name.assign(name);
701 702
}

703
int
704 705 706
NdbDictionary::Table::setTablespace(const NdbDictionary::Tablespace & ts){
  m_impl.m_tablespace_id = NdbTablespaceImpl::getImpl(ts).m_id;
  m_impl.m_tablespace_version = ts.getObjectVersion();
707
  return !m_impl.m_tablespace_name.assign(ts.getName());
708 709
}

710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
void
NdbDictionary::Table::setRowChecksumIndicator(bool val){
  m_impl.m_row_checksum = val;
}

bool 
NdbDictionary::Table::getRowChecksumIndicator() const {
  return m_impl.m_row_checksum;
}

void
NdbDictionary::Table::setRowGCIIndicator(bool val){
  m_impl.m_row_gci = val;
}

bool 
NdbDictionary::Table::getRowGCIIndicator() const {
  return m_impl.m_row_gci;
}

730 731 732 733 734 735 736 737 738 739
void
NdbDictionary::Table::setForceVarPart(bool val){
  m_impl.m_force_var_part = val;
}

bool 
NdbDictionary::Table::getForceVarPart() const {
  return m_impl.m_force_var_part;
}

740 741 742 743 744 745 746 747 748 749 750 751
int
NdbDictionary::Table::aggregate(NdbError& error)
{
  return m_impl.aggregate(error);
}

int
NdbDictionary::Table::validate(NdbError& error)
{
  return m_impl.validate(error);
}

752

753 754 755
/*****************************************************************
 * Index facade
 */
756

757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774
NdbDictionary::Index::Index(const char * name)
  : m_impl(* new NdbIndexImpl(* this))
{
  setName(name);
}

NdbDictionary::Index::Index(NdbIndexImpl & impl)
  : m_impl(impl) 
{
}

NdbDictionary::Index::~Index(){
  NdbIndexImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

775
int
776
NdbDictionary::Index::setName(const char * name){
777
  return m_impl.setName(name);
778 779 780 781 782 783 784
}

const char * 
NdbDictionary::Index::getName() const {
  return m_impl.getName();
}

785
int
786
NdbDictionary::Index::setTable(const char * table){
787
  return m_impl.setTable(table);
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821
}

const char * 
NdbDictionary::Index::getTable() const {
  return m_impl.getTable();
}

unsigned
NdbDictionary::Index::getNoOfColumns() const {
  return m_impl.m_columns.size();
}

int
NdbDictionary::Index::getNoOfIndexColumns() const {
  return m_impl.m_columns.size();
}

const NdbDictionary::Column *
NdbDictionary::Index::getColumn(unsigned no) const {
  if(no < m_impl.m_columns.size())
    return m_impl.m_columns[no];
  return NULL;
}

const char *
NdbDictionary::Index::getIndexColumn(int no) const {
  const NdbDictionary::Column* col = getColumn(no);

  if (col)
    return col->getName();
  else
    return NULL;
}

822
int
823 824
NdbDictionary::Index::addColumn(const Column & c){
  NdbColumnImpl* col = new NdbColumnImpl;
825 826 827 828 829
  if (col == NULL)
  {
    errno = ENOMEM;
    return -1;
  }
joreland@mysql.com's avatar
joreland@mysql.com committed
830
  (* col) = NdbColumnImpl::getImpl(c);
831 832 833 834 835
  if (m_impl.m_columns.push_back(col))
  {
    return -1;
  }
  return 0;
836 837
}

838
int
839 840
NdbDictionary::Index::addColumnName(const char * name){
  const Column c(name);
841
  return addColumn(c);
842 843
}

844
int
845 846
NdbDictionary::Index::addIndexColumn(const char * name){
  const Column c(name);
847
  return addColumn(c);
848 849
}

850
int
851 852 853
NdbDictionary::Index::addColumnNames(unsigned noOfNames, const char ** names){
  for(unsigned i = 0; i < noOfNames; i++) {
    const Column c(names[i]);
854 855 856 857
    if (addColumn(c))
    {
      return -1;
    }
858
  }
859
  return 0;
860 861
}

862
int
863 864 865
NdbDictionary::Index::addIndexColumns(int noOfNames, const char ** names){
  for(int i = 0; i < noOfNames; i++) {
    const Column c(names[i]);
866 867 868 869
    if (addColumn(c))
    {
      return -1;
    }
870
  }
871
  return 0;
872 873 874 875
}

void
NdbDictionary::Index::setType(NdbDictionary::Index::Type t){
876
  m_impl.m_type = (NdbDictionary::Object::Type)t;
877 878 879 880
}

NdbDictionary::Index::Type
NdbDictionary::Index::getType() const {
881
  return (NdbDictionary::Index::Type)m_impl.m_type;
882 883 884 885 886 887 888
}

void
NdbDictionary::Index::setLogging(bool val){
  m_impl.m_logging = val;
}

knielsen@ymer.(none)'s avatar
knielsen@ymer.(none) committed
889 890 891 892 893 894 895 896 897 898
bool
NdbDictionary::Index::getTemporary(){
  return m_impl.m_temporary;
}

void
NdbDictionary::Index::setTemporary(bool val){
  m_impl.m_temporary = val;
}

899 900 901 902 903 904 905
bool 
NdbDictionary::Index::getLogging() const {
  return m_impl.m_logging;
}

NdbDictionary::Object::Status
NdbDictionary::Index::getObjectStatus() const {
906
  return m_impl.m_table->m_status;
907 908 909 910
}

int 
NdbDictionary::Index::getObjectVersion() const {
911
  return m_impl.m_table->m_version;
912 913
}

914 915
int 
NdbDictionary::Index::getObjectId() const {
916
  return m_impl.m_table->m_id;
917 918 919
}


920 921 922 923 924 925 926 927 928
/*****************************************************************
 * Event facade
 */
NdbDictionary::Event::Event(const char * name)
  : m_impl(* new NdbEventImpl(* this))
{
  setName(name);
}

929 930 931 932 933 934 935
NdbDictionary::Event::Event(const char * name, const Table& table)
  : m_impl(* new NdbEventImpl(* this))
{
  setName(name);
  setTable(table);
}

936 937 938 939 940 941 942 943 944 945 946 947 948
NdbDictionary::Event::Event(NdbEventImpl & impl)
  : m_impl(impl) 
{
}

NdbDictionary::Event::~Event()
{
  NdbEventImpl * tmp = &m_impl;
  if(this != tmp){
    delete tmp;
  }
}

949
int
950 951
NdbDictionary::Event::setName(const char * name)
{
952
  return m_impl.setName(name);
953 954
}

955 956 957 958 959 960
const char *
NdbDictionary::Event::getName() const
{
  return m_impl.getName();
}

961 962 963 964 965 966
void 
NdbDictionary::Event::setTable(const Table& table)
{
  m_impl.setTable(table);
}

967 968 969 970 971 972
const NdbDictionary::Table *
NdbDictionary::Event::getTable() const
{
  return m_impl.getTable();
}

973
int
974 975
NdbDictionary::Event::setTable(const char * table)
{
976
  return m_impl.setTable(table);
977 978
}

979 980 981 982 983 984
const char*
NdbDictionary::Event::getTableName() const
{
  return m_impl.getTableName();
}

985 986 987 988 989 990
void
NdbDictionary::Event::addTableEvent(const TableEvent t)
{
  m_impl.addTableEvent(t);
}

991 992 993 994 995 996
bool
NdbDictionary::Event::getTableEvent(const TableEvent t) const
{
  return m_impl.getTableEvent(t);
}

997
void
998
NdbDictionary::Event::setDurability(EventDurability d)
999 1000 1001 1002
{
  m_impl.setDurability(d);
}

1003 1004 1005 1006 1007 1008
NdbDictionary::Event::EventDurability
NdbDictionary::Event::getDurability() const
{
  return m_impl.getDurability();
}

tomas@poseidon.ndb.mysql.com's avatar
tomas@poseidon.ndb.mysql.com committed
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020
void
NdbDictionary::Event::setReport(EventReport r)
{
  m_impl.setReport(r);
}

NdbDictionary::Event::EventReport
NdbDictionary::Event::getReport() const
{
  return m_impl.getReport();
}

1021 1022 1023
void
NdbDictionary::Event::addColumn(const Column & c){
  NdbColumnImpl* col = new NdbColumnImpl;
joreland@mysql.com's avatar
joreland@mysql.com committed
1024
  (* col) = NdbColumnImpl::getImpl(c);
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
  m_impl.m_columns.push_back(col);
}

void
NdbDictionary::Event::addEventColumn(unsigned attrId)
{
  m_impl.m_attrIds.push_back(attrId);
}

void
NdbDictionary::Event::addEventColumn(const char * name)
{
  const Column c(name);
  addColumn(c);
}

void
NdbDictionary::Event::addEventColumns(int n, const char ** names)
{
  for (int i = 0; i < n; i++)
    addEventColumn(names[i]);
}

1048 1049 1050 1051 1052
int NdbDictionary::Event::getNoOfEventColumns() const
{
  return m_impl.getNoOfEventColumns();
}

1053 1054 1055
const NdbDictionary::Column *
NdbDictionary::Event::getEventColumn(unsigned no) const
{
1056
  return m_impl.getEventColumn(no);
1057 1058
}

1059 1060 1061 1062 1063
void NdbDictionary::Event::mergeEvents(bool flag)
{
  m_impl.m_mergeEvents = flag;
}

1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075
NdbDictionary::Object::Status
NdbDictionary::Event::getObjectStatus() const
{
  return m_impl.m_status;
}

int 
NdbDictionary::Event::getObjectVersion() const
{
  return m_impl.m_version;
}

1076 1077 1078 1079 1080
int 
NdbDictionary::Event::getObjectId() const {
  return m_impl.m_id;
}

1081 1082 1083 1084 1085
void NdbDictionary::Event::print()
{
  m_impl.print();
}

1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
/*****************************************************************
 * Tablespace facade
 */
NdbDictionary::Tablespace::Tablespace()
  : m_impl(* new NdbTablespaceImpl(* this))
{
}

NdbDictionary::Tablespace::Tablespace(NdbTablespaceImpl & impl)
  : m_impl(impl) 
{
}

1099 1100 1101 1102 1103 1104
NdbDictionary::Tablespace::Tablespace(const NdbDictionary::Tablespace & org)
  : Object(org), m_impl(* new NdbTablespaceImpl(* this))
{
  m_impl.assign(org.m_impl);
}

1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
NdbDictionary::Tablespace::~Tablespace(){
  NdbTablespaceImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

void 
NdbDictionary::Tablespace::setName(const char * name){
  m_impl.m_name.assign(name);
}

const char * 
NdbDictionary::Tablespace::getName() const {
  return m_impl.m_name.c_str();
}

void
NdbDictionary::Tablespace::setAutoGrowSpecification
(const NdbDictionary::AutoGrowSpecification& spec){
  m_impl.m_grow_spec = spec;
}
const NdbDictionary::AutoGrowSpecification& 
NdbDictionary::Tablespace::getAutoGrowSpecification() const {
  return m_impl.m_grow_spec;
}

void
NdbDictionary::Tablespace::setExtentSize(Uint32 sz){
  m_impl.m_extent_size = sz;
}

Uint32
NdbDictionary::Tablespace::getExtentSize() const {
  return m_impl.m_extent_size;
}

void
NdbDictionary::Tablespace::setDefaultLogfileGroup(const char * name){
  m_impl.m_logfile_group_id = ~0;
  m_impl.m_logfile_group_version = ~0;
  m_impl.m_logfile_group_name.assign(name);
}

void
NdbDictionary::Tablespace::setDefaultLogfileGroup
(const NdbDictionary::LogfileGroup & lg){
  m_impl.m_logfile_group_id = NdbLogfileGroupImpl::getImpl(lg).m_id;
  m_impl.m_logfile_group_version = lg.getObjectVersion();
  m_impl.m_logfile_group_name.assign(lg.getName());
}

const char * 
NdbDictionary::Tablespace::getDefaultLogfileGroup() const {
  return m_impl.m_logfile_group_name.c_str();
}

1162 1163 1164 1165 1166
Uint32
NdbDictionary::Tablespace::getDefaultLogfileGroupId() const {
  return m_impl.m_logfile_group_id;
}

1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
NdbDictionary::Object::Status
NdbDictionary::Tablespace::getObjectStatus() const {
  return m_impl.m_status;
}

int 
NdbDictionary::Tablespace::getObjectVersion() const {
  return m_impl.m_version;
}

1177 1178 1179 1180 1181
int 
NdbDictionary::Tablespace::getObjectId() const {
  return m_impl.m_id;
}

1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194
/*****************************************************************
 * LogfileGroup facade
 */
NdbDictionary::LogfileGroup::LogfileGroup()
  : m_impl(* new NdbLogfileGroupImpl(* this))
{
}

NdbDictionary::LogfileGroup::LogfileGroup(NdbLogfileGroupImpl & impl)
  : m_impl(impl) 
{
}

1195 1196 1197 1198 1199 1200
NdbDictionary::LogfileGroup::LogfileGroup(const NdbDictionary::LogfileGroup & org)
  : Object(org), m_impl(* new NdbLogfileGroupImpl(* this)) 
{
  m_impl.assign(org.m_impl);
}

1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237
NdbDictionary::LogfileGroup::~LogfileGroup(){
  NdbLogfileGroupImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

void 
NdbDictionary::LogfileGroup::setName(const char * name){
  m_impl.m_name.assign(name);
}

const char * 
NdbDictionary::LogfileGroup::getName() const {
  return m_impl.m_name.c_str();
}

void
NdbDictionary::LogfileGroup::setUndoBufferSize(Uint32 sz){
  m_impl.m_undo_buffer_size = sz;
}

Uint32
NdbDictionary::LogfileGroup::getUndoBufferSize() const {
  return m_impl.m_undo_buffer_size;
}

void
NdbDictionary::LogfileGroup::setAutoGrowSpecification
(const NdbDictionary::AutoGrowSpecification& spec){
  m_impl.m_grow_spec = spec;
}
const NdbDictionary::AutoGrowSpecification& 
NdbDictionary::LogfileGroup::getAutoGrowSpecification() const {
  return m_impl.m_grow_spec;
}

1238 1239 1240 1241
Uint64 NdbDictionary::LogfileGroup::getUndoFreeWords() const {
  return m_impl.m_undo_free_words;
}

1242 1243 1244 1245 1246 1247 1248 1249 1250 1251
NdbDictionary::Object::Status
NdbDictionary::LogfileGroup::getObjectStatus() const {
  return m_impl.m_status;
}

int 
NdbDictionary::LogfileGroup::getObjectVersion() const {
  return m_impl.m_version;
}

1252 1253 1254 1255 1256
int 
NdbDictionary::LogfileGroup::getObjectId() const {
  return m_impl.m_id;
}

1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269
/*****************************************************************
 * Datafile facade
 */
NdbDictionary::Datafile::Datafile()
  : m_impl(* new NdbDatafileImpl(* this))
{
}

NdbDictionary::Datafile::Datafile(NdbDatafileImpl & impl)
  : m_impl(impl) 
{
}

1270 1271 1272 1273 1274 1275
NdbDictionary::Datafile::Datafile(const NdbDictionary::Datafile & org)
  : Object(org), m_impl(* new NdbDatafileImpl(* this)) 
{
  m_impl.assign(org.m_impl);
}

1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
NdbDictionary::Datafile::~Datafile(){
  NdbDatafileImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

void 
NdbDictionary::Datafile::setPath(const char * path){
  m_impl.m_path.assign(path);
}

const char * 
NdbDictionary::Datafile::getPath() const {
  return m_impl.m_path.c_str();
}

void 
NdbDictionary::Datafile::setSize(Uint64 sz){
  m_impl.m_size = sz;
}

Uint64
NdbDictionary::Datafile::getSize() const {
  return m_impl.m_size;
}

Uint64
NdbDictionary::Datafile::getFree() const {
  return m_impl.m_free;
}

1308
int
1309 1310 1311
NdbDictionary::Datafile::setTablespace(const char * tablespace){
  m_impl.m_filegroup_id = ~0;
  m_impl.m_filegroup_version = ~0;
1312
  return !m_impl.m_filegroup_name.assign(tablespace);
1313 1314
}

1315
int
1316 1317 1318
NdbDictionary::Datafile::setTablespace(const NdbDictionary::Tablespace & ts){
  m_impl.m_filegroup_id = NdbTablespaceImpl::getImpl(ts).m_id;
  m_impl.m_filegroup_version = ts.getObjectVersion();
1319
  return !m_impl.m_filegroup_name.assign(ts.getName());
1320 1321 1322 1323 1324 1325 1326
}

const char *
NdbDictionary::Datafile::getTablespace() const {
  return m_impl.m_filegroup_name.c_str();
}

jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1327 1328 1329 1330 1331 1332 1333 1334
void
NdbDictionary::Datafile::getTablespaceId(NdbDictionary::ObjectId* dst) const 
{
  if (dst)
  {
    NdbDictObjectImpl::getImpl(* dst).m_id = m_impl.m_filegroup_id;
    NdbDictObjectImpl::getImpl(* dst).m_version = m_impl.m_filegroup_version;
  }
1335 1336
}

1337 1338 1339 1340 1341 1342 1343 1344 1345 1346
NdbDictionary::Object::Status
NdbDictionary::Datafile::getObjectStatus() const {
  return m_impl.m_status;
}

int 
NdbDictionary::Datafile::getObjectVersion() const {
  return m_impl.m_version;
}

1347 1348 1349 1350 1351
int 
NdbDictionary::Datafile::getObjectId() const {
  return m_impl.m_id;
}

1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
/*****************************************************************
 * Undofile facade
 */
NdbDictionary::Undofile::Undofile()
  : m_impl(* new NdbUndofileImpl(* this))
{
}

NdbDictionary::Undofile::Undofile(NdbUndofileImpl & impl)
  : m_impl(impl) 
{
}

1365 1366 1367 1368 1369 1370
NdbDictionary::Undofile::Undofile(const NdbDictionary::Undofile & org)
  : Object(org), m_impl(* new NdbUndofileImpl(* this))
{
  m_impl.assign(org.m_impl);
}

1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417
NdbDictionary::Undofile::~Undofile(){
  NdbUndofileImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

void 
NdbDictionary::Undofile::setPath(const char * path){
  m_impl.m_path.assign(path);
}

const char * 
NdbDictionary::Undofile::getPath() const {
  return m_impl.m_path.c_str();
}

void 
NdbDictionary::Undofile::setSize(Uint64 sz){
  m_impl.m_size = sz;
}

Uint64
NdbDictionary::Undofile::getSize() const {
  return m_impl.m_size;
}

void 
NdbDictionary::Undofile::setLogfileGroup(const char * logfileGroup){
  m_impl.m_filegroup_id = ~0;
  m_impl.m_filegroup_version = ~0;
  m_impl.m_filegroup_name.assign(logfileGroup);
}

void 
NdbDictionary::Undofile::setLogfileGroup
(const NdbDictionary::LogfileGroup & ts){
  m_impl.m_filegroup_id = NdbLogfileGroupImpl::getImpl(ts).m_id;
  m_impl.m_filegroup_version = ts.getObjectVersion();
  m_impl.m_filegroup_name.assign(ts.getName());
}

const char *
NdbDictionary::Undofile::getLogfileGroup() const {
  return m_impl.m_filegroup_name.c_str();
}

jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1418 1419 1420 1421 1422 1423 1424 1425
void
NdbDictionary::Undofile::getLogfileGroupId(NdbDictionary::ObjectId * dst)const 
{
  if (dst)
  {
    NdbDictObjectImpl::getImpl(* dst).m_id = m_impl.m_filegroup_id;
    NdbDictObjectImpl::getImpl(* dst).m_version = m_impl.m_filegroup_version;
  }
1426 1427
}

1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
NdbDictionary::Object::Status
NdbDictionary::Undofile::getObjectStatus() const {
  return m_impl.m_status;
}

int 
NdbDictionary::Undofile::getObjectVersion() const {
  return m_impl.m_version;
}

1438 1439 1440 1441 1442
int 
NdbDictionary::Undofile::getObjectId() const {
  return m_impl.m_id;
}

1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462
/*****************************************************************
 * Dictionary facade
 */
NdbDictionary::Dictionary::Dictionary(Ndb & ndb)
  : m_impl(* new NdbDictionaryImpl(ndb, *this))
{
}

NdbDictionary::Dictionary::Dictionary(NdbDictionaryImpl & impl)
  : m_impl(impl) 
{
}
NdbDictionary::Dictionary::~Dictionary(){
  NdbDictionaryImpl * tmp = &m_impl;  
  if(this != tmp){
    delete tmp;
  }
}

int 
1463 1464 1465 1466
NdbDictionary::Dictionary::createTable(const Table & t)
{
  DBUG_ENTER("NdbDictionary::Dictionary::createTable");
  DBUG_RETURN(m_impl.createTable(NdbTableImpl::getImpl(t)));
1467 1468 1469 1470 1471 1472 1473
}

int
NdbDictionary::Dictionary::dropTable(Table & t){
  return m_impl.dropTable(NdbTableImpl::getImpl(t));
}

1474 1475 1476 1477 1478
int
NdbDictionary::Dictionary::dropTableGlobal(const Table & t){
  return m_impl.dropTableGlobal(NdbTableImpl::getImpl(t));
}

1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
int
NdbDictionary::Dictionary::dropTable(const char * name){
  return m_impl.dropTable(name);
}

int
NdbDictionary::Dictionary::alterTable(const Table & t){
  return m_impl.alterTable(NdbTableImpl::getImpl(t));
}

1489 1490 1491 1492 1493 1494 1495 1496
int
NdbDictionary::Dictionary::alterTableGlobal(const Table & f,
                                            const Table & t)
{
  return m_impl.alterTableGlobal(NdbTableImpl::getImpl(f),
                                 NdbTableImpl::getImpl(t));
}

1497
const NdbDictionary::Table * 
1498 1499
NdbDictionary::Dictionary::getTable(const char * name, void **data) const
{
1500
  NdbTableImpl * t = m_impl.getTable(name, data);
1501 1502 1503 1504 1505
  if(t)
    return t->m_facade;
  return 0;
}

1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539
const NdbDictionary::Index * 
NdbDictionary::Dictionary::getIndexGlobal(const char * indexName,
                                          const Table &ndbtab) const
{
  NdbIndexImpl * i = m_impl.getIndexGlobal(indexName,
                                           NdbTableImpl::getImpl(ndbtab));
  if(i)
    return i->m_facade;
  return 0;
}

const NdbDictionary::Table * 
NdbDictionary::Dictionary::getTableGlobal(const char * name) const
{
  NdbTableImpl * t = m_impl.getTableGlobal(name);
  if(t)
    return t->m_facade;
  return 0;
}

int
NdbDictionary::Dictionary::removeIndexGlobal(const Index &ndbidx,
                                             int invalidate) const
{
  return m_impl.releaseIndexGlobal(NdbIndexImpl::getImpl(ndbidx), invalidate);
}

int
NdbDictionary::Dictionary::removeTableGlobal(const Table &ndbtab,
                                             int invalidate) const
{
  return m_impl.releaseTableGlobal(NdbTableImpl::getImpl(ndbtab), invalidate);
}

1540 1541 1542 1543 1544 1545 1546
void NdbDictionary::Dictionary::putTable(const NdbDictionary::Table * table)
{
 NdbDictionary::Table  *copy_table = new NdbDictionary::Table;
  *copy_table = *table;
  m_impl.putTable(&NdbTableImpl::getImpl(*copy_table));
}

1547 1548 1549 1550 1551
void NdbDictionary::Dictionary::set_local_table_data_size(unsigned sz)
{
  m_impl.m_local_table_data_size= sz;
}

1552
const NdbDictionary::Table * 
1553 1554
NdbDictionary::Dictionary::getTable(const char * name) const
{
1555 1556 1557
  return getTable(name, 0);
}

1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
const NdbDictionary::Table *
NdbDictionary::Dictionary::getBlobTable(const NdbDictionary::Table* table,
                                        const char* col_name)
{
  const NdbDictionary::Column* col = table->getColumn(col_name);
  if (col == NULL) {
    m_impl.m_error.code = 4318;
    return NULL;
  }
  return getBlobTable(table, col->getColumnNo());
}

const NdbDictionary::Table *
NdbDictionary::Dictionary::getBlobTable(const NdbDictionary::Table* table,
                                        Uint32 col_no)
{
  return m_impl.getBlobTable(NdbTableImpl::getImpl(*table), col_no);
}

1577 1578
void
NdbDictionary::Dictionary::invalidateTable(const char * name){
1579
  DBUG_ENTER("NdbDictionaryImpl::invalidateTable");
1580 1581 1582
  NdbTableImpl * t = m_impl.getTable(name);
  if(t)
    m_impl.invalidateObject(* t);
1583
  DBUG_VOID_RETURN;
1584 1585
}

1586 1587 1588 1589 1590 1591
void
NdbDictionary::Dictionary::invalidateTable(const Table *table){
  NdbTableImpl &t = NdbTableImpl::getImpl(*table);
  m_impl.invalidateObject(t);
}

1592 1593 1594 1595 1596 1597 1598
void
NdbDictionary::Dictionary::removeCachedTable(const char * name){
  NdbTableImpl * t = m_impl.getTable(name);
  if(t)
    m_impl.removeCachedObject(* t);
}

1599 1600 1601 1602 1603 1604
void
NdbDictionary::Dictionary::removeCachedTable(const Table *table){
  NdbTableImpl &t = NdbTableImpl::getImpl(*table);
  m_impl.removeCachedObject(t);
}

1605 1606 1607 1608 1609 1610
int
NdbDictionary::Dictionary::createIndex(const Index & ind)
{
  return m_impl.createIndex(NdbIndexImpl::getImpl(ind));
}

1611 1612 1613 1614 1615 1616 1617
int
NdbDictionary::Dictionary::createIndex(const Index & ind, const Table & tab)
{
  return m_impl.createIndex(NdbIndexImpl::getImpl(ind),
                            NdbTableImpl::getImpl(tab));
}

1618 1619 1620 1621 1622 1623 1624
int 
NdbDictionary::Dictionary::dropIndex(const char * indexName,
				     const char * tableName)
{
  return m_impl.dropIndex(indexName, tableName);
}

1625 1626 1627 1628 1629 1630
int 
NdbDictionary::Dictionary::dropIndexGlobal(const Index &ind)
{
  return m_impl.dropIndexGlobal(NdbIndexImpl::getImpl(ind));
}

1631 1632
const NdbDictionary::Index * 
NdbDictionary::Dictionary::getIndex(const char * indexName,
1633
				    const char * tableName) const
1634 1635 1636 1637 1638 1639 1640
{
  NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
  if(i)
    return i->m_facade;
  return 0;
}

1641 1642 1643 1644 1645 1646 1647 1648 1649
void
NdbDictionary::Dictionary::invalidateIndex(const Index *index){
  DBUG_ENTER("NdbDictionary::Dictionary::invalidateIndex");
  NdbIndexImpl &i = NdbIndexImpl::getImpl(*index);
  assert(i.m_table != 0);
  m_impl.invalidateObject(* i.m_table);
  DBUG_VOID_RETURN;
}

1650 1651 1652
void
NdbDictionary::Dictionary::invalidateIndex(const char * indexName,
                                           const char * tableName){
1653
  DBUG_ENTER("NdbDictionaryImpl::invalidateIndex");
1654 1655 1656 1657 1658
  NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
  if(i) {
    assert(i->m_table != 0);
    m_impl.invalidateObject(* i->m_table);
  }
1659
  DBUG_VOID_RETURN;
1660 1661
}

1662 1663 1664 1665 1666 1667
int
NdbDictionary::Dictionary::forceGCPWait()
{
  return m_impl.forceGCPWait();
}

1668 1669 1670 1671 1672 1673 1674 1675 1676
void
NdbDictionary::Dictionary::removeCachedIndex(const Index *index){
  DBUG_ENTER("NdbDictionary::Dictionary::removeCachedIndex");
  NdbIndexImpl &i = NdbIndexImpl::getImpl(*index);
  assert(i.m_table != 0);
  m_impl.removeCachedObject(* i.m_table);
  DBUG_VOID_RETURN;
}

1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688
void
NdbDictionary::Dictionary::removeCachedIndex(const char * indexName,
					     const char * tableName){
  NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
  if(i) {
    assert(i->m_table != 0);
    m_impl.removeCachedObject(* i->m_table);
  }
}

const NdbDictionary::Table *
NdbDictionary::Dictionary::getIndexTable(const char * indexName, 
1689
					 const char * tableName) const
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727
{
  NdbIndexImpl * i = m_impl.getIndex(indexName, tableName);
  NdbTableImpl * t = m_impl.getTable(tableName);
  if(i && t) {
    NdbTableImpl * it = m_impl.getIndexTable(i, t);
    return it->m_facade;
  }
  return 0;
}


int
NdbDictionary::Dictionary::createEvent(const Event & ev)
{
  return m_impl.createEvent(NdbEventImpl::getImpl(ev));
}

int 
NdbDictionary::Dictionary::dropEvent(const char * eventName)
{
  return m_impl.dropEvent(eventName);
}

const NdbDictionary::Event *
NdbDictionary::Dictionary::getEvent(const char * eventName)
{
  NdbEventImpl * t = m_impl.getEvent(eventName);
  if(t)
    return t->m_facade;
  return 0;
}

int
NdbDictionary::Dictionary::listObjects(List& list, Object::Type type)
{
  return m_impl.listObjects(list, type);
}

1728
int
1729
NdbDictionary::Dictionary::listObjects(List& list, Object::Type type) const
1730
{
1731
  return m_impl.listObjects(list, type);
1732 1733
}

1734 1735 1736
int
NdbDictionary::Dictionary::listIndexes(List& list, const char * tableName)
{
joreland@mysql.com's avatar
joreland@mysql.com committed
1737 1738 1739 1740 1741 1742
  const NdbDictionary::Table* tab= getTable(tableName);
  if(tab == 0)
  {
    return -1;
  }
  return m_impl.listIndexes(list, tab->getTableId());
1743 1744
}

1745
int
1746
NdbDictionary::Dictionary::listIndexes(List& list,
1747 1748
				       const char * tableName) const
{
1749 1750 1751 1752 1753 1754
  const NdbDictionary::Table* tab= getTable(tableName);
  if(tab == 0)
  {
    return -1;
  }
  return m_impl.listIndexes(list, tab->getTableId());
1755 1756
}

1757 1758 1759 1760 1761 1762 1763 1764
int
NdbDictionary::Dictionary::listIndexes(List& list,
				       const NdbDictionary::Table &table) const
{
  return m_impl.listIndexes(list, table.getTableId());
}


1765 1766 1767 1768
const struct NdbError & 
NdbDictionary::Dictionary::getNdbError() const {
  return m_impl.getNdbError();
}
1769

pekka@mysql.com's avatar
pekka@mysql.com committed
1770 1771 1772 1773
// printers

NdbOut&
operator<<(NdbOut& out, const NdbDictionary::Column& col)
1774
{
pekka@mysql.com's avatar
pekka@mysql.com committed
1775 1776
  const CHARSET_INFO *cs = col.getCharset();
  const char *csname = cs ? cs->name : "?";
pekka@mysql.com's avatar
pekka@mysql.com committed
1777 1778 1779 1780
  out << col.getName() << " ";
  switch (col.getType()) {
  case NdbDictionary::Column::Tinyint:
    out << "Tinyint";
1781
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1782 1783 1784 1785 1786
  case NdbDictionary::Column::Tinyunsigned:
    out << "Tinyunsigned";
    break;
  case NdbDictionary::Column::Smallint:
    out << "Smallint";
1787 1788
    break;
  case NdbDictionary::Column::Smallunsigned:
pekka@mysql.com's avatar
pekka@mysql.com committed
1789
    out << "Smallunsigned";
1790
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1791 1792
  case NdbDictionary::Column::Mediumint:
    out << "Mediumint";
1793
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1794 1795
  case NdbDictionary::Column::Mediumunsigned:
    out << "Mediumunsigned";
1796 1797
    break;
  case NdbDictionary::Column::Int:
pekka@mysql.com's avatar
pekka@mysql.com committed
1798
    out << "Int";
1799
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1800 1801
  case NdbDictionary::Column::Unsigned:
    out << "Unsigned";
1802
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1803 1804
  case NdbDictionary::Column::Bigint:
    out << "Bigint";
1805
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1806 1807
  case NdbDictionary::Column::Bigunsigned:
    out << "Bigunsigned";
1808 1809
    break;
  case NdbDictionary::Column::Float:
pekka@mysql.com's avatar
pekka@mysql.com committed
1810
    out << "Float";
1811 1812
    break;
  case NdbDictionary::Column::Double:
pekka@mysql.com's avatar
pekka@mysql.com committed
1813
    out << "Double";
1814
    break;
1815 1816 1817 1818 1819
  case NdbDictionary::Column::Olddecimal:
    out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")";
    break;
  case NdbDictionary::Column::Olddecimalunsigned:
    out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")";
1820
    break;
1821 1822 1823 1824 1825 1826
  case NdbDictionary::Column::Decimal:
    out << "Decimal(" << col.getPrecision() << "," << col.getScale() << ")";
    break;
  case NdbDictionary::Column::Decimalunsigned:
    out << "Decimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")";
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1827
  case NdbDictionary::Column::Char:
pekka@mysql.com's avatar
pekka@mysql.com committed
1828
    out << "Char(" << col.getLength() << ";" << csname << ")";
pekka@mysql.com's avatar
pekka@mysql.com committed
1829 1830
    break;
  case NdbDictionary::Column::Varchar:
pekka@mysql.com's avatar
pekka@mysql.com committed
1831
    out << "Varchar(" << col.getLength() << ";" << csname << ")";
1832 1833
    break;
  case NdbDictionary::Column::Binary:
pekka@mysql.com's avatar
pekka@mysql.com committed
1834
    out << "Binary(" << col.getLength() << ")";
1835 1836
    break;
  case NdbDictionary::Column::Varbinary:
pekka@mysql.com's avatar
pekka@mysql.com committed
1837
    out << "Varbinary(" << col.getLength() << ")";
1838
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1839 1840
  case NdbDictionary::Column::Datetime:
    out << "Datetime";
1841
    break;
1842 1843
  case NdbDictionary::Column::Date:
    out << "Date";
1844 1845
    break;
  case NdbDictionary::Column::Blob:
pekka@mysql.com's avatar
pekka@mysql.com committed
1846 1847 1848 1849 1850
    out << "Blob(" << col.getInlineSize() << "," << col.getPartSize()
        << ";" << col.getStripeSize() << ")";
    break;
  case NdbDictionary::Column::Text:
    out << "Text(" << col.getInlineSize() << "," << col.getPartSize()
pekka@mysql.com's avatar
pekka@mysql.com committed
1851
        << ";" << col.getStripeSize() << ";" << csname << ")";
1852
    break;
1853 1854 1855
  case NdbDictionary::Column::Time:
    out << "Time";
    break;
1856 1857 1858 1859 1860 1861
  case NdbDictionary::Column::Year:
    out << "Year";
    break;
  case NdbDictionary::Column::Timestamp:
    out << "Timestamp";
    break;
1862
  case NdbDictionary::Column::Undefined:
pekka@mysql.com's avatar
pekka@mysql.com committed
1863
    out << "Undefined";
1864
    break;
1865 1866 1867
  case NdbDictionary::Column::Bit:
    out << "Bit(" << col.getLength() << ")";
    break;
pekka@mysql.com's avatar
pekka@mysql.com committed
1868 1869 1870 1871 1872 1873
  case NdbDictionary::Column::Longvarchar:
    out << "Longvarchar(" << col.getLength() << ";" << csname << ")";
    break;
  case NdbDictionary::Column::Longvarbinary:
    out << "Longvarbinary(" << col.getLength() << ")";
    break;
1874
  default:
pekka@mysql.com's avatar
pekka@mysql.com committed
1875
    out << "Type" << (Uint32)col.getType();
1876 1877
    break;
  }
1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895
  // show unusual (non-MySQL) array size
  if (col.getLength() != 1) {
    switch (col.getType()) {
    case NdbDictionary::Column::Char:
    case NdbDictionary::Column::Varchar:
    case NdbDictionary::Column::Binary:
    case NdbDictionary::Column::Varbinary:
    case NdbDictionary::Column::Blob:
    case NdbDictionary::Column::Text:
    case NdbDictionary::Column::Bit:
    case NdbDictionary::Column::Longvarchar:
    case NdbDictionary::Column::Longvarbinary:
      break;
    default:
      out << " [" << col.getLength() << "]";
      break;
    }
  }
1896

pekka@mysql.com's avatar
pekka@mysql.com committed
1897 1898 1899 1900 1901 1902
  if (col.getPrimaryKey())
    out << " PRIMARY KEY";
  else if (! col.getNullable())
    out << " NOT NULL";
  else
    out << " NULL";
1903

1904
  if(col.getDistributionKey())
1905
    out << " DISTRIBUTION KEY";
joreland@mysql.com's avatar
merge  
joreland@mysql.com committed
1906

1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917
  switch (col.getArrayType()) {
  case NDB_ARRAYTYPE_FIXED:
    out << " AT=FIXED";
    break;
  case NDB_ARRAYTYPE_SHORT_VAR:
    out << " AT=SHORT_VAR";
    break;
  case NDB_ARRAYTYPE_MEDIUM_VAR:
    out << " AT=MEDIUM_VAR";
    break;
  default:
1918
    out << " AT=" << (int)col.getArrayType() << "?";
1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929
    break;
  }

  switch (col.getStorageType()) {
  case NDB_STORAGETYPE_MEMORY:
    out << " ST=MEMORY";
    break;
  case NDB_STORAGETYPE_DISK:
    out << " ST=DISK";
    break;
  default:
1930
    out << " ST=" << (int)col.getStorageType() << "?";
1931 1932 1933
    break;
  }

pekka@mysql.com's avatar
pekka@mysql.com committed
1934
  return out;
1935
}
joreland@mysql.com's avatar
joreland@mysql.com committed
1936

1937
int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1938 1939 1940 1941
NdbDictionary::Dictionary::createLogfileGroup(const LogfileGroup & lg,
					      ObjectId * obj)
{
  return m_impl.createLogfileGroup(NdbLogfileGroupImpl::getImpl(lg),
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1942 1943
				   obj ? 
				   & NdbDictObjectImpl::getImpl(* obj) : 0);
1944 1945 1946
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1947 1948
NdbDictionary::Dictionary::dropLogfileGroup(const LogfileGroup & lg)
{
1949 1950 1951 1952
  return m_impl.dropLogfileGroup(NdbLogfileGroupImpl::getImpl(lg));
}

NdbDictionary::LogfileGroup
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1953 1954
NdbDictionary::Dictionary::getLogfileGroup(const char * name)
{
1955 1956 1957 1958 1959 1960 1961
  NdbDictionary::LogfileGroup tmp;
  m_impl.m_receiver.get_filegroup(NdbLogfileGroupImpl::getImpl(tmp), 
				  NdbDictionary::Object::LogfileGroup, name);
  return tmp;
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1962 1963 1964 1965
NdbDictionary::Dictionary::createTablespace(const Tablespace & lg,
					    ObjectId * obj)
{
  return m_impl.createTablespace(NdbTablespaceImpl::getImpl(lg),
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1966 1967
				 obj ? 
				 & NdbDictObjectImpl::getImpl(* obj) : 0);
1968 1969 1970
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1971 1972
NdbDictionary::Dictionary::dropTablespace(const Tablespace & lg)
{
1973 1974 1975 1976
  return m_impl.dropTablespace(NdbTablespaceImpl::getImpl(lg));
}

NdbDictionary::Tablespace
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1977 1978
NdbDictionary::Dictionary::getTablespace(const char * name)
{
1979 1980 1981 1982 1983 1984
  NdbDictionary::Tablespace tmp;
  m_impl.m_receiver.get_filegroup(NdbTablespaceImpl::getImpl(tmp), 
				  NdbDictionary::Object::Tablespace, name);
  return tmp;
}

1985
NdbDictionary::Tablespace
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1986 1987
NdbDictionary::Dictionary::getTablespace(Uint32 tablespaceId)
{
1988 1989 1990 1991 1992 1993 1994
  NdbDictionary::Tablespace tmp;
  m_impl.m_receiver.get_filegroup(NdbTablespaceImpl::getImpl(tmp), 
				  NdbDictionary::Object::Tablespace,
                                  tablespaceId);
  return tmp;
}

1995
int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
1996 1997 1998 1999 2000 2001
NdbDictionary::Dictionary::createDatafile(const Datafile & df, 
					  bool force,
					  ObjectId * obj)
{
  return m_impl.createDatafile(NdbDatafileImpl::getImpl(df), 
			       force,
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2002
			       obj ? & NdbDictObjectImpl::getImpl(* obj) : 0);
2003 2004 2005
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2006 2007
NdbDictionary::Dictionary::dropDatafile(const Datafile& df)
{
2008 2009 2010 2011
  return m_impl.dropDatafile(NdbDatafileImpl::getImpl(df));
}

NdbDictionary::Datafile
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2012 2013
NdbDictionary::Dictionary::getDatafile(Uint32 node, const char * path)
{
2014 2015 2016 2017 2018 2019 2020 2021
  NdbDictionary::Datafile tmp;
  m_impl.m_receiver.get_file(NdbDatafileImpl::getImpl(tmp),
			     NdbDictionary::Object::Datafile,
			     node ? (int)node : -1, path);
  return tmp;
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2022 2023 2024 2025 2026 2027
NdbDictionary::Dictionary::createUndofile(const Undofile & df, 
					  bool force,
					  ObjectId * obj)
{
  return m_impl.createUndofile(NdbUndofileImpl::getImpl(df), 
			       force,
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2028
			       obj ? & NdbDictObjectImpl::getImpl(* obj) : 0);
2029 2030 2031
}

int
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2032 2033
NdbDictionary::Dictionary::dropUndofile(const Undofile& df)
{
2034 2035 2036 2037
  return m_impl.dropUndofile(NdbUndofileImpl::getImpl(df));
}

NdbDictionary::Undofile
jonas@perch.ndb.mysql.com's avatar
jonas@perch.ndb.mysql.com committed
2038 2039
NdbDictionary::Dictionary::getUndofile(Uint32 node, const char * path)
{
2040 2041 2042 2043 2044 2045 2046
  NdbDictionary::Undofile tmp;
  m_impl.m_receiver.get_file(NdbUndofileImpl::getImpl(tmp),
			     NdbDictionary::Object::Undofile,
			     node ? (int)node : -1, path);
  return tmp;
}