List:Commits« Previous MessageNext Message »
From:pekka Date:September 26 2006 2:22pm
Subject:bk commit into 5.1 tree (pekka:1.2318) BUG#21690
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of pekka. When pekka does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-09-26 14:21:52+02:00, pekka@stripped +6 -0
  ndb - bug#21690: cleanup: set column properties in any order before create

  storage/ndb/include/ndbapi/NdbDictionary.hpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +31 -0
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

  storage/ndb/src/ndbapi/NdbDictionary.cpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +14 -3
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

  storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +23 -19
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

  storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +4 -5
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

  storage/ndb/test/include/NDBT_Table.hpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +5 -0
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

  storage/ndb/test/src/NDBT_Tables.cpp@stripped, 2006-09-26 14:16:27+02:00,
pekka@stripped +5 -0
    compute aggregates only before create table or by user request.
    remove distribution key hacks (set by user/set by us..)

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	pekka
# Host:	orca.ndb.mysql.com
# Root:	/export/home/space/pekka/ndb/version/my51-bug21690

--- 1.83/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-09-26 14:22:12 +02:00
+++ 1.84/storage/ndb/include/ndbapi/NdbDictionary.hpp	2006-09-26 14:22:12 +02:00
@@ -922,6 +922,37 @@
     void setTemporary(bool); 
 #endif
 
+    // these 2 are not de-doxygenated
+
+    /**
+     * This method is not needed in normal usage.
+     *
+     * Compute aggregate data on table being defined.  Required for
+     * aggregate methods such as getNoOfPrimaryKeys() to work before
+     * table has been created and retrieved via getTable().
+     *
+     * May adjust some column flags.  If no PK is so far marked as
+     * distribution key then all PK's will be marked.
+     *
+     * Returns 0 on success.  Returns -1 and sets error if an
+     * inconsistency is detected.
+     */
+    int aggregate(struct NdbError& error);
+
+    /**
+     * This method is not needed in normal usage.
+     *
+     * Validate new table definition before create.  Does aggregate()
+     * and additional checks.  There may still be errors which are
+     * detected only by NDB kernel at create table.
+     *
+     * Create table and retrieve table do validate() automatically.
+     *
+     * Returns 0 on success.  Returns -1 and sets error if an
+     * inconsistency is detected.
+     */
+    int validate(struct NdbError& error);
+
   private:
 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
     friend class Ndb;

--- 1.63/storage/ndb/src/ndbapi/NdbDictionary.cpp	2006-09-26 14:22:12 +02:00
+++ 1.64/storage/ndb/src/ndbapi/NdbDictionary.cpp	2006-09-26 14:22:12 +02:00
@@ -204,12 +204,12 @@
 
 void 
 NdbDictionary::Column::setPartitionKey(bool val){
-  m_impl.m_distributionKey = (val ? 2 : 0);
+  m_impl.m_distributionKey = true;
 }
 
 bool 
 NdbDictionary::Column::getPartitionKey() const{
-  return (bool)m_impl.m_distributionKey;
+  return m_impl.m_distributionKey;
 }
 
 const NdbDictionary::Table * 
@@ -353,7 +353,6 @@
   NdbColumnImpl* col = new NdbColumnImpl;
   (* col) = NdbColumnImpl::getImpl(c);
   m_impl.m_columns.push_back(col);
-  m_impl.computeAggregates();
   m_impl.buildColumnHash();
 }
 
@@ -697,6 +696,18 @@
 bool 
 NdbDictionary::Table::getRowGCIIndicator() const {
   return m_impl.m_row_gci;
+}
+
+int
+NdbDictionary::Table::aggregate(NdbError& error)
+{
+  return m_impl.aggregate(error);
+}
+
+int
+NdbDictionary::Table::validate(NdbError& error)
+{
+  return m_impl.validate(error);
 }
 
 

--- 1.150/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-09-26 14:22:12 +02:00
+++ 1.151/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp	2006-09-26 14:22:12 +02:00
@@ -295,7 +295,7 @@
     DBUG_RETURN(false);
   }
   if (m_pk) {
-    if ((bool)m_distributionKey != (bool)col.m_distributionKey) {
+    if (m_distributionKey != col.m_distributionKey) {
       DBUG_RETURN(false);
     }
   }
@@ -780,8 +780,8 @@
       m_noOfKeys++;
       m_keyLenInWords += (col->m_attrSize * col->m_arraySize + 3) / 4;
     }
-    if (col->m_distributionKey == 2)    // set by user
-      m_noOfDistributionKeys++;
+    if (col->m_distributionKey)
+      m_noOfDistributionKeys++; // XXX check PK
     
     if (col->getBlobType())
       m_noOfBlobs++;
@@ -798,19 +798,7 @@
     for (i = 0, n = m_noOfKeys; n != 0; i++) {
       NdbColumnImpl* col = m_columns[i];
       if (col->m_pk) {
-        col->m_distributionKey = true;  // set by us
-        n--;
-      }
-    }
-  }
-  else 
-  {
-    for (i = 0, n = m_noOfKeys; n != 0; i++) {
-      NdbColumnImpl* col = m_columns[i];
-      if (col->m_pk)
-      {
-	if(col->m_distributionKey == 1)
-	  col->m_distributionKey = 0;  
+        col->m_distributionKey = true;
         n--;
       }
     }
@@ -826,6 +814,22 @@
   }
 }
 
+// TODO add error checks
+// TODO use these internally at create and retrieve
+int
+NdbTableImpl::aggregate(NdbError& error)
+{
+  computeAggregates();
+  return 0;
+}
+int
+NdbTableImpl::validate(NdbError& error)
+{
+  if (aggregate(error) == -1)
+    return -1;
+  return 0;
+}
+
 const void*
 NdbTableImpl::getTablespaceNames() const
 {
@@ -2113,9 +2117,9 @@
     col->m_storageType = attrDesc.AttributeStorageType;
     
     col->m_pk = attrDesc.AttributeKeyFlag;
-    col->m_distributionKey = attrDesc.AttributeDKey ? 2 : 0;
+    col->m_distributionKey = (attrDesc.AttributeDKey != 0);
     col->m_nullable = attrDesc.AttributeNullableFlag;
-    col->m_autoIncrement = (attrDesc.AttributeAutoIncrement ? true : false);
+    col->m_autoIncrement = (attrDesc.AttributeAutoIncrement != 0);
     col->m_autoIncrementInitialValue = ~0;
     col->m_defaultValue.assign(attrDesc.AttributeDefaultValue);
 
@@ -2606,7 +2610,7 @@
     tmpAttr.AttributeId = col->m_attrId;
     tmpAttr.AttributeKeyFlag = col->m_pk;
     tmpAttr.AttributeNullableFlag = col->m_nullable;
-    tmpAttr.AttributeDKey = distKeys ? (bool)col->m_distributionKey : 0;
+    tmpAttr.AttributeDKey = distKeys ? col->m_distributionKey : 0;
 
     tmpAttr.AttributeExtType = (Uint32)col->m_type;
     tmpAttr.AttributeExtPrecision = ((unsigned)col->m_precision & 0xFFFF);

--- 1.67/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-09-26 14:22:12 +02:00
+++ 1.68/storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp	2006-09-26 14:22:12 +02:00
@@ -85,11 +85,7 @@
   CHARSET_INFO * m_cs;          // not const in MySQL
   
   bool m_pk;
-  /*
-   * Since "none" is "all" we distinguish between
-   * 1-set by us, 2-set by user
-   */
-  Uint32 m_distributionKey;
+  bool m_distributionKey;
   bool m_nullable;
   bool m_autoIncrement;
   Uint64 m_autoIncrementInitialValue;
@@ -158,6 +154,9 @@
 
   const char * getMysqlName() const;
   void updateMysqlName();
+
+  int aggregate(NdbError& error);
+  int validate(NdbError& error);
 
   Uint32 m_changeMask;
   Uint32 m_primaryTableId;

--- 1.12/storage/ndb/test/include/NDBT_Table.hpp	2006-09-26 14:22:12 +02:00
+++ 1.13/storage/ndb/test/include/NDBT_Table.hpp	2006-09-26 14:22:12 +02:00
@@ -65,6 +65,11 @@
     //setStoredTable(stored);
     for(int i = 0; i<noOfAttributes; i++)
       addColumn(attributes[i]);
+
+    // validate() might cause initialization order problem with charset
+    NdbError error;
+    int ret = aggregate(error);
+    assert(ret == 0);
   }
 
   static const NdbDictionary::Table * discoverTableFromDb(Ndb* ndb,

--- 1.20/storage/ndb/test/src/NDBT_Tables.cpp	2006-09-26 14:22:12 +02:00
+++ 1.21/storage/ndb/test/src/NDBT_Tables.cpp	2006-09-26 14:22:12 +02:00
@@ -977,6 +977,11 @@
   do {
     NdbDictionary::Table tmpTab(* tab);
     tmpTab.setStoredTable(_temp ? 0 : 1);
+    {
+      NdbError error;
+      int ret = tmpTab.validate(error);
+      assert(ret == 0);
+    }
     if(f != 0 && f(pNdb, tmpTab, 0, arg))
     {
       ndbout << "Failed to create table" << endl;
Thread
bk commit into 5.1 tree (pekka:1.2318) BUG#21690pekka26 Sep