Commit abe6457e authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint

into  whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
parents 9e1777a8 fe7ce4f7
......@@ -382,7 +382,7 @@ create table t1 (a int primary key) engine=ndb;
select * from t1;
a
select * from t1;
ERROR HY000: Can't lock file (errno: 4009)
ERROR HY000: Can't lock file (errno: 157)
use test;
drop database test_only_ndb_tables;
CREATE TABLE t9 (
......
-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/ndb_default_cluster.inc
-- source include/not_embedded.inc
......@@ -7,6 +8,11 @@
drop table if exists t1, t2;
--enable_warnings
# Workaround for Bug#27644
# ndb: connecting api node/mysqld may "steal" node_id from running mysqld
# - let ndb_waiter use a fixed node id so "steal" cannot happen
--let connect_str = "nodeid=6;$NDB_CONNECTSTRING"
#
# Transaction ongoing while cluster is restarted
#
......@@ -17,7 +23,7 @@ begin;
insert into t1 values (1);
--exec $NDB_MGM --no-defaults -e "all restart" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
--error 1297
insert into t1 values (2);
......@@ -35,7 +41,7 @@ insert into t2 values (1,1),(2,1),(3,1),(4,1),(5,1),(6,1),(7,1),(8,1),(9,1),(10,
select * from t2 order by a limit 3;
--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
--connection server2
create table t2 (a int key) engine=ndbcluster;
......@@ -49,7 +55,7 @@ select * from t2 order by a limit 3;
select * from t2 order by a limit 3;
--exec $NDB_MGM --no-defaults -e "all restart -i" >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults >> $NDB_TOOLS_OUTPUT
--exec $NDB_TOOLS_DIR/ndb_waiter --no-defaults -c $connect_str >> $NDB_TOOLS_OUTPUT
--connection server1
show tables;
......
......@@ -155,6 +155,8 @@ TCP_Transporter::initTransporter() {
void
TCP_Transporter::setSocketOptions(){
int sockOptKeepAlive = 1;
if (setsockopt(theSocket, SOL_SOCKET, SO_RCVBUF,
(char*)&sockOptRcvBufSize, sizeof(sockOptRcvBufSize)) < 0) {
#ifdef DEBUG_TRANSPORTER
......@@ -169,6 +171,11 @@ TCP_Transporter::setSocketOptions(){
#endif
}//if
if (setsockopt(theSocket, SOL_SOCKET, SO_KEEPALIVE,
(char*)&sockOptKeepAlive, sizeof(sockOptKeepAlive)) < 0) {
ndbout_c("The setsockopt SO_KEEPALIVE error code = %d", InetErrno);
}//if
//-----------------------------------------------
// Set the TCP_NODELAY option so also small packets are sent
// as soon as possible
......
......@@ -452,6 +452,13 @@ Uint32 Dbtup::leafPageRangeFull(Fragrecord* const regFragPtr, PageRangePtr curr
ptrCheckGuard(parentPageRangePtr, cnoOfPageRangeRec, pageRange);
if (parentPageRangePtr.p->currentIndexPos < 3) {
ljam();
if (c_noOfFreePageRanges < tiprNoLevels)
{
ljam();
return RNIL;
}//if
/* ---------------------------------------------------------------- */
/* WE HAVE FOUND AN EMPTY ENTRY IN A PAGE RANGE RECORD. */
/* ALLOCATE A NEW PAGE RANGE RECORD, FILL IN THE START RANGE, */
......
......@@ -2026,6 +2026,9 @@ CommandInterpreter::executeRestart(Vector<BaseString> &command_list,
return -1;
}
if (!nostart)
ndbout_c("Shutting down nodes with \"-n, no start\" option, to subsequently start the nodes.");
result= ndb_mgm_restart3(m_mgmsrv, no_of_nodes, node_ids,
initialstart, nostart, abort, &need_disconnect);
......
......@@ -657,7 +657,7 @@ InitConfigFileParser::store_in_properties(Vector<struct my_option>& options,
if (options[i].var_type == GET_INT)
ctx.m_currentSection->put(options[i].name, (Uint32)value_int);
else
ctx.m_currentSection->put(options[i].name, value_int);
ctx.m_currentSection->put64(options[i].name, value_int);
}
}
return true;
......
......@@ -328,12 +328,18 @@ NdbScanFilterImpl::cond_col(Interpreter::UnaryCondition op, Uint32 AttrId){
int
NdbScanFilter::isnull(int AttrId){
return m_impl.cond_col(Interpreter::IS_NULL, AttrId);
if(m_impl.m_negative == 1)
return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId);
else
return m_impl.cond_col(Interpreter::IS_NULL, AttrId);
}
int
NdbScanFilter::isnotnull(int AttrId){
return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId);
if(m_impl.m_negative == 1)
return m_impl.cond_col(Interpreter::IS_NULL, AttrId);
else
return m_impl.cond_col(Interpreter::IS_NOT_NULL, AttrId);
}
struct tab3 {
......
......@@ -67,6 +67,7 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_delete_all");
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
......
......@@ -69,6 +69,7 @@ int main(int argc, char** argv){
return NDBT_ProgramExit(NDBT_WRONGARGS);
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_desc");
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
......
......@@ -61,6 +61,7 @@ int main(int argc, char** argv){
}
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_drop_index");
if(con.connect(12, 5, 1) != 0)
{
return NDBT_ProgramExit(NDBT_FAILED);
......
......@@ -61,6 +61,7 @@ int main(int argc, char** argv){
}
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_drop_table");
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
......
......@@ -219,6 +219,7 @@ int main(int argc, char** argv){
_tabname = argv[0];
ndb_cluster_connection = new Ndb_cluster_connection(opt_connect_str);
ndb_cluster_connection->set_name("ndb_show_tables");
if (ndb_cluster_connection->connect(12,5,1))
fatal("Unable to connect to management server.");
if (ndb_cluster_connection->wait_until_ready(30,0) < 0)
......
......@@ -108,6 +108,7 @@ int main(int argc, char** argv){
}
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_select_all");
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
......
......@@ -83,6 +83,7 @@ int main(int argc, char** argv){
}
Ndb_cluster_connection con(opt_connect_str);
con.set_name("ndb_select_count");
if(con.connect(12, 5, 1) != 0)
{
ndbout << "Unable to connect to management server." << endl;
......
......@@ -203,6 +203,8 @@ static const err_code_mapping err_map[]=
{ 284, HA_ERR_TABLE_DEF_CHANGED, 0 },
{4009, HA_ERR_NO_CONNECTION, 1 },
{ 0, 1, 0 },
{ -1, -1, 1 }
......@@ -5068,14 +5070,11 @@ int ndbcluster_table_exists_in_engine(THD* thd, const char *db, const char *name
dict->invalidateTable(name);
if (!(tab= dict->getTable(name)))
{
const NdbError err= dict->getNdbError();
if (err.code == 709)
DBUG_RETURN(0);
ERR_RETURN(err);
ERR_RETURN(dict->getNdbError());
}
DBUG_PRINT("info", ("Found table %s", tab->getName()));
DBUG_RETURN(1);
DBUG_RETURN(HA_ERR_TABLE_EXIST);
}
......@@ -5260,7 +5259,7 @@ int ndbcluster_find_files(THD *thd,const char *db,const char *path,
DBUG_PRINT("info", ("%s existed on disk", name));
// The .ndb file exists on disk, but it's not in list of tables in ndb
// Verify that handler agrees table is gone.
if (ndbcluster_table_exists_in_engine(thd, db, file_name) == 0)
if (ndbcluster_table_exists_in_engine(thd, db, file_name) == HA_ERR_NO_SUCH_TABLE)
{
DBUG_PRINT("info", ("NDB says %s does not exists", file_name));
it.remove();
......@@ -6695,7 +6694,8 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
DBUG_RETURN(NULL);
}
List<NDB_SHARE> util_open_tables;
uint share_list_size= 0;
NDB_SHARE **share_list= NULL;
set_timespec(abstime, 0);
for (;;)
{
......@@ -6725,7 +6725,22 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
/* Lock mutex and fill list with pointers to all open tables */
NDB_SHARE *share;
pthread_mutex_lock(&ndbcluster_mutex);
for (uint i= 0; i < ndbcluster_open_tables.records; i++)
uint i, record_count= ndbcluster_open_tables.records;
if (share_list_size < record_count)
{
NDB_SHARE ** new_share_list= new NDB_SHARE * [record_count];
if (!new_share_list)
{
sql_print_warning("ndb util thread: malloc failure, "
"query cache not maintained properly");
pthread_mutex_unlock(&ndbcluster_mutex);
goto next; // At least do not crash
}
delete [] share_list;
share_list_size= record_count;
share_list= new_share_list;
}
for (i= 0; i < record_count; i++)
{
share= (NDB_SHARE *)hash_element(&ndbcluster_open_tables, i);
share->use_count++; /* Make sure the table can't be closed */
......@@ -6734,14 +6749,14 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
i, share->table_name, share->use_count));
/* Store pointer to table */
util_open_tables.push_back(share);
share_list[i]= share;
}
pthread_mutex_unlock(&ndbcluster_mutex);
/* Iterate through the open files list */
List_iterator_fast<NDB_SHARE> it(util_open_tables);
while ((share= it++))
/* Iterate through the open files list */
for (i= 0; i < record_count; i++)
{
share= share_list[i];
/* Split tab- and dbname */
char buf[FN_REFLEN];
char *tabname, *db;
......@@ -6790,10 +6805,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
/* Decrease the use count and possibly free share */
free_share(share);
}
/* Clear the list of open tables */
util_open_tables.empty();
next:
/* Calculate new time to wake up */
int secs= 0;
int msecs= ndb_cache_check_time;
......@@ -6816,6 +6828,8 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
}
}
if (share_list)
delete [] share_list;
thd->cleanup();
delete thd;
delete ndb;
......
......@@ -2438,14 +2438,14 @@ ha_find_files(THD *thd,const char *db,const char *path,
Ask handler if the table exists in engine
RETURN
0 Table does not exist
1 Table exists
# Error code
HA_ERR_NO_SUCH_TABLE Table does not exist
HA_ERR_TABLE_EXIST Table exists
# Error code
*/
int ha_table_exists_in_engine(THD* thd, const char* db, const char* name)
{
int error= 0;
int error= HA_ERR_NO_SUCH_TABLE;
DBUG_ENTER("ha_table_exists_in_engine");
DBUG_PRINT("enter", ("db: %s, name: %s", db, name));
#ifdef HAVE_NDBCLUSTER_DB
......
......@@ -1697,6 +1697,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
alias);
DBUG_RETURN(FALSE);
}
DBUG_PRINT("info",("1"));
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias);
DBUG_RETURN(TRUE);
}
......@@ -1707,6 +1708,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
{
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
goto warn;
DBUG_PRINT("info",("2"));
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto end;
}
......@@ -1725,14 +1727,25 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name,
{
bool create_if_not_exists =
create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS;
if (ha_table_exists_in_engine(thd, db, table_name))
int retcode = ha_table_exists_in_engine(thd, db, table_name);
DBUG_PRINT("info", ("exists_in_engine: %u",retcode));
switch (retcode)
{
DBUG_PRINT("info", ("Table with same name already existed in handler"));
case HA_ERR_NO_SUCH_TABLE:
/* Normal case, no table exists. we can go and create it */
break;
case HA_ERR_TABLE_EXIST:
DBUG_PRINT("info", ("Table existed in handler"));
if (create_if_not_exists)
goto warn;
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto end;
if (create_if_not_exists)
goto warn;
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto end;
break;
default:
DBUG_PRINT("info", ("error: %u from storage engine", retcode));
my_error(retcode, MYF(0),table_name);
goto end;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment