Skip to content

Commit b842b3c

Browse files
author
Mattias Jonsson
committed
Manual merge branch 'mysql-5.6' into mysql-5.7
of post-push fix for bug#19856162 including removal of non-used HA_PARTITION_ONE_PHASE define and code. Conflicts: sql/sql_partition.cc
2 parents 2c5a1eb + a57aae9 commit b842b3c

File tree

4 files changed

+24
-65
lines changed

4 files changed

+24
-65
lines changed

mysql-test/suite/ndb/r/ndb_partition_key.result

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ERROR HY000: A PRIMARY KEY must include all columns in the table's partitioning
2121
CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b))
2222
ENGINE = NDB
2323
PARTITION BY KEY (a);
24+
ALTER TABLE t1 REORGANIZE PARTITION;
2425
insert into t1 values
2526
(1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3),
2627
(1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3);
@@ -322,8 +323,12 @@ a b c
322323
2 22 7
323324
ndb_scan_count
324325
1
326+
Warnings:
327+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
325328
ndb_pruned_scan_count
326329
0
330+
Warnings:
331+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
327332
Single partition scan
328333
select * from nott1 where a=0 order by c;
329334
a b c
@@ -333,15 +338,23 @@ a b c
333338
0 3 3
334339
ndb_scan_count
335340
1
341+
Warnings:
342+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
336343
ndb_pruned_scan_count
337344
1
345+
Warnings:
346+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
338347
Single partition scan
339348
select * from nott1 where a=4 order by c;
340349
a b c
341350
ndb_scan_count
342351
1
352+
Warnings:
353+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
343354
ndb_pruned_scan_count
344355
1
356+
Warnings:
357+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
345358
MRR scan on one partition
346359
select * from nott1 where a=0 and (( b > 0 and b < 3) or
347360
( b > 5 and b < 10) or
@@ -351,8 +364,12 @@ a b c
351364
0 2 2
352365
ndb_scan_count
353366
1
367+
Warnings:
368+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
354369
ndb_pruned_scan_count
355370
1
371+
Warnings:
372+
Warning 1287 'INFORMATION_SCHEMA.SESSION_STATUS' is deprecated and will be removed in a future release. Please use performance_schema.session_status instead
356373
drop table nott1;
357374
CREATE TABLE t1 (
358375
a char(10) NOT NULL,

mysql-test/suite/ndb/t/ndb_partition_key.test

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ CREATE TABLE t1 (a int, b int, c int, PRIMARY KEY(a,b))
3737
ENGINE = NDB
3838
PARTITION BY KEY (a);
3939

40+
# Trigger assert from bug#19856162 with an alter table
41+
# not actually doing any changes to partitioniong
42+
ALTER TABLE t1 REORGANIZE PARTITION;
43+
4044
insert into t1 values
4145
(1,1,3),(1,2,3),(1,3,3),(1,4,3),(1,5,3),(1,6,3),
4246
(1,7,3),(1,8,3),(1,9,3),(1,10,3),(1,11,3),(1,12,3);

sql/partitioning/partition_handler.h

-9
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,9 @@ static const uint NO_CURRENT_PART_ID= UINT_MAX32;
5555
The new idea is that handlers will handle the lock level already in
5656
store_lock for ALTER TABLE partitions.
5757
TODO: Implement this via the alter-inplace api.
58-
59-
HA_PARTITION_ONE_PHASE is a flag that can be set by handlers that take
60-
care of changing the partitions online and in one phase. Thus all phases
61-
needed to handle the change are implemented inside the storage engine.
62-
The storage engine must also support auto-discovery since the frm file
63-
is changed as part of the change and this change must be controlled by
64-
the storage engine. A typical engine to support this is NDB (through
65-
WL #2498).
6658
*/
6759
#define HA_PARTITION_FUNCTION_SUPPORTED (1L << 0)
6860
#define HA_FAST_CHANGE_PARTITION (1L << 1)
69-
#define HA_PARTITION_ONE_PHASE (1L << 2)
7061

7162
enum enum_part_operation {
7263
OPTIMIZE_PARTS= 0,

sql/sql_partition.cc

+3-56
Original file line numberDiff line numberDiff line change
@@ -4969,9 +4969,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
49694969
without any changes at all.
49704970
*/
49714971
flags= part_handler->alter_flags(alter_info->flags);
4972-
DBUG_ASSERT(flags & (HA_FAST_CHANGE_PARTITION |
4973-
HA_PARTITION_ONE_PHASE));
4974-
if (flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE))
4972+
if ((flags & HA_FAST_CHANGE_PARTITION) != 0)
49754973
{
49764974
*new_part_info= tab_part_info;
49774975
/* Force table re-open for consistency with the main case. */
@@ -5005,7 +5003,7 @@ uint prep_alter_part_table(THD *thd, TABLE *table, Alter_info *alter_info,
50055003
my_error(ER_PARTITION_FUNCTION_FAILURE, MYF(0));
50065004
goto err;
50075005
}
5008-
if ((flags & (HA_FAST_CHANGE_PARTITION | HA_PARTITION_ONE_PHASE)) != 0)
5006+
if ((flags & HA_FAST_CHANGE_PARTITION) != 0)
50095007
{
50105008
/*
50115009
"Fast" change of partitioning is supported in this case.
@@ -6825,58 +6823,7 @@ bool fast_alter_partition_table(THD *thd,
68256823
my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
68266824
DBUG_RETURN(true);
68276825
}
6828-
if (part_handler->alter_flags(alter_info->flags) & HA_PARTITION_ONE_PHASE)
6829-
{
6830-
/*
6831-
In the case where the engine supports one phase online partition
6832-
changes it is not necessary to have any exclusive locks. The
6833-
correctness is upheld instead by transactions being aborted if they
6834-
access the table after its partition definition has changed (if they
6835-
are still using the old partition definition).
6836-
6837-
The handler is in this case responsible to ensure that all users
6838-
start using the new frm file after it has changed. To implement
6839-
one phase it is necessary for the handler to have the master copy
6840-
of the frm file and use discovery mechanisms to renew it. Thus
6841-
write frm will write the frm, pack the new frm and finally
6842-
the frm is deleted and the discovery mechanisms will either restore
6843-
back to the old or installing the new after the change is activated.
6844-
6845-
Thus all open tables will be discovered that they are old, if not
6846-
earlier as soon as they try an operation using the old table. One
6847-
should ensure that this is checked already when opening a table,
6848-
even if it is found in the cache of open tables.
6849-
6850-
change_partitions will perform all operations and it is the duty of
6851-
the handler to ensure that the frm files in the system gets updated
6852-
in synch with the changes made and if an error occurs that a proper
6853-
error handling is done.
6854-
6855-
If the MySQL Server crashes at this moment but the handler succeeds
6856-
in performing the change then the binlog is not written for the
6857-
change. There is no way to solve this as long as the binlog is not
6858-
transactional and even then it is hard to solve it completely.
6859-
6860-
The first approach here was to downgrade locks. Now a different approach
6861-
is decided upon. The idea is that the handler will have access to the
6862-
Alter_info when store_lock arrives with TL_WRITE_ALLOW_READ. So if the
6863-
handler knows that this functionality can be handled with a lower lock
6864-
level it will set the lock level to TL_WRITE_ALLOW_WRITE immediately.
6865-
Thus the need to downgrade the lock disappears.
6866-
1) Write the new frm, pack it and then delete it
6867-
2) Perform the change within the handler
6868-
*/
6869-
/* No engine supports this yet, so this is not yet tested! */
6870-
DBUG_ASSERT(0);
6871-
if (mysql_write_frm(lpt, WFRM_WRITE_SHADOW | WFRM_PACK_FRM) ||
6872-
mysql_change_partitions(lpt))
6873-
{
6874-
DBUG_RETURN(true);
6875-
}
6876-
fast_end_partition(thd, lpt->copied, lpt->deleted, table_list);
6877-
DBUG_RETURN(false);
6878-
}
6879-
else if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION)
6826+
if (alter_info->flags & Alter_info::ALTER_DROP_PARTITION)
68806827
{
68816828
/*
68826829
Now after all checks and setting state on dropped partitions we can

0 commit comments

Comments
 (0)