NdbDictionaryImpl.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:18k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef NdbDictionaryImpl_H
  14. #define NdbDictionaryImpl_H
  15. #include <ndb_types.h>
  16. #include <kernel_types.h>
  17. #include <ndb_limits.h>
  18. #include <NdbError.hpp>
  19. #include <BaseString.hpp>
  20. #include <Vector.hpp>
  21. #include <UtilBuffer.hpp>
  22. #include <NdbDictionary.hpp>
  23. #include <Bitmask.hpp>
  24. #include <AttributeList.hpp>
  25. #include <Ndb.hpp>
  26. #include "NdbWaiter.hpp"
  27. #include "DictCache.hpp"
  28. class NdbDictObjectImpl {
  29. public:
  30.   Uint32 m_version;
  31.   NdbDictionary::Object::Status m_status;
  32.   
  33.   bool change();
  34. protected:
  35.   NdbDictObjectImpl() :
  36.     m_status(NdbDictionary::Object::New) {
  37.   }
  38. };
  39. /**
  40.  * Column
  41.  */
  42. class NdbColumnImpl : public NdbDictionary::Column {
  43. public:
  44.   NdbColumnImpl();
  45.   NdbColumnImpl(NdbDictionary::Column &); // This is not a copy constructor
  46.   ~NdbColumnImpl();
  47.   NdbColumnImpl& operator=(const NdbColumnImpl&);
  48.   void init(Type t = Unsigned);
  49.   
  50.   int m_attrId;
  51.   BaseString m_name;
  52.   NdbDictionary::Column::Type m_type;
  53.   int m_precision;
  54.   int m_scale;
  55.   int m_length;
  56.   CHARSET_INFO * m_cs;          // not const in MySQL
  57.   
  58.   bool m_pk;
  59.   bool m_tupleKey;
  60.   bool m_distributionKey;
  61.   bool m_distributionGroup;
  62.   int m_distributionGroupBits;
  63.   bool m_nullable;
  64.   bool m_indexOnly;
  65.   bool m_autoIncrement;
  66.   Uint64 m_autoIncrementInitialValue;
  67.   BaseString m_defaultValue;
  68.   NdbTableImpl * m_blobTable;
  69.   /**
  70.    * Internal types and sizes, and aggregates
  71.    */
  72.   Uint32 m_attrType;            // type outsize API and DICT
  73.   Uint32 m_attrSize;            // element size (size when arraySize==1)
  74.   Uint32 m_arraySize;           // length or length+2 for Var* types
  75.   Uint32 m_keyInfoPos;
  76.   Uint32 m_extType;             // used by restore (kernel type in versin v2x)
  77.   bool getInterpretableType() const ;
  78.   bool getCharType() const;
  79.   bool getBlobType() const;
  80.   /**
  81.    * Equality/assign
  82.    */
  83.   bool equal(const NdbColumnImpl&) const;
  84.   static NdbColumnImpl & getImpl(NdbDictionary::Column & t);
  85.   static const NdbColumnImpl & getImpl(const NdbDictionary::Column & t);
  86.   NdbDictionary::Column * m_facade;
  87.   static NdbDictionary::Column * create_psuedo(const char *);
  88. };
  89. class NdbTableImpl : public NdbDictionary::Table, public NdbDictObjectImpl {
  90. public:
  91.   NdbTableImpl();
  92.   NdbTableImpl(NdbDictionary::Table &);
  93.   ~NdbTableImpl();
  94.   
  95.   void init();
  96.   void setName(const char * name);
  97.   const char * getName() const;
  98.   Uint32 m_changeMask;
  99.   Uint32 m_tableId;
  100.   BaseString m_internalName;
  101.   BaseString m_externalName;
  102.   BaseString m_newExternalName; // Used for alter table
  103.   UtilBuffer m_frm; 
  104.   NdbDictionary::Object::FragmentType m_fragmentType;
  105.   /**
  106.    * 
  107.    */
  108.   Uint32 m_columnHashMask;
  109.   Vector<Uint32> m_columnHash;
  110.   Vector<NdbColumnImpl *> m_columns;
  111.   void buildColumnHash(); 
  112.   
  113.   bool m_logging;
  114.   int m_kvalue;
  115.   int m_minLoadFactor;
  116.   int m_maxLoadFactor;
  117.   int m_keyLenInWords;
  118.   int m_fragmentCount;
  119.   NdbDictionaryImpl * m_dictionary;
  120.   NdbIndexImpl * m_index;
  121.   NdbColumnImpl * getColumn(unsigned attrId);
  122.   NdbColumnImpl * getColumn(const char * name);
  123.   const NdbColumnImpl * getColumn(unsigned attrId) const;
  124.   const NdbColumnImpl * getColumn(const char * name) const;
  125.   
  126.   /**
  127.    * Index only stuff
  128.    */
  129.   BaseString m_primaryTable;
  130.   NdbDictionary::Index::Type m_indexType;
  131.   /**
  132.    * Aggregates
  133.    */
  134.   Uint32 m_noOfKeys;
  135.   unsigned short m_sizeOfKeysInWords;
  136.   unsigned short m_noOfBlobs;
  137.   /**
  138.    * Equality/assign
  139.    */
  140.   bool equal(const NdbTableImpl&) const;
  141.   void assign(const NdbTableImpl&);
  142.   void clearNewProperties();
  143.   void copyNewProperties();
  144.   static NdbTableImpl & getImpl(NdbDictionary::Table & t);
  145.   static NdbTableImpl & getImpl(const NdbDictionary::Table & t);
  146.   NdbDictionary::Table * m_facade;
  147. };
  148. class NdbIndexImpl : public NdbDictionary::Index, public NdbDictObjectImpl {
  149. public:
  150.   NdbIndexImpl();
  151.   NdbIndexImpl(NdbDictionary::Index &);
  152.   ~NdbIndexImpl();
  153.   void setName(const char * name);
  154.   const char * getName() const;
  155.   void setTable(const char * table);
  156.   const char * getTable() const;
  157.   const NdbTableImpl * getIndexTable() const;
  158.   Uint32 m_indexId;
  159.   BaseString m_internalName;
  160.   BaseString m_externalName;
  161.   BaseString m_tableName;
  162.   Vector<NdbColumnImpl *> m_columns;
  163.   Vector<int> m_key_ids;
  164.   NdbDictionary::Index::Type m_type;
  165.   bool m_logging;
  166.   
  167.   NdbTableImpl * m_table;
  168.   
  169.   static NdbIndexImpl & getImpl(NdbDictionary::Index & t);
  170.   static NdbIndexImpl & getImpl(const NdbDictionary::Index & t);
  171.   NdbDictionary::Index * m_facade;
  172. };
  173. class NdbEventImpl : public NdbDictionary::Event, public NdbDictObjectImpl {
  174. public:
  175.   NdbEventImpl();
  176.   NdbEventImpl(NdbDictionary::Event &);
  177.   ~NdbEventImpl();
  178.   void setName(const char * name);
  179.   const char * getName() const;
  180.   void setTable(const char * table);
  181.   const char * getTable() const;
  182.   void addTableEvent(const NdbDictionary::Event::TableEvent t);
  183.   void setDurability(const NdbDictionary::Event::EventDurability d);
  184.   void addEventColumn(const NdbColumnImpl &c);
  185.   void print() {
  186.     ndbout_c("NdbEventImpl: id=%d, key=%d",
  187.      m_eventId,
  188.      m_eventKey);
  189.   };
  190.   Uint32 m_eventId;
  191.   Uint32 m_eventKey;
  192.   Uint32 m_tableId;
  193.   AttributeMask m_attrListBitmask;
  194.   //BaseString m_internalName;
  195.   BaseString m_externalName;
  196.   Uint32 mi_type;
  197.   NdbDictionary::Event::EventDurability m_dur;
  198.   NdbTableImpl *m_tableImpl;
  199.   BaseString m_tableName;
  200.   Vector<NdbColumnImpl *> m_columns;
  201.   Vector<unsigned> m_attrIds;
  202.   int m_bufferId;
  203.   NdbEventOperation *eventOp;
  204.   static NdbEventImpl & getImpl(NdbDictionary::Event & t);
  205.   static NdbEventImpl & getImpl(const NdbDictionary::Event & t);
  206.   NdbDictionary::Event * m_facade;
  207. };
  208. class NdbDictInterface {
  209. public:
  210.   NdbDictInterface(NdbError& err) : m_error(err) {
  211.     m_reference = 0;
  212.     m_masterNodeId = 0;
  213.     m_transporter= NULL;
  214.   }
  215.   ~NdbDictInterface();
  216.   
  217.   bool setTransporter(class Ndb * ndb, class TransporterFacade * tf);
  218.   bool setTransporter(class TransporterFacade * tf);
  219.   
  220.   // To abstract the stuff thats made in all create/drop/lists below
  221.   int
  222.   dictSignal(NdbApiSignal* signal, 
  223.      LinearSectionPtr ptr[3], int noLPTR,
  224.      const int useMasterNodeId,
  225.      const Uint32 RETRIES,
  226.      const WaitSignalType wst,
  227.      const int theWait,
  228.      const int *errcodes,
  229.      const int noerrcodes,
  230.      const int temporaryMask = 0);
  231.   int createOrAlterTable(class Ndb & ndb, NdbTableImpl &, bool alter);
  232.   int createTable(class Ndb & ndb, NdbTableImpl &);
  233.   int createTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  234.   int alterTable(class Ndb & ndb, NdbTableImpl &);
  235.   int alterTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  236.   int createIndex(class Ndb & ndb,
  237.   NdbIndexImpl &, 
  238.   const NdbTableImpl &);
  239.   int createIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  240.   
  241.   int createEvent(class Ndb & ndb, NdbEventImpl &, int getFlag);
  242.   int createEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP);
  243.   
  244.   int dropTable(const NdbTableImpl &);
  245.   int dropTable(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  246.   int dropIndex(const NdbIndexImpl &, const NdbTableImpl &);
  247.   int dropIndex(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  248.   int dropEvent(const NdbEventImpl &);
  249.   int dropEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3], int noLSP);
  250.   int executeSubscribeEvent(class Ndb & ndb, NdbEventImpl &);
  251.   int executeSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  252.   
  253.   int stopSubscribeEvent(class Ndb & ndb, NdbEventImpl &);
  254.   int stopSubscribeEvent(NdbApiSignal* signal, LinearSectionPtr ptr[3]);
  255.   
  256.   int listObjects(NdbDictionary::Dictionary::List& list, Uint32 requestData, bool fullyQualifiedNames);
  257.   int listObjects(NdbApiSignal* signal);
  258.   
  259.   NdbTableImpl * getTable(int tableId, bool fullyQualifiedNames);
  260.   NdbTableImpl * getTable(const char * name, bool fullyQualifiedNames);
  261.   NdbTableImpl * getTable(class NdbApiSignal * signal, 
  262.   LinearSectionPtr ptr[3],
  263.   Uint32 noOfSections, bool fullyQualifiedNames);
  264.   static int parseTableInfo(NdbTableImpl ** dst, 
  265.     const Uint32 * data, Uint32 len,
  266.     bool fullyQualifiedNames);
  267.   
  268.   static int create_index_obj_from_table(NdbIndexImpl ** dst, 
  269.  const NdbTableImpl*,
  270.  const NdbTableImpl*);
  271.   
  272.   NdbError & m_error;
  273. private:
  274.   Uint32 m_reference;
  275.   Uint32 m_masterNodeId;
  276.   
  277.   NdbWaiter m_waiter;
  278.   class TransporterFacade * m_transporter;
  279.   
  280.   friend class Ndb;
  281.   static void execSignal(void* dictImpl, 
  282.  class NdbApiSignal* signal, 
  283.  struct LinearSectionPtr ptr[3]);
  284.   
  285.   static void execNodeStatus(void* dictImpl, Uint32, 
  286.      bool alive, bool nfCompleted);  
  287.   
  288.   void execGET_TABINFO_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  289.   void execGET_TABINFO_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  290.   void execCREATE_TABLE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  291.   void execCREATE_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  292.   void execALTER_TABLE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  293.   void execALTER_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  294.   void execCREATE_INDX_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  295.   void execCREATE_INDX_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  296.   void execDROP_INDX_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  297.   void execDROP_INDX_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  298.   void execCREATE_EVNT_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  299.   void execCREATE_EVNT_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  300.   void execSUB_START_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  301.   void execSUB_START_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  302.   void execSUB_TABLE_DATA(NdbApiSignal *, LinearSectionPtr ptr[3]);
  303.   void execSUB_GCP_COMPLETE_REP(NdbApiSignal *, LinearSectionPtr ptr[3]);
  304.   void execSUB_STOP_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  305.   void execSUB_STOP_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  306.   void execDROP_EVNT_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  307.   void execDROP_EVNT_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  308.   void execDROP_TABLE_REF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  309.   void execDROP_TABLE_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  310.   void execLIST_TABLES_CONF(NdbApiSignal *, LinearSectionPtr ptr[3]);
  311.   Uint32 m_fragmentId;
  312.   UtilBuffer m_buffer;
  313. };
  314. class NdbDictionaryImpl : public NdbDictionary::Dictionary {
  315. public:
  316.   NdbDictionaryImpl(Ndb &ndb);
  317.   NdbDictionaryImpl(Ndb &ndb, NdbDictionary::Dictionary & f);
  318.   ~NdbDictionaryImpl();
  319.   bool setTransporter(class Ndb * ndb, class TransporterFacade * tf);
  320.   bool setTransporter(class TransporterFacade * tf);
  321.   
  322.   int createTable(NdbTableImpl &t);
  323.   int createBlobTables(NdbTableImpl &);
  324.   int addBlobTables(NdbTableImpl &);
  325.   int alterTable(NdbTableImpl &t);
  326.   int dropTable(const char * name);
  327.   int dropTable(NdbTableImpl &);
  328.   int dropBlobTables(NdbTableImpl &);
  329.   int invalidateObject(NdbTableImpl &);
  330.   int removeCachedObject(NdbTableImpl &);
  331.   int createIndex(NdbIndexImpl &ix);
  332.   int dropIndex(const char * indexName, 
  333. const char * tableName);
  334.   int dropIndex(NdbIndexImpl &, const char * tableName);
  335.   NdbTableImpl * getIndexTable(NdbIndexImpl * index, 
  336.        NdbTableImpl * table);
  337.   int createEvent(NdbEventImpl &);
  338.   int dropEvent(const char * eventName);
  339.   int executeSubscribeEvent(NdbEventImpl &);
  340.   int stopSubscribeEvent(NdbEventImpl &);
  341.   int listObjects(List& list, NdbDictionary::Object::Type type);
  342.   int listIndexes(List& list, Uint32 indexId);
  343.   
  344.   NdbTableImpl * getTable(const char * tableName, void **data= 0);
  345.   Ndb_local_table_info * get_local_table_info(const char * internalName,
  346.       bool do_add_blob_tables);
  347.   NdbIndexImpl * getIndex(const char * indexName,
  348.   const char * tableName);
  349.   NdbIndexImpl * getIndexImpl(const char * name, const char * internalName);
  350.   NdbEventImpl * getEvent(const char * eventName);
  351.   NdbEventImpl * getEventImpl(const char * internalName);
  352.   
  353.   const NdbError & getNdbError() const;
  354.   NdbError m_error;
  355.   Uint32 m_local_table_data_size;
  356.   LocalDictCache m_localHash;
  357.   GlobalDictCache * m_globalHash;
  358.   static NdbDictionaryImpl & getImpl(NdbDictionary::Dictionary & t);
  359.   static const NdbDictionaryImpl & getImpl(const NdbDictionary::Dictionary &t);
  360.   NdbDictionary::Dictionary * m_facade;
  361.   NdbDictInterface m_receiver;
  362.   Ndb & m_ndb;
  363. private:
  364.   Ndb_local_table_info * fetchGlobalTableImpl(const char * internalName);
  365. };
  366. inline
  367. NdbEventImpl &
  368. NdbEventImpl::getImpl(const NdbDictionary::Event & t){
  369.   return t.m_impl;
  370. }
  371. inline
  372. NdbEventImpl &
  373. NdbEventImpl::getImpl(NdbDictionary::Event & t){
  374.   return t.m_impl;
  375. }
  376. inline
  377. NdbColumnImpl &
  378. NdbColumnImpl::getImpl(NdbDictionary::Column & t){
  379.   return t.m_impl;
  380. }
  381. inline
  382. const NdbColumnImpl &
  383. NdbColumnImpl::getImpl(const NdbDictionary::Column & t){
  384.   return t.m_impl;
  385. }
  386. inline
  387. bool 
  388. NdbColumnImpl::getInterpretableType() const {
  389.   return (m_type == NdbDictionary::Column::Unsigned ||
  390.   m_type == NdbDictionary::Column::Bigunsigned);
  391. }
  392. inline
  393. bool 
  394. NdbColumnImpl::getCharType() const {
  395.   return (m_type == NdbDictionary::Column::Char ||
  396.           m_type == NdbDictionary::Column::Varchar ||
  397.           m_type == NdbDictionary::Column::Text);
  398. }
  399.    
  400. inline
  401. bool 
  402. NdbColumnImpl::getBlobType() const {
  403.   return (m_type == NdbDictionary::Column::Blob ||
  404.   m_type == NdbDictionary::Column::Text);
  405. }
  406. inline
  407. NdbTableImpl &
  408. NdbTableImpl::getImpl(NdbDictionary::Table & t){
  409.   return t.m_impl;
  410. }
  411. inline
  412. NdbTableImpl &
  413. NdbTableImpl::getImpl(const NdbDictionary::Table & t){
  414.   return t.m_impl;
  415. }
  416. inline
  417. NdbColumnImpl *
  418. NdbTableImpl::getColumn(unsigned attrId){
  419.   if(m_columns.size() > attrId){
  420.     return m_columns[attrId];
  421.   }
  422.   return 0;
  423. }
  424. inline
  425. Uint32
  426. Hash( const char* str ){
  427.   Uint32 h = 0;
  428.   Uint32 len = strlen(str);
  429.   while(len >= 4){
  430.     h = (h << 5) + h + str[0];
  431.     h = (h << 5) + h + str[1];
  432.     h = (h << 5) + h + str[2];
  433.     h = (h << 5) + h + str[3];
  434.     len -= 4;
  435.     str += 4;
  436.   }
  437.   
  438.   switch(len){
  439.   case 3:
  440.     h = (h << 5) + h + *str++;
  441.   case 2:
  442.     h = (h << 5) + h + *str++;
  443.   case 1:
  444.     h = (h << 5) + h + *str++;
  445.   }
  446.   return h + h;
  447. }
  448. inline
  449. NdbColumnImpl *
  450. NdbTableImpl::getColumn(const char * name){
  451.   Uint32 sz = m_columns.size();
  452.   NdbColumnImpl** cols = m_columns.getBase();
  453.   const Uint32 * hashtable = m_columnHash.getBase();
  454.   if(sz > 5 && false){
  455.     Uint32 hashValue = Hash(name) & 0xFFFE;
  456.     Uint32 bucket = hashValue & m_columnHashMask;
  457.     bucket = (bucket < sz ? bucket : bucket - sz);
  458.     hashtable += bucket;
  459.     Uint32 tmp = * hashtable;
  460.     if((tmp & 1) == 1 ){ // No chaining
  461.       sz = 1;
  462.     } else {
  463.       sz = (tmp >> 16);
  464.       hashtable += (tmp & 0xFFFE) >> 1;
  465.       tmp = * hashtable;
  466.     }
  467.     do {
  468.       if(hashValue == (tmp & 0xFFFE)){
  469. NdbColumnImpl* col = cols[tmp >> 16];
  470. if(strcmp(name, col->m_name.c_str()) == 0){
  471.   return col;
  472. }
  473.       }
  474.       hashtable++;
  475.       tmp = * hashtable;
  476.     } while(--sz > 0);
  477. #if 0
  478.     Uint32 dir = m_columnHash[bucket];
  479.     Uint32 pos = bucket + ((dir & 0xFFFE) >> 1); 
  480.     Uint32 cnt = dir >> 16;
  481.     ndbout_c("col: %s hv: %x bucket: %d dir: %x pos: %d cnt: %d tmp: %d -> 0", 
  482.      name, hashValue, bucket, dir, pos, cnt, tmp);
  483. #endif
  484.     return 0;
  485.   } else {
  486.     for(Uint32 i = 0; i<sz; i++){
  487.       NdbColumnImpl* col = * cols++;
  488.       if(col != 0 && strcmp(name, col->m_name.c_str()) == 0)
  489. return col;
  490.     }
  491.   }
  492.   return 0;
  493. }
  494. inline
  495. const NdbColumnImpl *
  496. NdbTableImpl::getColumn(unsigned attrId) const {
  497.   if(m_columns.size() > attrId){
  498.     return m_columns[attrId];
  499.   }
  500.   return 0;
  501. }
  502. inline
  503. const NdbColumnImpl *
  504. NdbTableImpl::getColumn(const char * name) const {
  505.   Uint32 sz = m_columns.size();
  506.   NdbColumnImpl* const * cols = m_columns.getBase();
  507.   for(Uint32 i = 0; i<sz; i++, cols++){
  508.     NdbColumnImpl* col = * cols;
  509.     if(col != 0 && strcmp(name, col->m_name.c_str()) == 0)
  510.       return col;
  511.   }
  512.   return 0;
  513. }
  514. inline
  515. NdbIndexImpl &
  516. NdbIndexImpl::getImpl(NdbDictionary::Index & t){
  517.   return t.m_impl;
  518. }
  519. inline
  520. NdbIndexImpl &
  521. NdbIndexImpl::getImpl(const NdbDictionary::Index & t){
  522.   return t.m_impl;
  523. }
  524. inline
  525. NdbDictionaryImpl &
  526. NdbDictionaryImpl::getImpl(NdbDictionary::Dictionary & t){
  527.   return t.m_impl;
  528. }
  529. inline
  530. const NdbDictionaryImpl &
  531. NdbDictionaryImpl::getImpl(const NdbDictionary::Dictionary & t){
  532.   return t.m_impl;
  533. }
  534. /*****************************************************************
  535.  * Inline:d getters
  536.  */
  537. inline
  538. NdbTableImpl * 
  539. NdbDictionaryImpl::getTable(const char * tableName, void **data)
  540. {
  541.   Ndb_local_table_info *info=
  542.     get_local_table_info(m_ndb.internalizeTableName(tableName), true);
  543.   if (info == 0) {
  544.     return 0;
  545.   }
  546.   if (data) {
  547.     *data= info->m_local_data;
  548.   }
  549.   return info->m_table_impl;
  550. }
  551. inline
  552. Ndb_local_table_info * 
  553. NdbDictionaryImpl::get_local_table_info(const char * internalTableName,
  554. bool do_add_blob_tables)
  555. {
  556.   Ndb_local_table_info *info= m_localHash.get(internalTableName);
  557.   if (info == 0) {
  558.     info= fetchGlobalTableImpl(internalTableName);
  559.     if (info == 0) {
  560.       return 0;
  561.     }
  562.   }
  563.   if (do_add_blob_tables && info->m_table_impl->m_noOfBlobs)
  564.     addBlobTables(*(info->m_table_impl));
  565.   
  566.   return info; // autoincrement already initialized
  567. }
  568. inline
  569. NdbIndexImpl * 
  570. NdbDictionaryImpl::getIndex(const char * indexName,
  571.     const char * tableName)
  572. {
  573.   if (tableName || m_ndb.usingFullyQualifiedNames()) {
  574.     const char * internalIndexName = 0;
  575.     if (tableName) {
  576.       NdbTableImpl * t = getTable(tableName);
  577.       if (t != 0)
  578.         internalIndexName = m_ndb.internalizeIndexName(t, indexName);
  579.     } else {
  580.       internalIndexName =
  581. m_ndb.internalizeTableName(indexName); // Index is also a table
  582.     }
  583.     if (internalIndexName) {
  584.       Ndb_local_table_info * info = get_local_table_info(internalIndexName,
  585.  false);
  586.       if (info) {
  587. NdbTableImpl * tab = info->m_table_impl;
  588.         if (tab->m_index == 0)
  589.           tab->m_index = getIndexImpl(indexName, internalIndexName);
  590.         if (tab->m_index != 0)
  591.           tab->m_index->m_table = tab;
  592.         return tab->m_index;
  593.       }
  594.     }
  595.   }
  596.   m_error.code = 4243;
  597.   return 0;
  598. }
  599. #endif