diff options
author | unknown <mskold@mysql.com> | 2005-04-13 12:42:23 +0200 |
---|---|---|
committer | unknown <mskold@mysql.com> | 2005-04-13 12:42:23 +0200 |
commit | 9faf085b9f831e8bb77ba106d8561b0b0baafdc6 (patch) | |
tree | 0224f76d32d84b634e8b9d1f689a2161881682e9 /sql/ha_ndbcluster.cc | |
parent | cde615c9cbff404b6a6c82a1ab7a6bcb8742b88e (diff) | |
download | mariadb-git-9faf085b9f831e8bb77ba106d8561b0b0baafdc6.tar.gz |
Fix for bug#9813: Test 'ndb_basic': Autoincrement fails in 64 bit
Diffstat (limited to 'sql/ha_ndbcluster.cc')
-rw-r--r-- | sql/ha_ndbcluster.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 7025ac2cd1a..fc1e838fbd2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1854,7 +1854,7 @@ int ha_ndbcluster::write_row(byte *record) m_rows_inserted++; no_uncommitted_rows_update(1); m_bulk_insert_not_flushed= TRUE; - if ((m_rows_to_insert == 1) || + if ((m_rows_to_insert == (ha_rows) 1) || ((m_rows_inserted % m_bulk_insert_rows) == 0) || set_blob_value) { @@ -2919,8 +2919,12 @@ void ha_ndbcluster::start_bulk_insert(ha_rows rows) DBUG_ENTER("start_bulk_insert"); DBUG_PRINT("enter", ("rows: %d", (int)rows)); - m_rows_inserted= 0; - m_rows_to_insert= rows; + m_rows_inserted= (ha_rows) 0; + if (rows == (ha_rows) 0) + /* We don't know how many will be inserted, guess */ + m_rows_to_insert= m_autoincrement_prefetch; + else + m_rows_to_insert= rows; /* Calculate how many rows that should be inserted @@ -2954,7 +2958,7 @@ int ha_ndbcluster::end_bulk_insert() // Send rows to NDB DBUG_PRINT("info", ("Sending inserts to NDB, "\ "rows_inserted:%d, bulk_insert_rows: %d", - m_rows_inserted, m_bulk_insert_rows)); + (int) m_rows_inserted, (int) m_bulk_insert_rows)); m_bulk_insert_not_flushed= FALSE; if (execute_no_commit(this,trans) != 0) { no_uncommitted_rows_execute_failure(); @@ -2962,8 +2966,8 @@ int ha_ndbcluster::end_bulk_insert() } } - m_rows_inserted= 0; - m_rows_to_insert= 1; + m_rows_inserted= (ha_rows) 0; + m_rows_to_insert= (ha_rows) 1; DBUG_RETURN(error); } @@ -3152,7 +3156,8 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) // store thread specific data first to set the right context m_force_send= thd->variables.ndb_force_send; m_ha_not_exact_count= !thd->variables.ndb_use_exact_count; - m_autoincrement_prefetch= thd->variables.ndb_autoincrement_prefetch_sz; + m_autoincrement_prefetch= + (ha_rows) thd->variables.ndb_autoincrement_prefetch_sz; if (!thd->transaction.on) m_transaction_on= FALSE; else @@ -3566,7 +3571,7 @@ static int create_ndb_column(NDBCOL &col, static void ndb_set_fragmentation(NDBTAB &tab, TABLE *form, uint pk_length) { - if (form->max_rows == 0) /* default setting, don't set fragmentation */ + if (form->max_rows == (ha_rows) 0) /* default setting, don't set fragmentation */ return; /** * get the number of fragments right @@ -3929,7 +3934,12 @@ longlong ha_ndbcluster::get_auto_increment() DBUG_ENTER("get_auto_increment"); DBUG_PRINT("enter", ("m_tabname: %s", m_tabname)); Ndb *ndb= get_ndb(); + + if (m_rows_inserted > m_rows_to_insert) + /* We guessed too low */ + m_rows_to_insert+= m_autoincrement_prefetch; int cache_size= + (int) (m_rows_to_insert - m_rows_inserted < m_autoincrement_prefetch) ? m_rows_to_insert - m_rows_inserted : (m_rows_to_insert > m_autoincrement_prefetch) ? @@ -3964,9 +3974,9 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_primary_key_update(FALSE), m_retrieve_all_fields(FALSE), m_retrieve_primary_key(FALSE), - m_rows_to_insert(1), - m_rows_inserted(0), - m_bulk_insert_rows(1024), + m_rows_to_insert((ha_rows) 1), + m_rows_inserted((ha_rows) 0), + m_bulk_insert_rows((ha_rows) 1024), m_bulk_insert_not_flushed(FALSE), m_ops_pending(0), m_skip_auto_increment(TRUE), @@ -3976,7 +3986,7 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg): m_dupkey((uint) -1), m_ha_not_exact_count(FALSE), m_force_send(TRUE), - m_autoincrement_prefetch(32), + m_autoincrement_prefetch((ha_rows) 32), m_transaction_on(TRUE), m_use_local_query_cache(FALSE) { |