Commit 9a9c64ce authored by ingo@mysql.com's avatar ingo@mysql.com

Merge mysql.com:/home/mydev/mysql-5.1

into  mysql.com:/home/mydev/mysql-5.1-bug11527
parents 8efa709f 9d819dff
This diff is collapsed.
#############################################################
# Author: JBM
# Date: 2006-02-23
# Purpose: To reuse through out test and make maint easier
#############################################################
connection master;
--echo "--- Insert into t1 --" as "";
--disable_query_log
INSERT INTO t1 VALUES(42,1,'Testing MySQL databases is a cool ',
'Must make it bug free for the customer',
654321.4321,15.21,0,1965,"1905-11-14");
INSERT INTO t1 VALUES(2,1,'Testing MySQL databases is a cool ',
'Must make it bug free for the customer',
654321.4321,15.21,0,1965,"1965-11-14");
INSERT INTO t1 VALUES(4,1,'Testing MySQL databases is a cool ',
'Must make it bug free for the customer',
654321.4321,15.21,0,1965,"1985-11-14");
INSERT INTO t1 VALUES(142,1,'Testing MySQL databases is a cool ',
'Must make it bug free for the customer',
654321.4321,15.21,0,1965,"1995-11-14");
INSERT INTO t1 VALUES(412,1,'Testing MySQL databases is a cool ',
'Must make it bug free for the customer',
654321.4321,15.21,0,1965,"2005-11-14");
--enable_query_log
--echo --- Select from t1 on master ---
select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
sync_slave_with_master;
--echo --- Select from t1 on slave ---
select id,hex(b1),vc,bc,d,f,total,y,t from t1 order by id;
connection master;
--echo --- Update t1 on master --
UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412;
--echo --- Check the update on master ---
SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412;
# Must give injector thread a little time to get update
# into the binlog other wise we will miss the update.
sleep 3;
sync_slave_with_master;
--echo --- Check Update on slave ---
SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412;
connection master;
--echo --- Remove a record from t1 on master ---
DELETE FROM t1 WHERE id = 42;
--echo --- Show current count on master for t1 ---
SELECT COUNT(*) FROM t1;
sync_slave_with_master;
--echo --- Show current count on slave for t1 ---
SELECT COUNT(*) FROM t1;
connection master;
DELETE FROM t1;
......@@ -37,6 +37,54 @@ alter event event3 rename to event2;
drop event event2;
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
drop event event2;
CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 10 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
0 1
ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
1 1
ALTER EVENT event_starts_test COMMENT "non-empty comment";
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
1 1 non-empty comment
ALTER EVENT event_starts_test COMMENT "";
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost ONE TIME 2020-02-02 17:00:02 NULL NULL # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
1 1
DROP EVENT event_starts_test;
CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
0 0
ALTER EVENT event_starts_test COMMENT "non-empty comment";
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
starts IS NULL ends IS NULL comment
0 0 non-empty comment
ALTER EVENT event_starts_test COMMENT "";
SHOW EVENTS;
Db Name Definer Type Execute at Interval value Interval field Starts Ends Status
events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLED
DROP EVENT event_starts_test;
create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1;
alter event e_43 do alter event e_43 do set @a = 4;
......
......@@ -22,12 +22,16 @@ partition_03ndb : Bug#16385
ps_7ndb : dbug assert in RBR mode when executing test suite
rpl_bit_npk : Bug#13418
rpl_ddl : Bug#15963 SBR does not show "Definer" correctly
rpl_ndb_2innodb : Bugs#17400, 17687, 17701
rpl_ndb_2myisam : Bugs#17400, 17687, 17701
rpl_ndb_auto_inc : Bug#17086
rpl_ndb_basic : Bug#16228 [IN REVIEW]
rpl_ndb_charset : Bug#17246
rpl_ndb_ddl : Bug#17400: delete & update of rows in table without pk fails
rpl_ndb_delete_nowhere : Bug#17400: delete & update of rows in table without pk fails
rpl_ndb_innodb2ndb : Bugs#17400, 17687, 17701
rpl_ndb_insert_ignore : Bugs: #17431: INSERT IGNORE INTO returns failed: 1296
rpl_ndb_myisam2ndb : Bugs#17400, 17687, 17701
rpl_ndb_log : result not deterministic
rpl_ndb_relay_space : Bug#16993
rpl_ndb_multi_update3 : Bug#17400: delete & update of rows in table without pk fails
......
......@@ -48,6 +48,38 @@ drop event event2;
create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end;
drop event event2;
# BUG #16537 (Events: mysql.event.starts is null)
CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1;
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
ALTER EVENT event_starts_test ON SCHEDULE AT '2020-02-02 20:00:02';
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
ALTER EVENT event_starts_test COMMENT "non-empty comment";
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
ALTER EVENT event_starts_test COMMENT "";
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
DROP EVENT event_starts_test;
CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '2020-02-02 20:00:02' ENDS '2022-02-02 20:00:02' DO SELECT 2;
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
ALTER EVENT event_starts_test COMMENT "non-empty comment";
--replace_column 8 # 9 #
SHOW EVENTS;
SELECT starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test';
ALTER EVENT event_starts_test COMMENT "";
--replace_column 8 # 9 #
SHOW EVENTS;
DROP EVENT event_starts_test;
#
#
create event e_43 on schedule every 1 second do set @a = 5;
set global event_scheduler = 1;
--sleep 2
......
--default-storage-engine=ndb --binlog-format=row
--innodb --default-storage-engine=innodb --binlog-format=row
#############################################################
# Author: JBM
# Date: 2006-02-24
# Purpose: Trying to test ability to replicate from cluster
# to innodb, or myisam, or replicate from innodb/myisam to
# cluster slave. Due to limitations I have created wrappers
# to be able to use the same code for all these different
# test and to have control over the tests.
##############################################################
-- source include/have_ndb.inc
-- source include/master-slave.inc
connection slave;
-- source include/have_innodb.inc
connection master;
SET storage_engine=ndb;
--source extra/rpl_tests/rpl_ndb_2multi_eng.test
--default-storage-engine=ndb --binlog-format=row
--default-storage-engine=myisam --binlog-format=row
#############################################################
# Author: JBM
# Date: 2006-02-24
# Purpose: Trying to test ability to replicate from cluster
# to innodb, or myisam, or replicate from innodb/myisam to
# cluster slave. Due to limitations I have created wrappers
# to be able to use the same code for all these different
# test and to have control over the tests.
##############################################################
-- source include/have_ndb.inc
-- source include/master-slave.inc
SET storage_engine=ndb;
--source extra/rpl_tests/rpl_ndb_2multi_eng.test
--binlog-format=row --default-storage-engine=ndb
#############################################################
# Author: JBM
# Date: 2006-02-24
# Purpose: Trying to test ability to replicate from cluster
# to innodb, or myisam, or replicate from innodb/myisam to
# cluster slave. Due to limitations I have created wrappers
# to be able to use the same code for all these different
# test and to have control over the tests.
##############################################################
-- source include/have_innodb.inc
-- source include/master-slave.inc
connection slave;
-- source include/have_ndb.inc
connection master;
SET storage_engine=innodb;
--source extra/rpl_tests/rpl_ndb_2multi_eng.test
--default-storage-engine=ndb --binlog-format=row
#############################################################
# Author: JBM
# Date: 2006-02-24
# Purpose: Trying to test ability to replicate from cluster
# to innodb, or myisam, or replicate from innodb/myisam to
# cluster slave. Due to limitations I have created wrappers
# to be able to use the same code for all these different
# test and to have control over the tests.
##############################################################
-- source include/master-slave.inc
connection slave;
--source include/have_ndb.inc
connection master;
SET storage_engine=myisam;
--source extra/rpl_tests/rpl_ndb_2multi_eng.test
This diff is collapsed.
......@@ -103,6 +103,9 @@ class event_timed
TIME starts;
TIME ends;
TIME execute_at;
my_bool starts_null;
my_bool ends_null;
my_bool execute_at_null;
longlong expression;
interval_type interval;
......
This diff is collapsed.
This diff is collapsed.
......@@ -3957,7 +3957,7 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
sch_table->field[3]->store(et.definer.str, et.definer.length, scs);
sch_table->field[4]->store(et.body.str, et.body.length, scs);
// [9] is SQL_MODE
/* [9] is SQL_MODE */
{
byte *sql_mode_str;
ulong sql_mode_len=0;
......@@ -3972,9 +3972,9 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
String show_str;
//type
sch_table->field[5]->store(STRING_WITH_LEN("RECURRING"), scs);
//execute_at
/* execute_at */
sch_table->field[6]->set_null();
//interval_value
/* interval_value */
//interval_type
if (event_reconstruct_interval_expression(&show_str, et.interval,
et.expression))
......@@ -3986,26 +3986,24 @@ fill_events_copy_to_schema_table(THD *thd, TABLE *sch_table, TABLE *event_table)
LEX_STRING *ival= &interval_type_to_name[et.interval];
sch_table->field[8]->set_notnull();
sch_table->field[8]->store(ival->str, ival->length, scs);
//starts & ends
//starts & ends
sch_table->field[10]->set_notnull();
sch_table->field[10]->store_time(&et.starts, MYSQL_TIMESTAMP_DATETIME);
sch_table->field[11]->set_notnull();
sch_table->field[11]->store_time(&et.ends, MYSQL_TIMESTAMP_DATETIME);
if (!et.ends_null)
{
sch_table->field[11]->set_notnull();
sch_table->field[11]->store_time(&et.ends, MYSQL_TIMESTAMP_DATETIME);
}
}
else
{
//type
sch_table->field[5]->store(STRING_WITH_LEN("ONE TIME"), scs);
//execute_at
sch_table->field[6]->set_notnull();
sch_table->field[6]->store_time(&et.execute_at, MYSQL_TIMESTAMP_DATETIME);
//interval
sch_table->field[7]->set_null();
//interval_type
sch_table->field[8]->set_null();
//starts & ends
sch_table->field[10]->set_null();
sch_table->field[11]->set_null();
}
//status
......
......@@ -1476,6 +1476,9 @@ opt_ev_status: /* empty */ { $$= 0; }
;
ev_starts: /* empty */
{
Lex->et->init_starts(YYTHD, new Item_func_now_local());
}
| STARTS_SYM expr
{
LEX *lex= Lex;
......
......@@ -2056,59 +2056,94 @@ int
NdbDictionaryImpl::createTable(NdbTableImpl &t)
{
DBUG_ENTER("NdbDictionaryImpl::createTable");
// If the a new name has not been set, used the copied name
// if the new name has not been set, use the copied name
if (t.m_newExternalName.empty())
t.m_newExternalName.assign(t.m_externalName);
// create table
if (m_receiver.createTable(m_ndb, t) != 0)
{
DBUG_RETURN(-1);
Uint32* data = (Uint32*)m_receiver.m_buffer.get_data();
t.m_id = data[0];
t.m_version = data[1];
// update table def from DICT - by-pass cache
NdbTableImpl* t2 =
m_receiver.getTable(t.m_internalName, m_ndb.usingFullyQualifiedNames());
// check if we got back same table
if (t2 == NULL) {
DBUG_PRINT("info", ("table %s dropped by another thread",
t.m_internalName.c_str()));
m_error.code = 283;
DBUG_RETURN(-1);
}
if (t.m_noOfBlobs == 0)
{
DBUG_RETURN(0);
}
// update table def from DICT
Ndb_local_table_info *info=
get_local_table_info(t.m_internalName,false);
if (info == NULL) {
m_error.code= 709;
if (t.m_id != t2->m_id || t.m_version != t2->m_version) {
DBUG_PRINT("info", ("table %s re-created by another thread",
t.m_internalName.c_str()));
m_error.code = 283;
delete t2;
DBUG_RETURN(-1);
}
if (createBlobTables(t, *(info->m_table_impl)) != 0) {
// auto-increment - use "t" because initial value is not in DICT
{
bool autoIncrement = false;
Uint64 initialValue = 0;
for (Uint32 i = 0; i < t.m_columns.size(); i++) {
const NdbColumnImpl* c = t.m_columns[i];
assert(c != NULL);
if (c->m_autoIncrement) {
if (autoIncrement) {
m_error.code = 4335;
delete t2;
DBUG_RETURN(-1);
}
autoIncrement = true;
initialValue = c->m_autoIncrementInitialValue;
}
}
if (autoIncrement) {
// XXX unlikely race condition - t.m_id may no longer be same table
if (! m_ndb.setTupleIdInNdb(t.m_id, initialValue, false)) {
if (m_ndb.theError.code)
m_error.code = m_ndb.theError.code;
else
m_error.code = 4336;
delete t2;
DBUG_RETURN(-1);
}
}
}
// blob tables - use "t2" to get values set by kernel
if (t2->m_noOfBlobs != 0 && createBlobTables(*t2) != 0) {
int save_code = m_error.code;
(void)dropTable(t);
m_error.code= save_code;
(void)dropTable(*t2);
m_error.code = save_code;
delete t2;
DBUG_RETURN(-1);
}
// not entered in cache
delete t2;
DBUG_RETURN(0);
}
int
NdbDictionaryImpl::createBlobTables(NdbTableImpl& org, NdbTableImpl &t)
NdbDictionaryImpl::createBlobTables(NdbTableImpl &t)
{
DBUG_ENTER("NdbDictionaryImpl::createBlobTables");
for (unsigned i = 0; i < t.m_columns.size(); i++) {
NdbColumnImpl & c = *t.m_columns[i];
NdbColumnImpl & oc = *org.m_columns[i];
if (! c.getBlobType() || c.getPartSize() == 0)
continue;
NdbTableImpl bt;
NdbDictionary::Column::StorageType save = c.getStorageType();
c.setStorageType(oc.getStorageType());
NdbBlob::getBlobTable(bt, &t, &c);
c.setStorageType(save);
if (createTable(bt) != 0)
{
DBUG_RETURN(-1);
}
// Save BLOB table handle
Ndb_local_table_info *info=
get_local_table_info(bt.m_internalName, false);
if (info == 0)
{
if (createTable(bt) != 0) {
DBUG_RETURN(-1);
}
c.m_blobTable = info->m_table_impl;
}
DBUG_RETURN(0);
}
......@@ -2292,21 +2327,13 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
sizeof(tmpTab->TableName),
internalName.c_str());
bool haveAutoIncrement = false;
Uint64 autoIncrementValue = 0;
Uint32 distKeys= 0;
for(i = 0; i<sz; i++){
for(i = 0; i<sz; i++) {
const NdbColumnImpl * col = impl.m_columns[i];
if(col == 0)
continue;
if (col->m_autoIncrement) {
if (haveAutoIncrement) {
m_error.code= 4335;
NdbMem_Free((void*)tmpTab);
DBUG_RETURN(-1);
}
haveAutoIncrement = true;
autoIncrementValue = col->m_autoIncrementInitialValue;
if (col == NULL) {
m_error.code = 4272;
NdbMem_Free((void*)tmpTab);
DBUG_RETURN(-1);
}
if (col->m_distributionKey)
{
......@@ -2570,17 +2597,6 @@ NdbDictInterface::createOrAlterTable(Ndb & ndb,
errCodes);
}
if (!ret && !alter && haveAutoIncrement) {
if (!ndb.setAutoIncrementValue(impl.m_externalName.c_str(),
autoIncrementValue)) {
if (ndb.theError.code == 0) {
m_error.code = 4336;
ndb.theError = m_error;
} else
m_error= ndb.theError;
ret = -1; // errorcode set in initialize_autoincrement
}
}
DBUG_RETURN(ret);
}
......@@ -2588,12 +2604,12 @@ void
NdbDictInterface::execCREATE_TABLE_CONF(NdbApiSignal * signal,
LinearSectionPtr ptr[3])
{
#if 0
const CreateTableConf* const conf=
CAST_CONSTPTR(CreateTableConf, signal->getDataPtr());
Uint32 tableId= conf->tableId;
Uint32 tableVersion= conf->tableVersion;
#endif
m_buffer.grow(4 * 2); // 2 words
Uint32* data = (Uint32*)m_buffer.get_data();
data[0] = conf->tableId;
data[1] = conf->tableVersion;
m_waiter.signal(NO_WAIT);
}
......
......@@ -479,6 +479,7 @@ private:
class TransporterFacade * m_transporter;
friend class Ndb;
friend class NdbDictionaryImpl;
static void execSignal(void* dictImpl,
class NdbApiSignal* signal,
struct LinearSectionPtr ptr[3]);
......@@ -540,7 +541,7 @@ public:
bool setTransporter(class TransporterFacade * tf);
int createTable(NdbTableImpl &t);
int createBlobTables(NdbTableImpl& org, NdbTableImpl & created);
int createBlobTables(NdbTableImpl& t);
int addBlobTables(NdbTableImpl &);
int alterTable(NdbTableImpl &t);
int dropTable(const char * name);
......
......@@ -596,7 +596,9 @@ ErrorBundle ErrorCodes[] = {
{ 4269, DMEC, IE, "No connection to ndb management server" },
{ 4270, DMEC, IE, "Unknown blob error" },
{ 4335, DMEC, AE, "Only one autoincrement column allowed per table. Having a table without primary key uses an autoincremented hidden key, i.e. a table without a primary key can not have an autoincremented column" },
{ 4271, DMEC, AE, "Invalid index object, not retrieved via getIndex()" }
{ 4336, DMEC, AE, "Auto-increment value set below current value" },
{ 4271, DMEC, AE, "Invalid index object, not retrieved via getIndex()" },
{ 4272, DMEC, AE, "Table definition has undefined column" }
};
static
......
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