Esempio n. 1
0
static int drop_all_tables()
{
  NdbDictionary::Dictionary * dict = g_ndb->getDictionary();
  require(dict);

  BaseString db = g_ndb->getDatabaseName();
  BaseString schema = g_ndb->getSchemaName();

  NdbDictionary::Dictionary::List list;
  if (dict->listObjects(list, NdbDictionary::Object::TypeUndefined) == -1){
      g_err << "Failed to list tables: " << endl
	    << dict->getNdbError() << endl;
      return -1;
  }
  for (unsigned i = 0; i < list.count; i++) {
    NdbDictionary::Dictionary::List::Element& elt = list.elements[i];
    switch (elt.type) {
    case NdbDictionary::Object::SystemTable:
    case NdbDictionary::Object::UserTable:
      g_ndb->setDatabaseName(elt.database);
      g_ndb->setSchemaName(elt.schema);
      if(dict->dropTable(elt.name) != 0){
	g_err << "Failed to drop table: " 
	      << elt.database << "/" << elt.schema << "/" << elt.name <<endl;
	g_err << dict->getNdbError() << endl;
	return -1;
      }
      break;
    case NdbDictionary::Object::UniqueHashIndex:
    case NdbDictionary::Object::OrderedIndex:
    case NdbDictionary::Object::HashIndexTrigger:
    case NdbDictionary::Object::IndexTrigger:
    case NdbDictionary::Object::SubscriptionTrigger:
    case NdbDictionary::Object::ReadOnlyConstraint:
    default:
      break;
    }
  }
  
  g_ndb->setDatabaseName(db.c_str());
  g_ndb->setSchemaName(schema.c_str());
  
  return 0;
}
Esempio n. 2
0
 /* UV_WORKER_THREAD part of listTables */
 void run() {
   ndb = arg0->ndb;
   dict = ndb->getDictionary();
   return_val = dict->listObjects(list, NdbDictionary::Object::UserTable);
 }
Esempio n. 3
0
 /* UV_WORKER_THREAD part of listTables */
 void run() {
   NdbDictionary::Dictionary * dict = arg0->dict;
   return_val = dict->listObjects(list, NdbDictionary::Object::UserTable);
 }
Esempio n. 4
0
int
runPostUpgradeChecks(NDBT_Context* ctx, NDBT_Step* step)
{
    /**
     * Table will be dropped/recreated
     *   automatically by NDBT...
     *   so when we enter here, this is already tested
     */
    NdbBackup backup;

    ndbout << "Starting backup..." << flush;
    if (backup.start() != 0)
    {
        ndbout << "Failed" << endl;
        return NDBT_FAILED;
    }
    ndbout << "done" << endl;


    if ((ctx->getProperty("NoDDL", Uint32(0)) == 0) &&
            (ctx->getProperty("KeepFS", Uint32(0)) != 0))
    {
        /**
         * Bug48227
         * Upgrade with FS 6.3->7.0, followed by table
         * create, followed by Sys restart resulted in
         * table loss.
         */
        Ndb* pNdb = GETNDB(step);
        NdbDictionary::Dictionary *pDict = pNdb->getDictionary();
        {
            NdbDictionary::Dictionary::List l;
            pDict->listObjects(l);
            for (Uint32 i = 0; i<l.count; i++)
                ndbout_c("found %u : %s", l.elements[i].id, l.elements[i].name);
        }

        pDict->dropTable("I3");
        if (NDBT_Tables::createTable(pNdb, "I3"))
        {
            ndbout_c("Failed to create table!");
            ndbout << pDict->getNdbError() << endl;
            return NDBT_FAILED;
        }

        {
            NdbDictionary::Dictionary::List l;
            pDict->listObjects(l);
            for (Uint32 i = 0; i<l.count; i++)
                ndbout_c("found %u : %s", l.elements[i].id, l.elements[i].name);
        }

        NdbRestarter res;
        if (res.restartAll() != 0)
        {
            ndbout_c("restartAll() failed");
            return NDBT_FAILED;
        }

        if (res.waitClusterStarted() != 0)
        {
            ndbout_c("waitClusterStarted() failed");
            return NDBT_FAILED;
        }

        if (pDict->getTable("I3") == 0)
        {
            ndbout_c("Table disappered");
            return NDBT_FAILED;
        }
    }

    return NDBT_OK;
}