Commit d9f2d135 authored by unknown's avatar unknown

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

into  mysql.com:/usr/home/ram/work/5.0.b16511

parents 79112423 5b9cdaa4
...@@ -445,3 +445,14 @@ t1 CREATE TABLE `t1` ( ...@@ -445,3 +445,14 @@ t1 CREATE TABLE `t1` (
FULLTEXT KEY `a` (`a`) FULLTEXT KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
a MATCH(a) AGAINST('test1 test')
test1 0.68526661396027
EXECUTE stmt;
a MATCH(a) AGAINST('test1 test')
test1 0.68526661396027
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
...@@ -203,3 +203,18 @@ NULL ...@@ -203,3 +203,18 @@ NULL
Warnings: Warnings:
Error 1365 Division by 0 Error 1365 Division by 0
set sql_mode=''; set sql_mode='';
select round(111,-10);
round(111,-10)
0
select round(-5000111000111000155,-1);
round(-5000111000111000155,-1)
-5000111000111000160
select round(15000111000111000155,-1);
round(15000111000111000155,-1)
15000111000111000160
select truncate(-5000111000111000155,-1);
truncate(-5000111000111000155,-1)
-5000111000111000150
select truncate(15000111000111000155,-1);
truncate(15000111000111000155,-1)
15000111000111000150
...@@ -626,3 +626,12 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ; ...@@ -626,3 +626,12 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ;
id month year code id month year code
1 4 2004 12 1 4 2004 12
drop table t1; drop table t1;
create table t1 (a int primary key, b varchar(1000) not null, unique key (b))
engine=ndb charset=utf8;
insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200));
insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200));
ERROR 23000: Duplicate entry '2' for key 1
select a, sha1(b) from t1;
a sha1(b)
1 08f5d02c8b8bc244f275bdfc22c42c5cab0d9d7d
drop table t1;
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
ERROR 23000: Can't write; duplicate key in table 't1'
DROP TABLE t1;
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
word
Aarhus
Aarhus
Aaron
Aaron
Ababa
Ababa
aback
aback
abaft
abaft
abandon
abandon
abandoned
abandoned
abandoning
abandoning
abandonment
abandonment
abandons
abandons
abase
abased
abasement
abasements
abases
abash
abashed
abashes
abashing
abasing
abate
abated
abatement
abatements
abater
abates
abating
Abba
abbe
abbey
abbeys
abbot
abbots
Abbott
abbreviate
abbreviated
abbreviates
abbreviating
abbreviation
abbreviations
Abby
abdomen
abdomens
abdominal
abduct
abducted
abduction
abductions
abductor
abductors
abducts
Abe
abed
Abel
Abelian
Abelson
Aberdeen
Abernathy
aberrant
aberration
DROP TABLE t1;
...@@ -365,4 +365,16 @@ CREATE TABLE t1 (a VARCHAR(10000), FULLTEXT(a)); ...@@ -365,4 +365,16 @@ CREATE TABLE t1 (a VARCHAR(10000), FULLTEXT(a));
SHOW CREATE TABLE t1; SHOW CREATE TABLE t1;
DROP TABLE t1; DROP TABLE t1;
#
# BUG#14496: Crash or strange results with prepared statement,
# MATCH and FULLTEXT
#
CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a));
INSERT INTO t1 VALUES('test'),('test1'),('test');
PREPARE stmt from "SELECT a, MATCH(a) AGAINST('test1 test') FROM t1 WHERE MATCH(a) AGAINST('test1 test')";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
# End of 4.1 tests # End of 4.1 tests
...@@ -141,3 +141,17 @@ select log(2,-1); ...@@ -141,3 +141,17 @@ select log(2,-1);
select log(-2,1); select log(-2,1);
set sql_mode=''; set sql_mode='';
#
# Bug #8461 truncate() and round() return false results 2nd argument negative.
#
# round(a,-b) log_10(b) > a
select round(111,-10);
# round on bigint
select round(-5000111000111000155,-1);
# round on unsigned bigint
select round(15000111000111000155,-1);
# truncate on bigint
select truncate(-5000111000111000155,-1);
# truncate on unsigned bigint
select truncate(15000111000111000155,-1);
...@@ -309,4 +309,18 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ; ...@@ -309,4 +309,18 @@ select * from t1 where code = '12' and month = 4 and year = 2004 ;
drop table t1; drop table t1;
# bug#15918 Unique Key Limit in NDB Engine
create table t1 (a int primary key, b varchar(1000) not null, unique key (b))
engine=ndb charset=utf8;
insert into t1 values (1, repeat(_utf8 0xe288ab6474, 200));
--error 1062
insert into t1 values (2, repeat(_utf8 0xe288ab6474, 200));
select a, sha1(b) from t1;
# perl -e 'print pack("H2000","e288ab6474"x200)' | sha1sum
drop table t1;
# End of 4.1 tests # End of 4.1 tests
-- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#
# Basic test for different types of loading data
#
# should give duplicate key
CREATE TABLE t1 (word CHAR(20) NOT NULL PRIMARY KEY) ENGINE=NDB;
--error 1022
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
DROP TABLE t1;
# now without a primary key we should be ok
CREATE TABLE t1 (word CHAR(20) NOT NULL) ENGINE=NDB;
LOAD DATA INFILE '../../std_data/words.dat' INTO TABLE t1 ;
SELECT * FROM t1 ORDER BY word;
DROP TABLE t1;
# End of 4.1 tests
...@@ -1446,7 +1446,7 @@ private: ...@@ -1446,7 +1446,7 @@ private:
Uint32 cexcPrevforward; Uint32 cexcPrevforward;
Uint32 clocalkey[32]; Uint32 clocalkey[32];
union { union {
Uint32 ckeys[2048]; Uint32 ckeys[2048 * MAX_XFRM_MULTIPLY];
Uint64 ckeys_align; Uint64 ckeys_align;
}; };
......
...@@ -63,8 +63,10 @@ extern "C" void handler_sigusr1(int signum); // child signalling failed restart ...@@ -63,8 +63,10 @@ extern "C" void handler_sigusr1(int signum); // child signalling failed restart
void systemInfo(const Configuration & conf, void systemInfo(const Configuration & conf,
const LogLevel & ll); const LogLevel & ll);
static FILE *child_info_file_r= 0; // These are used already before fork if fetch_configuration() fails
static FILE *child_info_file_w= 0; // (e.g. Unable to alloc node id). Set them to something reasonable.
static FILE *child_info_file_r= stdin;
static FILE *child_info_file_w= stdout;
static void writeChildInfo(const char *token, int val) static void writeChildInfo(const char *token, int val)
{ {
...@@ -270,8 +272,8 @@ int main(int argc, char** argv) ...@@ -270,8 +272,8 @@ int main(int argc, char** argv)
#ifndef NDB_WIN32 #ifndef NDB_WIN32
signal(SIGUSR1, handler_sigusr1); signal(SIGUSR1, handler_sigusr1);
pid_t child; pid_t child = -1;
while (1) while (! theConfig->getForegroundMode()) // the cond is const
{ {
// setup reporting between child and parent // setup reporting between child and parent
int filedes[2]; int filedes[2];
...@@ -393,8 +395,10 @@ int main(int argc, char** argv) ...@@ -393,8 +395,10 @@ int main(int argc, char** argv)
if (child >= 0) if (child >= 0)
g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid());
else else if (child > 0)
g_eventLogger.info("Ndb pid: %d", getpid()); g_eventLogger.info("Ndb pid: %d", getpid());
else
g_eventLogger.info("Ndb started in foreground");
#else #else
g_eventLogger.info("Ndb started"); g_eventLogger.info("Ndb started");
#endif #endif
...@@ -569,10 +573,7 @@ catchsigs(bool ignore){ ...@@ -569,10 +573,7 @@ catchsigs(bool ignore){
#ifdef SIGPOLL #ifdef SIGPOLL
SIGPOLL, SIGPOLL,
#endif #endif
SIGSEGV, SIGSEGV
#ifdef SIGTRAP
SIGTRAP
#endif
}; };
static const int signals_ignore[] = { static const int signals_ignore[] = {
...@@ -586,6 +587,11 @@ catchsigs(bool ignore){ ...@@ -586,6 +587,11 @@ catchsigs(bool ignore){
handler_register(signals_error[i], handler_error, ignore); handler_register(signals_error[i], handler_error, ignore);
for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++) for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++)
handler_register(signals_ignore[i], SIG_IGN, ignore); handler_register(signals_ignore[i], SIG_IGN, ignore);
#ifdef SIGTRAP
Configuration* theConfig = globalEmulatorData.theConfiguration;
if (! theConfig->getForegroundMode())
handler_register(SIGTRAP, handler_error, ignore);
#endif
#endif #endif
} }
......
...@@ -48,11 +48,13 @@ extern EventLogger g_eventLogger; ...@@ -48,11 +48,13 @@ extern EventLogger g_eventLogger;
enum ndbd_options { enum ndbd_options {
OPT_INITIAL = NDB_STD_OPTIONS_LAST, OPT_INITIAL = NDB_STD_OPTIONS_LAST,
OPT_NODAEMON OPT_NODAEMON,
OPT_FOREGROUND
}; };
NDB_STD_OPTS_VARS; NDB_STD_OPTS_VARS;
static int _daemon, _no_daemon, _initial, _no_start; // XXX should be my_bool ???
static int _daemon, _no_daemon, _foreground, _initial, _no_start;
/** /**
* Arguments to NDB process * Arguments to NDB process
*/ */
...@@ -75,6 +77,11 @@ static struct my_option my_long_options[] = ...@@ -75,6 +77,11 @@ static struct my_option my_long_options[] =
"Do not start ndbd as daemon, provided for testing purposes", "Do not start ndbd as daemon, provided for testing purposes",
(gptr*) &_no_daemon, (gptr*) &_no_daemon, 0, (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "foreground", OPT_FOREGROUND,
"Run real ndbd in foreground, provided for debugging purposes"
" (implies --nodaemon)",
(gptr*) &_foreground, (gptr*) &_foreground, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
static void short_usage_sub(void) static void short_usage_sub(void)
...@@ -103,13 +110,14 @@ Configuration::init(int argc, char** argv) ...@@ -103,13 +110,14 @@ Configuration::init(int argc, char** argv)
ndb_std_get_one_option))) ndb_std_get_one_option)))
exit(ho_error); exit(ho_error);
if (_no_daemon) { if (_no_daemon || _foreground) {
_daemon= 0; _daemon= 0;
} }
DBUG_PRINT("info", ("no_start=%d", _no_start)); DBUG_PRINT("info", ("no_start=%d", _no_start));
DBUG_PRINT("info", ("initial=%d", _initial)); DBUG_PRINT("info", ("initial=%d", _initial));
DBUG_PRINT("info", ("daemon=%d", _daemon)); DBUG_PRINT("info", ("daemon=%d", _daemon));
DBUG_PRINT("info", ("foreground=%d", _foreground));
DBUG_PRINT("info", ("connect_str=%s", opt_connect_str)); DBUG_PRINT("info", ("connect_str=%s", opt_connect_str));
ndbSetOwnVersion(); ndbSetOwnVersion();
...@@ -131,6 +139,8 @@ Configuration::init(int argc, char** argv) ...@@ -131,6 +139,8 @@ Configuration::init(int argc, char** argv)
// Check daemon flag // Check daemon flag
if (_daemon) if (_daemon)
_daemonMode = true; _daemonMode = true;
if (_foreground)
_foregroundMode = true;
// Save programname // Save programname
if(argc > 0 && argv[0] != 0) if(argc > 0 && argv[0] != 0)
...@@ -151,6 +161,7 @@ Configuration::Configuration() ...@@ -151,6 +161,7 @@ Configuration::Configuration()
_backupPath = 0; _backupPath = 0;
_initialStart = false; _initialStart = false;
_daemonMode = false; _daemonMode = false;
_foregroundMode = false;
m_config_retriever= 0; m_config_retriever= 0;
m_clusterConfig= 0; m_clusterConfig= 0;
m_clusterConfigIter= 0; m_clusterConfigIter= 0;
......
...@@ -64,6 +64,7 @@ public: ...@@ -64,6 +64,7 @@ public:
bool getInitialStart() const; bool getInitialStart() const;
void setInitialStart(bool val); void setInitialStart(bool val);
bool getDaemonMode() const; bool getDaemonMode() const;
bool getForegroundMode() const;
const ndb_mgm_configuration_iterator * getOwnConfigIterator() const; const ndb_mgm_configuration_iterator * getOwnConfigIterator() const;
...@@ -105,7 +106,8 @@ private: ...@@ -105,7 +106,8 @@ private:
char * _connectString; char * _connectString;
Uint32 m_mgmd_port; Uint32 m_mgmd_port;
BaseString m_mgmd_host; BaseString m_mgmd_host;
bool _daemonMode; bool _daemonMode; // if not, angel in foreground
bool _foregroundMode; // no angel, raw ndbd in foreground
void calcSizeAlt(class ConfigValues * ); void calcSizeAlt(class ConfigValues * );
}; };
...@@ -140,4 +142,10 @@ Configuration::getDaemonMode() const { ...@@ -140,4 +142,10 @@ Configuration::getDaemonMode() const {
return _daemonMode; return _daemonMode;
} }
inline
bool
Configuration::getForegroundMode() const {
return _foregroundMode;
}
#endif #endif
...@@ -3116,9 +3116,26 @@ int ha_ndbcluster::end_bulk_insert() ...@@ -3116,9 +3116,26 @@ int ha_ndbcluster::end_bulk_insert()
"rows_inserted:%d, bulk_insert_rows: %d", "rows_inserted:%d, bulk_insert_rows: %d",
(int) m_rows_inserted, (int) m_bulk_insert_rows)); (int) m_rows_inserted, (int) m_bulk_insert_rows));
m_bulk_insert_not_flushed= FALSE; m_bulk_insert_not_flushed= FALSE;
if (execute_no_commit(this,trans) != 0) { if (m_transaction_on)
no_uncommitted_rows_execute_failure(); {
my_errno= error= ndb_err(trans); if (execute_no_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
}
}
else
{
if (execute_commit(this, trans) != 0)
{
no_uncommitted_rows_execute_failure();
my_errno= error= ndb_err(trans);
}
else
{
int res= trans->restart();
DBUG_ASSERT(res == 0);
}
} }
} }
...@@ -3274,8 +3291,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) ...@@ -3274,8 +3291,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
ERR_RETURN(ndb->getNdbError()); ERR_RETURN(ndb->getNdbError());
no_uncommitted_rows_reset(thd); no_uncommitted_rows_reset(thd);
thd_ndb->stmt= trans; thd_ndb->stmt= trans;
if (m_transaction_on) trans_register_ha(thd, FALSE, &ndbcluster_hton);
trans_register_ha(thd, FALSE, &ndbcluster_hton);
} }
else else
{ {
...@@ -3290,8 +3306,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type) ...@@ -3290,8 +3306,7 @@ int ha_ndbcluster::external_lock(THD *thd, int lock_type)
ERR_RETURN(ndb->getNdbError()); ERR_RETURN(ndb->getNdbError());
no_uncommitted_rows_reset(thd); no_uncommitted_rows_reset(thd);
thd_ndb->all= trans; thd_ndb->all= trans;
if (m_transaction_on) trans_register_ha(thd, TRUE, &ndbcluster_hton);
trans_register_ha(thd, TRUE, &ndbcluster_hton);
/* /*
If this is the start of a LOCK TABLE, a table look If this is the start of a LOCK TABLE, a table look
...@@ -5083,6 +5098,10 @@ uint ha_ndbcluster::max_supported_key_length() const ...@@ -5083,6 +5098,10 @@ uint ha_ndbcluster::max_supported_key_length() const
{ {
return NDB_MAX_KEY_SIZE; return NDB_MAX_KEY_SIZE;
} }
uint ha_ndbcluster::max_supported_key_part_length() const
{
return NDB_MAX_KEY_SIZE;
}
bool ha_ndbcluster::low_byte_first() const bool ha_ndbcluster::low_byte_first() const
{ {
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
...@@ -5093,7 +5112,7 @@ bool ha_ndbcluster::low_byte_first() const ...@@ -5093,7 +5112,7 @@ bool ha_ndbcluster::low_byte_first() const
} }
bool ha_ndbcluster::has_transactions() bool ha_ndbcluster::has_transactions()
{ {
return m_transaction_on; return TRUE;
} }
const char* ha_ndbcluster::index_type(uint key_number) const char* ha_ndbcluster::index_type(uint key_number)
{ {
......
...@@ -510,6 +510,7 @@ class ha_ndbcluster: public handler ...@@ -510,6 +510,7 @@ class ha_ndbcluster: public handler
uint max_supported_keys() const; uint max_supported_keys() const;
uint max_supported_key_parts() const; uint max_supported_key_parts() const;
uint max_supported_key_length() const; uint max_supported_key_length() const;
uint max_supported_key_part_length() const;
int rename_table(const char *from, const char *to); int rename_table(const char *from, const char *to);
int delete_table(const char *name); int delete_table(const char *name);
......
...@@ -1863,28 +1863,30 @@ longlong Item_func_round::int_op() ...@@ -1863,28 +1863,30 @@ longlong Item_func_round::int_op()
return value; // integer have not digits after point return value; // integer have not digits after point
abs_dec= -dec; abs_dec= -dec;
double tmp; longlong tmp;
/*
tmp2 is here to avoid return the value with 80 bit precision if(abs_dec >= array_elements(log_10_int))
This will fix that the test round(0.1,1) = round(0.1,1) is true return 0;
*/
volatile double tmp2; tmp= log_10_int[abs_dec];
tmp= (abs_dec < array_elements(log_10) ?
log_10[abs_dec] : pow(10.0, (double) abs_dec));
if (truncate) if (truncate)
{ {
if (unsigned_flag) if (unsigned_flag)
tmp2= floor(ulonglong2double(value)/tmp)*tmp; value= (ulonglong(value)/tmp)*tmp;
else if (value >= 0)
tmp2= floor(((double)value)/tmp)*tmp;
else else
tmp2= ceil(((double)value)/tmp)*tmp; value= (value/tmp)*tmp;
} }
else else
tmp2= rint(((double)value)/tmp)*tmp; {
return (longlong)tmp2; if (unsigned_flag)
value= ((ulonglong(value)+(tmp>>1))/tmp)*tmp;
else if ( value >= 0)
value= ((value+(tmp>>1))/tmp)*tmp;
else
value= ((value-(tmp>>1))/tmp)*tmp;
}
return value;
} }
......
...@@ -1283,10 +1283,8 @@ class Item_func_match :public Item_real_func ...@@ -1283,10 +1283,8 @@ class Item_func_match :public Item_real_func
DBUG_ENTER("Item_func_match"); DBUG_ENTER("Item_func_match");
Item_real_func::cleanup(); Item_real_func::cleanup();
if (!master && ft_handler) if (!master && ft_handler)
{
ft_handler->please->close_search(ft_handler); ft_handler->please->close_search(ft_handler);
ft_handler=0; ft_handler= 0;
}
concat= 0; concat= 0;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -373,8 +373,11 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, ...@@ -373,8 +373,11 @@ bool mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
error= read_sep_field(thd, info, table_list, fields_vars, error= read_sep_field(thd, info, table_list, fields_vars,
set_fields, set_values, read_info, set_fields, set_values, read_info,
*enclosed, skip_lines, ignore); *enclosed, skip_lines, ignore);
if (table->file->end_bulk_insert()) if (table->file->end_bulk_insert() && !error)
error=1; /* purecov: inspected */ {
table->file->print_error(my_errno, MYF(0));
error= 1;
}
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
table->next_number_field=0; table->next_number_field=0;
} }
......
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