summaryrefslogtreecommitdiff
path: root/sql/ha_ndbcluster.cc
diff options
context:
space:
mode:
authorunknown <tomas@whalegate.ndb.mysql.com>2007-05-22 23:20:40 +0200
committerunknown <tomas@whalegate.ndb.mysql.com>2007-05-22 23:20:40 +0200
commitf529d18ba617be40a5f840f818c310dcb2ec0211 (patch)
treef64f45786ea586e06eb06ba26e27f78f7a73b4ed /sql/ha_ndbcluster.cc
parent9a1ab7e63f73f81c3b34b8a705fb9692250f0678 (diff)
parent4d8de9e792552079598974d6bf0b25405e6c6e79 (diff)
downloadmariadb-git-f529d18ba617be40a5f840f818c310dcb2ec0211.tar.gz
Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0
into whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r--sql/ha_ndbcluster.cc86
1 files changed, 54 insertions, 32 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 9b48e0d4f38..0f3a42bbce7 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -2309,16 +2309,24 @@ int ha_ndbcluster::write_row(byte *record)
{
// Table has hidden primary key
Ndb *ndb= get_ndb();
- int ret;
Uint64 auto_value;
uint retries= NDB_AUTO_INCREMENT_RETRIES;
- do {
- ret= ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, 1);
- } while (ret == -1 &&
- --retries &&
- ndb->getNdbError().status == NdbError::TemporaryError);
- if (ret == -1)
- ERR_RETURN(ndb->getNdbError());
+ int retry_sleep= 30; /* 30 milliseconds, transaction */
+ for (;;)
+ {
+ if (ndb->getAutoIncrementValue((const NDBTAB *) m_table,
+ auto_value, 1) == -1)
+ {
+ if (--retries &&
+ ndb->getNdbError().status == NdbError::TemporaryError);
+ {
+ my_sleep(retry_sleep);
+ continue;
+ }
+ ERR_RETURN(ndb->getNdbError());
+ }
+ break;
+ }
if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value))
ERR_RETURN(op->getNdbError());
}
@@ -4855,22 +4863,27 @@ ulonglong ha_ndbcluster::get_auto_increment()
m_rows_to_insert - m_rows_inserted :
((m_rows_to_insert > m_autoincrement_prefetch) ?
m_rows_to_insert : m_autoincrement_prefetch));
- int ret;
uint retries= NDB_AUTO_INCREMENT_RETRIES;
- do {
- ret=
- m_skip_auto_increment ?
- ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) :
- ndb->getAutoIncrementValue((const NDBTAB *) m_table, auto_value, cache_size);
- } while (ret == -1 &&
- --retries &&
- ndb->getNdbError().status == NdbError::TemporaryError);
- if (ret == -1)
- {
- const NdbError err= ndb->getNdbError();
- sql_print_error("Error %lu in ::get_auto_increment(): %s",
- (ulong) err.code, err.message);
- DBUG_RETURN(~(ulonglong) 0);
+ int retry_sleep= 30; /* 30 milliseconds, transaction */
+ for (;;)
+ {
+ if (m_skip_auto_increment &&
+ ndb->readAutoIncrementValue((const NDBTAB *) m_table, auto_value) ||
+ ndb->getAutoIncrementValue((const NDBTAB *) m_table,
+ auto_value, cache_size))
+ {
+ if (--retries &&
+ ndb->getNdbError().status == NdbError::TemporaryError);
+ {
+ my_sleep(retry_sleep);
+ continue;
+ }
+ const NdbError err= ndb->getNdbError();
+ sql_print_error("Error %lu in ::get_auto_increment(): %s",
+ (ulong) err.code, err.message);
+ DBUG_RETURN(~(ulonglong) 0);
+ }
+ break;
}
DBUG_RETURN((longlong)auto_value);
}
@@ -5011,27 +5024,36 @@ int ha_ndbcluster::open(const char *name, int mode, uint test_if_locked)
set_dbname(name);
set_tabname(name);
- if (check_ndb_connection()) {
- free_share(m_share); m_share= 0;
- DBUG_RETURN(HA_ERR_NO_CONNECTION);
+ if ((res= check_ndb_connection()) ||
+ (res= get_metadata(name)))
+ {
+ free_share(m_share);
+ m_share= 0;
+ DBUG_RETURN(res);
}
-
- res= get_metadata(name);
- if (!res)
+ while (1)
{
Ndb *ndb= get_ndb();
if (ndb->setDatabaseName(m_dbname))
{
- ERR_RETURN(ndb->getNdbError());
+ res= ndb_to_mysql_error(&ndb->getNdbError());
+ break;
}
struct Ndb_statistics stat;
res= ndb_get_table_statistics(NULL, false, ndb, m_tabname, &stat);
records= stat.row_count;
if(!res)
res= info(HA_STATUS_CONST);
+ break;
}
-
- DBUG_RETURN(res);
+ if (res)
+ {
+ free_share(m_share);
+ m_share= 0;
+ release_metadata();
+ DBUG_RETURN(res);
+ }
+ DBUG_RETURN(0);
}