Commit eab52b8a authored by unknown's avatar unknown
Browse files

ndb - ndb api : try to catch autoincr 'error 0'


storage/ndb/src/ndbapi/Ndb.cpp:
  try to catch autoincr 'error 0'
parent c8cb9048
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -1025,14 +1025,19 @@ int Ndb::initAutoIncrement()
  setDatabaseName("sys");
  setDatabaseSchemaName("def");

  m_sys_tab_0 = getDictionary()->getTableGlobal("SYSTAB_0");
  m_sys_tab_0 = theDictionary->getTableGlobal("SYSTAB_0");

  // Restore current name space
  setDatabaseName(currentDb.c_str());
  setDatabaseSchemaName(currentSchema.c_str());

  if (m_sys_tab_0 == NULL) {
    assert(theDictionary->m_error.code != 0);
    theError.code = theDictionary->m_error.code;
    return -1;
  }

  return (m_sys_tab_0 == NULL);
  return 0;
}

int
@@ -1043,19 +1048,19 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
  Uint32 aTableId = table->m_id;
  DBUG_PRINT("enter", ("table=%u value=%llu op=%u", aTableId, opValue, op));

  NdbTransaction*     tConnection;
  NdbOperation*      tOperation= 0; // Compiler warning if not initialized
  NdbTransaction*    tConnection = NULL;
  NdbOperation*      tOperation = NULL;
  Uint64             tValue;
  NdbRecAttr*        tRecAttrResult;

  CHECK_STATUS_MACRO_ZERO;
  CHECK_STATUS_MACRO;

  if (initAutoIncrement())
    goto error_return;
  if (initAutoIncrement() == -1)
    goto error_handler;

  tConnection = this->startTransaction();
  if (tConnection == NULL)
    goto error_return;
    goto error_handler;

  tOperation = tConnection->getNdbOperation(m_sys_tab_0);
  if (tOperation == NULL)
@@ -1131,13 +1136,20 @@ Ndb::opTupleIdOnNdb(const NdbTableImpl* table,
  DBUG_RETURN(0);

error_handler:
    theError.code = tConnection->theError.code;
    this->closeTransaction(tConnection);
  error_return:
  DBUG_PRINT("error", ("ndb=%d con=%d op=%d",
             theError.code,
             tConnection ? tConnection->theError.code : -1,
             tOperation ? tOperation->theError.code : -1));
             tConnection != NULL ? tConnection->theError.code : -1,
             tOperation != NULL ? tOperation->theError.code : -1));

  if (theError.code == 0 && tConnection != NULL)
    theError.code = tConnection->theError.code;
  if (theError.code == 0 && tOperation != NULL)
    theError.code = tOperation->theError.code;
  DBUG_ASSERT(theError.code != 0);

  if (tConnection != NULL)
    this->closeTransaction(tConnection);

  DBUG_RETURN(-1);
}