Skip to content

Commit 6fc485e

Browse files
committed
Merge ../mysql-5.6-cluster-7.3 into mysql-5.6-cluster-7.4
2 parents 193e380 + 8c72569 commit 6fc485e

File tree

3 files changed

+165
-1
lines changed

3 files changed

+165
-1
lines changed

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ SELECT count(*) >= 20 FROM blocks;
238238
count(*) >= 20
239239
1
240240

241+
show create table ndb$test;
242+
Table Create Table
243+
ndb$test CREATE TABLE `ndb$test` (
244+
`node_id` int(10) unsigned DEFAULT NULL,
245+
`block_number` int(10) unsigned DEFAULT NULL,
246+
`block_instance` int(10) unsigned DEFAULT NULL,
247+
`counter` int(10) unsigned DEFAULT NULL,
248+
`counter2` bigint(20) unsigned DEFAULT NULL
249+
) ENGINE=NDBINFO DEFAULT CHARSET=latin1 COMMENT='for testing'
241250
## 1) More columns in NDB -> allowed, with warning
242251
DROP TABLE ndb$test;
243252
CREATE TABLE ndb$test (node_id int unsigned) ENGINE = ndbinfo;
@@ -354,6 +363,15 @@ ERROR 42000: The used table type doesn't support BLOB/TEXT columns
354363
CREATE TABLE ndb$test (node_id int AUTO_INCREMENT) ENGINE = ndbinfo;
355364
ERROR 42000: The used table type doesn't support AUTO_INCREMENT columns
356365

366+
## Restore original allowing repeated test execution
367+
CREATE TABLE `ndb$test` (
368+
`node_id` int unsigned DEFAULT NULL,
369+
`block_number` int unsigned DEFAULT NULL,
370+
`block_instance` int unsigned DEFAULT NULL,
371+
`counter` int unsigned DEFAULT NULL,
372+
`counter2` bigint unsigned DEFAULT NULL
373+
) ENGINE=NDBINFO COMMENT='for testing';
374+
357375
select distinct node_id
358376
from ndbinfo.diskpagebuffer;
359377
node_id
@@ -706,6 +724,54 @@ select table_schema, table_name, definer from information_schema.views
706724
definer != 'root@localhost';
707725
table_schema table_name definer
708726

727+
set @@optimizer_switch='block_nested_loop=off';
728+
729+
select @a:=0;
730+
731+
select
732+
@a:=@a+1,
733+
a.node_id, b.node_id,
734+
a.block_name, b.block_name,
735+
a.block_instance, b.block_instance,
736+
a.counter_id, b.counter_id,
737+
a.counter_name, b.counter_name,
738+
a.val, b.val
739+
from
740+
ndbinfo.counters a join
741+
ndbinfo.counters b
742+
on
743+
a.node_id = b.node_id;
744+
745+
select @b:=0;
746+
747+
select
748+
@b:=@b+1,
749+
a.node_id, b.node_id,
750+
a.block_name, b.block_name,
751+
a.block_instance, b.block_instance,
752+
a.counter_id, b.counter_id,
753+
a.counter_name, b.counter_name,
754+
a.val, b.val
755+
from
756+
ndbinfo.counters a join
757+
ndbinfo.counters b
758+
on
759+
a.node_id = b.node_id;
760+
761+
Expect both joins to give same row count
762+
(0 diff)
763+
select @a - @b;
764+
@a - @b
765+
0
766+
767+
create temporary table old_count
768+
select counter_name, sum(val) as val
769+
from ndbinfo.counters
770+
where block_name='DBSPJ'
771+
group by counter_name;
772+
drop table old_count;
773+
set @@optimizer_switch=default;
774+
709775
create table numbers(
710776
i int
711777
);

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ SELECT count(*) >= 20 FROM blocks;
103103

104104
# Test incompatible table definition between NDB and MySQL Server
105105
# using the ndb$test table which originally looks like
106+
show create table ndb$test;
106107
# CREATE TABLE `ndb$test` (
107108
# `node_id` int unsigned DEFAULT NULL,
108109
# `block_number` int unsigned DEFAULT NULL,
@@ -189,6 +190,15 @@ CREATE TABLE ndb$test (node_id int, block_number blob) ENGINE = ndbinfo;
189190
--error ER_TABLE_CANT_HANDLE_AUTO_INCREMENT
190191
CREATE TABLE ndb$test (node_id int AUTO_INCREMENT) ENGINE = ndbinfo;
191192

193+
## Restore original allowing repeated test execution
194+
CREATE TABLE `ndb$test` (
195+
`node_id` int unsigned DEFAULT NULL,
196+
`block_number` int unsigned DEFAULT NULL,
197+
`block_instance` int unsigned DEFAULT NULL,
198+
`counter` int unsigned DEFAULT NULL,
199+
`counter2` bigint unsigned DEFAULT NULL
200+
) ENGINE=NDBINFO COMMENT='for testing';
201+
192202
# wl#5567 - exercise table...
193203
# only node_id is guranteed to be same...
194204
# (unless we change cluster config for test)
@@ -316,6 +326,66 @@ select table_schema, table_name, definer from information_schema.views
316326
where table_schema = 'ndbinfo' and
317327
definer != 'root@localhost';
318328

329+
330+
#
331+
# Test buffered joining
332+
#
333+
# BUG#20075747 RND_INIT() ON AN OPEN SCAN IS USED TO REPOSITION THE CURSOR
334+
# - rnd_init() on an open scan is used to reposition the "cursor"
335+
# back to first row
336+
#
337+
set @@optimizer_switch='block_nested_loop=off';
338+
339+
340+
--disable_result_log
341+
342+
select @a:=0;
343+
344+
select
345+
@a:=@a+1,
346+
a.node_id, b.node_id,
347+
a.block_name, b.block_name,
348+
a.block_instance, b.block_instance,
349+
a.counter_id, b.counter_id,
350+
a.counter_name, b.counter_name,
351+
a.val, b.val
352+
from
353+
ndbinfo.counters a join
354+
ndbinfo.counters b
355+
on
356+
a.node_id = b.node_id;
357+
358+
select @b:=0;
359+
360+
select
361+
@b:=@b+1,
362+
a.node_id, b.node_id,
363+
a.block_name, b.block_name,
364+
a.block_instance, b.block_instance,
365+
a.counter_id, b.counter_id,
366+
a.counter_name, b.counter_name,
367+
a.val, b.val
368+
from
369+
ndbinfo.counters a join
370+
ndbinfo.counters b
371+
on
372+
a.node_id = b.node_id;
373+
374+
--enable_result_log
375+
376+
--echo Expect both joins to give same row count
377+
--echo (0 diff)
378+
select @a - @b;
379+
380+
381+
create temporary table old_count
382+
select counter_name, sum(val) as val
383+
from ndbinfo.counters
384+
where block_name='DBSPJ'
385+
group by counter_name;
386+
drop table old_count;
387+
set @@optimizer_switch=default;
388+
319389
# ################################
320390
# Test memory_per_fragment table.
321391
# ################################
@@ -682,4 +752,5 @@ drop view frag_ops;
682752
drop table t1;
683753
drop table t2;
684754

755+
685756
--source ndbinfo_drop.inc

sql/ha_ndbinfo.cc

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -475,6 +475,33 @@ int ha_ndbinfo::rnd_init(bool scan)
475475
}
476476

477477
assert(is_open());
478+
479+
if (m_impl.m_scan_op)
480+
{
481+
/*
482+
It should be impossible to come here with an already open
483+
scan, assumption is that rnd_end() would be called to indicate
484+
that the previous scan should be closed or perhaps like it says
485+
in decsription of rnd_init() that it "may be called two times". Once
486+
to open the cursor and once to position te cursor at first row.
487+
488+
Unfortunately the assumption and description of rnd_init() is not
489+
correct. The rnd_init function is used on an open scan to reposition
490+
it back to first row. For ha_ndbinfo this means closing
491+
the scan and letting it be reopened.
492+
*/
493+
assert(scan); // "only makes sense if scan=1" (from rnd_init() description)
494+
495+
DBUG_PRINT("info", ("Closing scan to position it back to first row"));
496+
497+
// Release the scan operation
498+
g_ndbinfo->releaseScanOperation(m_impl.m_scan_op);
499+
m_impl.m_scan_op = NULL;
500+
501+
// Release pointers to the columns
502+
m_impl.m_columns.clear();
503+
}
504+
478505
assert(m_impl.m_scan_op == NULL); // No scan already ongoing
479506

480507
if (m_impl.m_first_use)

0 commit comments

Comments
 (0)