mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Bug#35111 - Truncate a MyISAM partitioned table does not reset
the auto_increment value This is an alternative patch that instead of allowing RECREATE TABLE on TRUNCATE TABLE it implements reset_auto_increment that is called after delete_all_rows. Note: this bug was fixed by Mattias Jonsson: Pusing this patch: http://lists.mysql.com/commits/70370 mysql-test/suite/parts/r/partition_auto_increment_memory.result: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value mysql-test/suite/parts/r/partition_auto_increment_myisam.result: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value sql/ha_partition.cc: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value Added reset_auto_increment, to be used after delete_all_rows to simulate truncate. storage/heap/ha_heap.cc: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value Added reset_auto_increment, to be used after delete_all_rows to simulate truncate storage/heap/ha_heap.h: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value Added reset_auto_increment, to be used after delete_all_rows to simulate truncate storage/myisam/ha_myisam.cc: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value Added reset_auto_increment, to be used after delete_all_rows to simulate truncate. storage/myisam/ha_myisam.h: Bug#35111: Truncate a MyISAM partitioned table does not reset the auto_increment value Added reset_auto_increment, to be used after delete_all_rows to simulate truncate.
This commit is contained in:
@ -381,12 +381,12 @@ Table Create Table
|
|||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
PRIMARY KEY (`c1`)
|
PRIMARY KEY (`c1`)
|
||||||
) ENGINE=MEMORY AUTO_INCREMENT=28 DEFAULT CHARSET=latin1
|
) ENGINE=MEMORY AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
|
||||||
/*!50100 PARTITION BY HASH (c1)
|
/*!50100 PARTITION BY HASH (c1)
|
||||||
PARTITIONS 2 */
|
PARTITIONS 2 */
|
||||||
SELECT * FROM t1 ORDER BY c1;
|
SELECT * FROM t1 ORDER BY c1;
|
||||||
c1
|
c1
|
||||||
27
|
1
|
||||||
INSERT INTO t1 VALUES (100);
|
INSERT INTO t1 VALUES (100);
|
||||||
INSERT INTO t1 VALUES (NULL);
|
INSERT INTO t1 VALUES (NULL);
|
||||||
DELETE FROM t1 WHERE c1 >= 100;
|
DELETE FROM t1 WHERE c1 >= 100;
|
||||||
|
@ -381,12 +381,12 @@ Table Create Table
|
|||||||
t1 CREATE TABLE `t1` (
|
t1 CREATE TABLE `t1` (
|
||||||
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
`c1` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
PRIMARY KEY (`c1`)
|
PRIMARY KEY (`c1`)
|
||||||
) ENGINE=MyISAM AUTO_INCREMENT=28 DEFAULT CHARSET=latin1
|
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
|
||||||
/*!50100 PARTITION BY HASH (c1)
|
/*!50100 PARTITION BY HASH (c1)
|
||||||
PARTITIONS 2 */
|
PARTITIONS 2 */
|
||||||
SELECT * FROM t1 ORDER BY c1;
|
SELECT * FROM t1 ORDER BY c1;
|
||||||
c1
|
c1
|
||||||
27
|
1
|
||||||
INSERT INTO t1 VALUES (100);
|
INSERT INTO t1 VALUES (100);
|
||||||
INSERT INTO t1 VALUES (NULL);
|
INSERT INTO t1 VALUES (NULL);
|
||||||
DELETE FROM t1 WHERE c1 >= 100;
|
DELETE FROM t1 WHERE c1 >= 100;
|
||||||
|
@ -3179,6 +3179,7 @@ int ha_partition::delete_row(const uchar *buf)
|
|||||||
int ha_partition::delete_all_rows()
|
int ha_partition::delete_all_rows()
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
bool truncate= FALSE;
|
||||||
handler **file;
|
handler **file;
|
||||||
THD *thd= ha_thd();
|
THD *thd= ha_thd();
|
||||||
DBUG_ENTER("ha_partition::delete_all_rows");
|
DBUG_ENTER("ha_partition::delete_all_rows");
|
||||||
@ -3190,12 +3191,16 @@ int ha_partition::delete_all_rows()
|
|||||||
ha_data->next_auto_inc_val= 0;
|
ha_data->next_auto_inc_val= 0;
|
||||||
ha_data->auto_inc_initialized= FALSE;
|
ha_data->auto_inc_initialized= FALSE;
|
||||||
unlock_auto_increment();
|
unlock_auto_increment();
|
||||||
|
truncate= TRUE;
|
||||||
}
|
}
|
||||||
file= m_file;
|
file= m_file;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ((error= (*file)->ha_delete_all_rows()))
|
if ((error= (*file)->ha_delete_all_rows()))
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
|
/* Ignore the error */
|
||||||
|
if (truncate)
|
||||||
|
(void) (*file)->ha_reset_auto_increment(0);
|
||||||
} while (*(++file));
|
} while (*(++file));
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
@ -419,6 +419,14 @@ int ha_heap::delete_all_rows()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ha_heap::reset_auto_increment(ulonglong value)
|
||||||
|
{
|
||||||
|
file->s->auto_increment= value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int ha_heap::external_lock(THD *thd, int lock_type)
|
int ha_heap::external_lock(THD *thd, int lock_type)
|
||||||
{
|
{
|
||||||
return 0; // No external locking
|
return 0; // No external locking
|
||||||
|
@ -98,6 +98,7 @@ public:
|
|||||||
int reset();
|
int reset();
|
||||||
int external_lock(THD *thd, int lock_type);
|
int external_lock(THD *thd, int lock_type);
|
||||||
int delete_all_rows(void);
|
int delete_all_rows(void);
|
||||||
|
int reset_auto_increment(ulonglong value);
|
||||||
int disable_indexes(uint mode);
|
int disable_indexes(uint mode);
|
||||||
int enable_indexes(uint mode);
|
int enable_indexes(uint mode);
|
||||||
int indexes_are_disabled(void);
|
int indexes_are_disabled(void);
|
||||||
|
@ -1870,6 +1870,12 @@ int ha_myisam::delete_all_rows()
|
|||||||
return mi_delete_all_rows(file);
|
return mi_delete_all_rows(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ha_myisam::reset_auto_increment(ulonglong value)
|
||||||
|
{
|
||||||
|
file->s->state.auto_increment= value;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int ha_myisam::delete_table(const char *name)
|
int ha_myisam::delete_table(const char *name)
|
||||||
{
|
{
|
||||||
return mi_delete_table(name);
|
return mi_delete_table(name);
|
||||||
|
@ -101,6 +101,7 @@ class ha_myisam: public handler
|
|||||||
int reset(void);
|
int reset(void);
|
||||||
int external_lock(THD *thd, int lock_type);
|
int external_lock(THD *thd, int lock_type);
|
||||||
int delete_all_rows(void);
|
int delete_all_rows(void);
|
||||||
|
int reset_auto_increment(ulonglong value);
|
||||||
int disable_indexes(uint mode);
|
int disable_indexes(uint mode);
|
||||||
int enable_indexes(uint mode);
|
int enable_indexes(uint mode);
|
||||||
int indexes_are_disabled(void);
|
int indexes_are_disabled(void);
|
||||||
|
Reference in New Issue
Block a user