summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <tomas@poseidon.ndb.mysql.com>2004-11-23 09:51:39 +0000
committerunknown <tomas@poseidon.ndb.mysql.com>2004-11-23 09:51:39 +0000
commiteeca93750d987ca55cadb97b33bdb67fed8aefac (patch)
tree95f62a320d8e2c480307088b4503d6135e837889 /sql
parentf57d5412e47aa85941ea03ec3e63b017dac8c1ba (diff)
parent1ffdb9e81e5ab46ba809829c11ca1aafdc238db8 (diff)
downloadmariadb-git-eeca93750d987ca55cadb97b33bdb67fed8aefac.tar.gz
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1
into poseidon.ndb.mysql.com:/home/tomas/mysql-4.1 sql/ha_ndbcluster.cc: Auto merged sql/ha_ndbcluster.h: Auto merged sql/set_var.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_ndbcluster.cc33
-rw-r--r--sql/ha_ndbcluster.h2
-rw-r--r--sql/mysqld.cc13
-rw-r--r--sql/set_var.cc6
-rw-r--r--sql/sql_class.h1
5 files changed, 41 insertions, 14 deletions
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 77cc7ce5bc4..8d82f60ae85 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -1268,7 +1268,7 @@ inline int ha_ndbcluster::next_result(byte *buf)
m_ops_pending= 0;
m_blobs_pending= FALSE;
}
- check= cursor->nextResult(contact_ndb);
+ check= cursor->nextResult(contact_ndb, m_force_send);
if (check == 0)
{
// One more record found
@@ -1561,7 +1561,7 @@ int ha_ndbcluster::ordered_index_scan(const key_range *start_key,
DBUG_ASSERT(op->getSorted() == sorted);
DBUG_ASSERT(op->getLockMode() ==
(NdbOperation::LockMode)get_ndb_lock_type(m_lock.type));
- if(op->reset_bounds())
+ if(op->reset_bounds(m_force_send))
DBUG_RETURN(ndb_err(m_active_trans));
}
@@ -2388,7 +2388,7 @@ int ha_ndbcluster::index_last(byte *buf)
int res;
if((res= ordered_index_scan(0, 0, TRUE, buf)) == 0){
NdbResultSet *cursor= m_active_cursor;
- while((res= cursor->nextResult(TRUE)) == 0);
+ while((res= cursor->nextResult(TRUE, m_force_send)) == 0);
if(res == 1){
unpack_record(buf);
table->status= 0;
@@ -2474,7 +2474,7 @@ int ha_ndbcluster::rnd_init(bool scan)
{
if (!scan)
DBUG_RETURN(1);
- int res= cursor->restart();
+ int res= cursor->restart(m_force_send);
DBUG_ASSERT(res == 0);
}
index_init(table->primary_key);
@@ -2505,7 +2505,7 @@ int ha_ndbcluster::close_scan()
m_ops_pending= 0;
}
- cursor->close();
+ cursor->close(m_force_send);
m_active_cursor= NULL;
DBUG_RETURN(0);
}
@@ -3025,6 +3025,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
m_transaction_on= FALSE;
else
m_transaction_on= thd->variables.ndb_use_transactions;
+ m_use_local_query_cache= thd->variables.ndb_use_local_query_cache;
m_active_trans= thd->transaction.all.ndb_tid ?
(NdbConnection*)thd->transaction.all.ndb_tid:
@@ -3749,7 +3750,8 @@ ha_ndbcluster::ha_ndbcluster(TABLE *table_arg):
m_ha_not_exact_count(FALSE),
m_force_send(TRUE),
m_autoincrement_prefetch(32),
- m_transaction_on(TRUE)
+ m_transaction_on(TRUE),
+ m_use_local_query_cache(FALSE)
{
int i;
@@ -4436,7 +4438,7 @@ bool ha_ndbcluster::low_byte_first() const
}
bool ha_ndbcluster::has_transactions()
{
- return TRUE;
+ return m_transaction_on;
}
const char* ha_ndbcluster::index_type(uint key_number)
{
@@ -4453,7 +4455,10 @@ const char* ha_ndbcluster::index_type(uint key_number)
}
uint8 ha_ndbcluster::table_cache_type()
{
- return HA_CACHE_TBL_NOCACHE;
+ if (m_use_local_query_cache)
+ return HA_CACHE_TBL_TRANSACT;
+ else
+ return HA_CACHE_TBL_NOCACHE;
}
/*
@@ -4621,13 +4626,12 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
{
DBUG_ENTER("ndb_get_table_statistics");
DBUG_PRINT("enter", ("table: %s", table));
-
+ NdbConnection* pTrans= ndb->startTransaction();
do
{
- NdbConnection* pTrans= ndb->startTransaction();
if (pTrans == NULL)
break;
-
+
NdbScanOperation* pOp= pTrans->getNdbScanOperation(table);
if (pOp == NULL)
break;
@@ -4644,13 +4648,13 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&rows);
pOp->getValue(NdbDictionary::Column::COMMIT_COUNT, (char*)&commits);
- check= pTrans->execute(NoCommit);
+ check= pTrans->execute(NoCommit, AbortOnError, TRUE);
if (check == -1)
break;
Uint64 sum_rows= 0;
Uint64 sum_commits= 0;
- while((check= rs->nextResult(TRUE)) == 0)
+ while((check= rs->nextResult(TRUE, TRUE)) == 0)
{
sum_rows+= rows;
sum_commits+= commits;
@@ -4659,6 +4663,8 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
if (check == -1)
break;
+ rs->close(TRUE);
+
ndb->closeTransaction(pTrans);
if(row_count)
* row_count= sum_rows;
@@ -4668,6 +4674,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
DBUG_RETURN(0);
} while(0);
+ ndb->closeTransaction(pTrans);
DBUG_PRINT("exit", ("failed"));
DBUG_RETURN(-1);
}
diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h
index 1b49aca81e6..f6c712620c1 100644
--- a/sql/ha_ndbcluster.h
+++ b/sql/ha_ndbcluster.h
@@ -239,10 +239,12 @@ class ha_ndbcluster: public handler
char *m_blobs_buffer;
uint32 m_blobs_buffer_size;
uint m_dupkey;
+ // set from thread variables at external lock
bool m_ha_not_exact_count;
bool m_force_send;
ha_rows m_autoincrement_prefetch;
bool m_transaction_on;
+ bool m_use_local_query_cache;
void set_rec_per_key();
void records_update();
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 5033c42ac69..f7c89f6dde3 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2227,7 +2227,11 @@ extern "C" pthread_handler_decl(handle_shutdown,arg)
#endif
-const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0,0};
+const char *load_default_groups[]= {
+#ifdef HAVE_NDBCLUSTER_DB
+ "mysql_cluster",
+#endif
+ "mysqld","server",MYSQL_BASE_VERSION,0,0};
bool open_log(MYSQL_LOG *log, const char *hostname,
const char *opt_name, const char *extension,
@@ -3950,6 +3954,7 @@ enum options_mysqld
OPT_INNODB, OPT_ISAM,
OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, OPT_NDB_USE_EXACT_COUNT,
OPT_NDB_FORCE_SEND, OPT_NDB_AUTOINCREMENT_PREFETCH_SZ,
+ OPT_NDB_USE_LOCAL_QUERY_CACHE,
OPT_SKIP_SAFEMALLOC,
OPT_TEMP_POOL, OPT_TX_ISOLATION,
OPT_SKIP_STACK_TRACE, OPT_SKIP_SYMLINKS,
@@ -4409,6 +4414,12 @@ Disable with --skip-ndbcluster (will save memory).",
(gptr*) &global_system_variables.ndb_use_exact_count,
(gptr*) &global_system_variables.ndb_use_exact_count,
0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
+ {"ndb_use_local_query_cache", OPT_NDB_USE_LOCAL_QUERY_CACHE,
+ "Use local query cache, note that this cache will _not_ "
+ "be invalidated if data is updated through other mysql servers",
+ (gptr*) &global_system_variables.ndb_use_local_query_cache,
+ (gptr*) &global_system_variables.ndb_use_local_query_cache,
+ 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"new", 'n', "Use very new possible 'unsafe' functions.",
(gptr*) &global_system_variables.new_mode,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 2031ac15412..a040e8b2ba4 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -371,6 +371,9 @@ sys_var_thd_bool
sys_ndb_use_exact_count("ndb_use_exact_count",
&SV::ndb_use_exact_count);
sys_var_thd_bool
+sys_ndb_use_local_query_cache("ndb_use_local_query_cache",
+ &SV::ndb_use_local_query_cache);
+sys_var_thd_bool
sys_ndb_use_transactions("ndb_use_transactions",
&SV::ndb_use_transactions);
// ndb server global variable settings
@@ -634,6 +637,7 @@ sys_var *sys_variables[]=
&sys_ndb_autoincrement_prefetch_sz,
&sys_ndb_force_send,
&sys_ndb_use_exact_count,
+ &sys_ndb_use_local_query_cache,
&sys_ndb_use_transactions,
#endif
&sys_unique_checks,
@@ -801,6 +805,8 @@ struct show_var_st init_vars[]= {
(char*) &sys_ndb_autoincrement_prefetch_sz, SHOW_SYS},
{sys_ndb_force_send.name, (char*) &sys_ndb_force_send, SHOW_SYS},
{sys_ndb_use_exact_count.name,(char*) &sys_ndb_use_exact_count, SHOW_SYS},
+ {sys_ndb_use_local_query_cache.name,
+ (char*) &sys_ndb_use_local_query_cache, SHOW_SYS},
{sys_ndb_use_transactions.name,(char*) &sys_ndb_use_transactions, SHOW_SYS},
#endif
{sys_net_buffer_length.name,(char*) &sys_net_buffer_length, SHOW_SYS},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index d0d9afc7746..06975730195 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -403,6 +403,7 @@ struct system_variables
ulong ndb_autoincrement_prefetch_sz;
my_bool ndb_force_send;
my_bool ndb_use_exact_count;
+ my_bool ndb_use_local_query_cache;
my_bool ndb_use_transactions;
#endif /* HAVE_NDBCLUSTER_DB */
my_bool old_passwords;