Commit dc17ac16 authored by Monty's avatar Monty

Adding support for auto_increment in the partition engine.

Contains Spiral patches:
022_mariadb-10.2.0.auto_increment.diff               MDEV-7720
030: 030_mariadb-10.2.0.partition_auto_inc_init.diff MDEV-7726

These patches have the following differences compared to the original
patches:
- Added the new #defines for the feature in spd_environ.h instead of in
  handler.h because these #defines are needed by Spider and are not needed
  by the server.
- Cleaned up code related to the removed variable m_need_info_for_auto_inc
. Changed variable assignment in lock_auto_increment() and
  unlock_auto_increment() so that the assignments are done under locks.
- Added a test case.
- Added test result changes resulting from a bug that was fixed by these
  patches.

Original author: Kentoku SHIBA
First reviewer:  Jacob Mathew
Second reviewer: Michael Widenius
parent 2f09b28e
...@@ -4231,15 +4231,8 @@ int ha_partition::write_row(uchar * buf) ...@@ -4231,15 +4231,8 @@ int ha_partition::write_row(uchar * buf)
*/ */
if (have_auto_increment) if (have_auto_increment)
{ {
if (!part_share->auto_inc_initialized && if (!table_share->next_number_keypart)
!table_share->next_number_keypart) update_next_auto_inc_val();
{
/*
If auto_increment in table_share is not initialized, start by
initializing it.
*/
info(HA_STATUS_AUTO);
}
error= update_auto_increment(); error= update_auto_increment();
/* /*
...@@ -4432,8 +4425,11 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data) ...@@ -4432,8 +4425,11 @@ int ha_partition::update_row(const uchar *old_data, const uchar *new_data)
bitmap_is_set(table->write_set, bitmap_is_set(table->write_set,
table->found_next_number_field->field_index)) table->found_next_number_field->field_index))
{ {
if (!part_share->auto_inc_initialized) update_next_auto_inc_val();
info(HA_STATUS_AUTO); /*
The following call is safe as part_share->auto_inc_initialized
(tested in the call) is guaranteed to be set for update statements.
*/
set_auto_increment_if_higher(table->found_next_number_field); set_auto_increment_if_higher(table->found_next_number_field);
} }
DBUG_RETURN(error); DBUG_RETURN(error);
...@@ -8119,7 +8115,8 @@ int ha_partition::info(uint flag) ...@@ -8119,7 +8115,8 @@ int ha_partition::info(uint flag)
{ {
set_if_bigger(part_share->next_auto_inc_val, set_if_bigger(part_share->next_auto_inc_val,
auto_increment_value); auto_increment_value);
part_share->auto_inc_initialized= true; if (can_use_for_auto_inc_init())
part_share->auto_inc_initialized= true;
DBUG_PRINT("info", ("initializing next_auto_inc_val to %lu", DBUG_PRINT("info", ("initializing next_auto_inc_val to %lu",
(ulong) part_share->next_auto_inc_val)); (ulong) part_share->next_auto_inc_val));
} }
...@@ -10088,6 +10085,82 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2) ...@@ -10088,6 +10085,82 @@ int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2)
****************************************************************************/ ****************************************************************************/
/**
Retreive new values for part_share->next_auto_inc_val if needed
This is needed if the value has not been initialized or if one of
the underlying partitions require that the value should be re-calculated
*/
void ha_partition::update_next_auto_inc_val()
{
if (!part_share->auto_inc_initialized ||
need_info_for_auto_inc())
info(HA_STATUS_AUTO);
}
/**
Determine whether a partition needs auto-increment initialization.
@return
TRUE A partition needs auto-increment initialization
FALSE No partition needs auto-increment initialization
Resets part_share->auto_inc_initialized if next auto_increment needs to be
recalculated.
*/
bool ha_partition::need_info_for_auto_inc()
{
handler **file= m_file;
DBUG_ENTER("ha_partition::need_info_for_auto_inc");
do
{
if ((*file)->need_info_for_auto_inc())
{
/* We have to get new auto_increment values from handler */
part_share->auto_inc_initialized= FALSE;
DBUG_RETURN(TRUE);
}
} while (*(++file));
DBUG_RETURN(FALSE);
}
/**
Determine if all partitions can use the current auto-increment value for
auto-increment initialization.
@return
TRUE All partitions can use the current auto-increment
value for auto-increment initialization
FALSE All partitions cannot use the current
auto-increment value for auto-increment
initialization
Notes
This function is only called for ::info(HA_STATUS_AUTO) and is
mainly used by the Spider engine, which returns false
except in the case of DROP TABLE or ALTER TABLE when it returns TRUE.
Other engines always returns TRUE for this call.
*/
bool ha_partition::can_use_for_auto_inc_init()
{
handler **file= m_file;
DBUG_ENTER("ha_partition::can_use_for_auto_inc_init");
do
{
if (!(*file)->can_use_for_auto_inc_init())
DBUG_RETURN(FALSE);
} while (*(++file));
DBUG_RETURN(TRUE);
}
int ha_partition::reset_auto_increment(ulonglong value) int ha_partition::reset_auto_increment(ulonglong value)
{ {
handler **file= m_file; handler **file= m_file;
...@@ -10177,8 +10250,8 @@ void ha_partition::get_auto_increment(ulonglong offset, ulonglong increment, ...@@ -10177,8 +10250,8 @@ void ha_partition::get_auto_increment(ulonglong offset, ulonglong increment,
based replication. Because the statement-based binary log contains based replication. Because the statement-based binary log contains
only the first generated value used by the statement, and slaves assumes only the first generated value used by the statement, and slaves assumes
all other generated values used by this statement were consecutive to all other generated values used by this statement were consecutive to
this first one, we must exclusively lock the generator until the statement this first one, we must exclusively lock the generator until the
is done. statement is done.
*/ */
if (!auto_increment_safe_stmt_log_lock && if (!auto_increment_safe_stmt_log_lock &&
thd->lex->sql_command != SQLCOM_INSERT && thd->lex->sql_command != SQLCOM_INSERT &&
......
...@@ -1137,6 +1137,8 @@ class ha_partition :public handler ...@@ -1137,6 +1137,8 @@ class ha_partition :public handler
auto_increment_column_changed auto_increment_column_changed
------------------------------------------------------------------------- -------------------------------------------------------------------------
*/ */
virtual bool need_info_for_auto_inc();
virtual bool can_use_for_auto_inc_init();
virtual void get_auto_increment(ulonglong offset, ulonglong increment, virtual void get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values, ulonglong nb_desired_values,
ulonglong *first_value, ulonglong *first_value,
...@@ -1144,16 +1146,17 @@ class ha_partition :public handler ...@@ -1144,16 +1146,17 @@ class ha_partition :public handler
virtual void release_auto_increment(); virtual void release_auto_increment();
private: private:
virtual int reset_auto_increment(ulonglong value); virtual int reset_auto_increment(ulonglong value);
void update_next_auto_inc_val();
virtual void lock_auto_increment() virtual void lock_auto_increment()
{ {
/* lock already taken */ /* lock already taken */
if (auto_increment_safe_stmt_log_lock) if (auto_increment_safe_stmt_log_lock)
return; return;
DBUG_ASSERT(!auto_increment_lock); if (table_share->tmp_table == NO_TMP_TABLE)
if(table_share->tmp_table == NO_TMP_TABLE)
{ {
auto_increment_lock= TRUE;
part_share->lock_auto_inc(); part_share->lock_auto_inc();
DBUG_ASSERT(!auto_increment_lock);
auto_increment_lock= TRUE;
} }
} }
virtual void unlock_auto_increment() virtual void unlock_auto_increment()
...@@ -1163,10 +1166,10 @@ class ha_partition :public handler ...@@ -1163,10 +1166,10 @@ class ha_partition :public handler
It will be set to false and thus unlocked at the end of the statement by It will be set to false and thus unlocked at the end of the statement by
ha_partition::release_auto_increment. ha_partition::release_auto_increment.
*/ */
if(auto_increment_lock && !auto_increment_safe_stmt_log_lock) if (auto_increment_lock && !auto_increment_safe_stmt_log_lock)
{ {
part_share->unlock_auto_inc();
auto_increment_lock= FALSE; auto_increment_lock= FALSE;
part_share->unlock_auto_inc();
} }
} }
virtual void set_auto_increment_if_higher(Field *field) virtual void set_auto_increment_if_higher(Field *field)
...@@ -1174,7 +1177,8 @@ class ha_partition :public handler ...@@ -1174,7 +1177,8 @@ class ha_partition :public handler
ulonglong nr= (((Field_num*) field)->unsigned_flag || ulonglong nr= (((Field_num*) field)->unsigned_flag ||
field->val_int() > 0) ? field->val_int() : 0; field->val_int() > 0) ? field->val_int() : 0;
lock_auto_increment(); lock_auto_increment();
DBUG_ASSERT(part_share->auto_inc_initialized); DBUG_ASSERT(part_share->auto_inc_initialized ||
!can_use_for_auto_inc_init());
/* must check when the mutex is taken */ /* must check when the mutex is taken */
if (nr >= part_share->next_auto_inc_val) if (nr >= part_share->next_auto_inc_val)
part_share->next_auto_inc_val= nr + 1; part_share->next_auto_inc_val= nr + 1;
......
...@@ -3395,6 +3395,8 @@ class handler :public Sql_alloc ...@@ -3395,6 +3395,8 @@ class handler :public Sql_alloc
virtual void try_semi_consistent_read(bool) {} virtual void try_semi_consistent_read(bool) {}
virtual void unlock_row() {} virtual void unlock_row() {}
virtual int start_stmt(THD *thd, thr_lock_type lock_type) {return 0;} virtual int start_stmt(THD *thd, thr_lock_type lock_type) {return 0;}
virtual bool need_info_for_auto_inc() { return 0; }
virtual bool can_use_for_auto_inc_init() { return 1; }
virtual void get_auto_increment(ulonglong offset, ulonglong increment, virtual void get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values, ulonglong nb_desired_values,
ulonglong *first_value, ulonglong *first_value,
......
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
drop and create databases
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
connection child2_1;
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
test select 1
connection master_1;
SELECT 1;
1
1
connection child2_1;
SELECT 1;
1
1
create table select test
connection child2_1;
CHILD2_1_DROP_TABLES
CHILD2_1_CREATE_TABLES
TRUNCATE TABLE mysql.general_log;
connection master_1;
DROP TABLE IF EXISTS tbl_a;
CREATE TABLE tbl_a (
col_a INT NOT NULL AUTO_INCREMENT,
col_b VARCHAR(20) DEFAULT 'defg',
col_c INT NOT NULL DEFAULT 100,
PRIMARY KEY(col_a)
) MASTER_1_ENGINE MASTER_1_AUTO_INCREMENT_2_1 MASTER_1_COMMENT_2_1
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` int(11) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` int(11) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
ALTER TABLE tbl_a MODIFY col_c MEDIUMINT NOT NULL DEFAULT 100;
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
RENAME TABLE tbl_a TO tbl_x;
SHOW CREATE TABLE tbl_x;
Table Create Table
tbl_x CREATE TABLE `tbl_x` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
RENAME TABLE tbl_x TO tbl_a;
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
MASTER_1_AUTO_INCREMENT1
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=30 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=5 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
MASTER_1_AUTO_INCREMENT2
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=20 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
Table Create Table
tbl_a CREATE TABLE `tbl_a` (
`col_a` int(11) NOT NULL AUTO_INCREMENT,
`col_b` varchar(20) DEFAULT 'defg',
`col_c` mediumint(9) NOT NULL DEFAULT 100,
PRIMARY KEY (`col_a`)
) ENGINE=SPIDER AUTO_INCREMENT=7 DEFAULT CHARSET=latin1 COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"'
select test
connection child2_1;
TRUNCATE TABLE mysql.general_log;
connection master_1;
SELECT * FROM tbl_a;
col_a col_b col_c
1 def 10
2 def 10
3 def 10
4 def 10
5 def 10
6 def 10
7 def 10
8 def 10
connection child2_1;
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
argument
select `col_a`,`col_b`,`col_c` from `auto_test_remote`.`tbl_a`
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %'
SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a;
col_a col_b col_c
1 def 10
2 def 10
3 def 10
4 def 10
5 def 10
6 def 10
7 def 10
8 def 10
deinit
connection master_1;
DROP DATABASE IF EXISTS auto_test_local;
connection child2_1;
DROP DATABASE IF EXISTS auto_test_remote;
SET GLOBAL log_output = @old_log_output;
for master_1
for child2
child2_1
child2_2
child2_3
for child3
child3_1
child3_2
child3_3
end of test
...@@ -85,10 +85,10 @@ MASTER_1_AUTO_INCREMENT_OFFSET3 ...@@ -85,10 +85,10 @@ MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 (id) VALUES (null); INSERT INTO t1 (id) VALUES (null);
SELECT LAST_INSERT_ID(); SELECT LAST_INSERT_ID();
LAST_INSERT_ID() LAST_INSERT_ID()
778 1555
SELECT MAX(id) FROM t1; SELECT MAX(id) FROM t1;
MAX(id) MAX(id)
1554 1555
MASTER_1_AUTO_INCREMENT_OFFSET4 MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 (id) VALUES (null); INSERT INTO t2 (id) VALUES (null);
SELECT LAST_INSERT_ID(); SELECT LAST_INSERT_ID();
...@@ -101,36 +101,36 @@ MASTER_1_AUTO_INCREMENT_OFFSET3 ...@@ -101,36 +101,36 @@ MASTER_1_AUTO_INCREMENT_OFFSET3
INSERT INTO t1 () VALUES (),(),(),(); INSERT INTO t1 () VALUES (),(),(),();
SELECT LAST_INSERT_ID(); SELECT LAST_INSERT_ID();
LAST_INSERT_ID() LAST_INSERT_ID()
1555 2332
SELECT id FROM t1 ORDER BY id; SELECT id FROM t1 ORDER BY id;
id id
777 777
778
1554 1554
1555 1555
2331 2331
2332 2332
3109 3109
3886 3886
4663
MASTER_1_AUTO_INCREMENT_OFFSET4 MASTER_1_AUTO_INCREMENT_OFFSET4
INSERT INTO t2 () VALUES (),(),(),(); INSERT INTO t2 () VALUES (),(),(),();
SELECT LAST_INSERT_ID(); SELECT LAST_INSERT_ID();
LAST_INSERT_ID() LAST_INSERT_ID()
3108 5439
SELECT id FROM t2 ORDER BY id; SELECT id FROM t2 ORDER BY id;
id id
777 777
778
1554 1554
1555 1555
2331 2331
2332 2332
3108
3109 3109
3885
3886 3886
4662 4663
5439 5439
6216
6993
7770
TRUNCATE TABLE t1; TRUNCATE TABLE t1;
TRUNCATE TABLE t2; TRUNCATE TABLE t2;
INSERT INTO t1 () VALUES (),(),(),(); INSERT INTO t1 () VALUES (),(),(),();
......
--source auto_increment_init.inc
--echo
--echo drop and create databases
--connection master_1
--disable_warnings
DROP DATABASE IF EXISTS auto_test_local;
CREATE DATABASE auto_test_local;
USE auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
if ($USE_GENERAL_LOG)
{
SET @old_log_output = @@global.log_output;
SET GLOBAL log_output = 'TABLE,FILE';
}
DROP DATABASE IF EXISTS auto_test_remote;
CREATE DATABASE auto_test_remote;
USE auto_test_remote;
}
--enable_warnings
--echo
--echo test select 1
--connection master_1
SELECT 1;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
SELECT 1;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo create table select test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($OUTPUT_CHILD_GROUP2)
{
--disable_query_log
echo CHILD2_1_DROP_TABLES;
echo CHILD2_1_CREATE_TABLES;
}
--disable_warnings
eval $CHILD2_1_DROP_TABLES;
--enable_warnings
eval $CHILD2_1_CREATE_TABLES;
if ($OUTPUT_CHILD_GROUP2)
{
--enable_query_log
}
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
--disable_warnings
DROP TABLE IF EXISTS tbl_a;
--enable_warnings
--disable_query_log
echo CREATE TABLE tbl_a (
col_a INT NOT NULL AUTO_INCREMENT,
col_b VARCHAR(20) DEFAULT 'defg',
col_c INT NOT NULL DEFAULT 100,
PRIMARY KEY(col_a)
) MASTER_1_ENGINE MASTER_1_AUTO_INCREMENT_2_1 MASTER_1_COMMENT_2_1;
eval CREATE TABLE tbl_a (
col_a INT NOT NULL AUTO_INCREMENT,
col_b VARCHAR(20) DEFAULT 'defg',
col_c INT NOT NULL DEFAULT 100,
PRIMARY KEY(col_a)
) $MASTER_1_ENGINE $MASTER_1_AUTO_INCREMENT_2_1 $MASTER_1_COMMENT_2_1;
--enable_query_log
SHOW CREATE TABLE tbl_a;
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
ALTER TABLE tbl_a MODIFY col_c MEDIUMINT NOT NULL DEFAULT 100;
SHOW CREATE TABLE tbl_a;
RENAME TABLE tbl_a TO tbl_x;
SHOW CREATE TABLE tbl_x;
RENAME TABLE tbl_x TO tbl_a;
SHOW CREATE TABLE tbl_a;
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT1;
eval $MASTER_1_AUTO_INCREMENT1;
--enable_query_log
SHOW CREATE TABLE tbl_a;
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
--disable_query_log
echo MASTER_1_AUTO_INCREMENT2;
eval $MASTER_1_AUTO_INCREMENT2;
--enable_query_log
SHOW CREATE TABLE tbl_a;
INSERT INTO tbl_a () VALUES ();
INSERT INTO tbl_a () VALUES ();
SHOW CREATE TABLE tbl_a;
--echo
--echo select test
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
TRUNCATE TABLE mysql.general_log;
}
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--connection master_1
SELECT * FROM tbl_a;
if ($USE_CHILD_GROUP2)
{
if (!$OUTPUT_CHILD_GROUP2)
{
--disable_query_log
--disable_result_log
}
--connection child2_1
if ($USE_GENERAL_LOG)
{
eval $CHILD2_1_SELECT_ARGUMENT1;
}
eval $CHILD2_1_SELECT_TABLES;
if (!$OUTPUT_CHILD_GROUP2)
{
--enable_query_log
--enable_result_log
}
}
--echo
--echo deinit
--disable_warnings
--connection master_1
DROP DATABASE IF EXISTS auto_test_local;
if ($USE_CHILD_GROUP2)
{
--connection child2_1
DROP DATABASE IF EXISTS auto_test_remote;
if ($USE_GENERAL_LOG)
{
SET GLOBAL log_output = @old_log_output;
}
}
--enable_warnings
--source auto_increment_deinit.inc
--echo
--echo end of test
--let $MASTER_1_COMMENT_2_1= $MASTER_1_COMMENT_2_1_BACKUP
--let $CHILD2_1_DROP_TABLES= $CHILD2_1_DROP_TABLES_BACKUP
--let $CHILD2_1_CREATE_TABLES= $CHILD2_1_CREATE_TABLES_BACKUP
--let $CHILD2_1_SELECT_TABLES= $CHILD2_1_SELECT_TABLES_BACKUP
--let $OUTPUT_CHILD_GROUP2= $OUTPUT_CHILD_GROUP2_BACKUP
--let $USE_GENERAL_LOG= $USE_GENERAL_LOG_BACKUP
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_deinit.inc
--enable_result_log
--enable_query_log
--enable_warnings
--disable_warnings
--disable_query_log
--disable_result_log
--source ../t/test_init.inc
--enable_result_log
--enable_query_log
--enable_warnings
--let $MASTER_1_COMMENT_2_1_BACKUP= $MASTER_1_COMMENT_2_1
let $MASTER_1_COMMENT_2_1=
COMMENT='database "auto_test_remote", table "tbl_a", srv "s_2_1", aim "0"';
let $MASTER_1_AUTO_INCREMENT_2_1=
AUTO_INCREMENT=20;
let $MASTER_1_AUTO_INCREMENT1=
ALTER TABLE tbl_a AUTO_INCREMENT=30;
let $MASTER_1_AUTO_INCREMENT2=
ALTER TABLE tbl_a AUTO_INCREMENT=10;
let $CHILD2_1_CHARSET_AUTO_INCREMENT=
AUTO_INCREMENT=20;
--let $CHILD2_1_DROP_TABLES_BACKUP= $CHILD2_1_DROP_TABLES
let $CHILD2_1_DROP_TABLES=
DROP TABLE IF EXISTS tbl_a;
--let $CHILD2_1_CREATE_TABLES_BACKUP= $CHILD2_1_CREATE_TABLES
let $CHILD2_1_CREATE_TABLES=
CREATE TABLE tbl_a (
col_a INT NOT NULL AUTO_INCREMENT,
col_b VARCHAR(20) DEFAULT 'def',
col_c INT NOT NULL DEFAULT 10,
PRIMARY KEY(col_a)
) $CHILD2_1_ENGINE $CHILD2_1_CHARSET_AUTO_INCREMENT $CHILD2_1_CHARSET;
--let $CHILD2_1_SELECT_TABLES_BACKUP= $CHILD2_1_SELECT_TABLES
let $CHILD2_1_SELECT_TABLES=
SELECT col_a, col_b, col_c FROM tbl_a ORDER BY col_a;
let $CHILD2_1_SELECT_ARGUMENT1=
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
--let $OUTPUT_CHILD_GROUP2_BACKUP= $OUTPUT_CHILD_GROUP2
--let $OUTPUT_CHILD_GROUP2= 1
--let $USE_GENERAL_LOG_BACKUP= $USE_GENERAL_LOG
--let $USE_GENERAL_LOG= 1
...@@ -31,5 +31,7 @@ ...@@ -31,5 +31,7 @@
#define PARTITION_HAS_EXTRA_ATTACH_CHILDREN #define PARTITION_HAS_EXTRA_ATTACH_CHILDREN
#define PARTITION_HAS_GET_CHILD_HANDLERS #define PARTITION_HAS_GET_CHILD_HANDLERS
#define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN #define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
#define HANDLER_HAS_NEED_INFO_FOR_AUTO_INC
#define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
#endif #endif
#endif /* SPD_ENVIRON_INCLUDED */ #endif /* SPD_ENVIRON_INCLUDED */
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