Skip to content

Commit b68dad1

Browse files
committed
ndbinfo
- backport to 7.0.10 - add trp_status table and view - add log_space table and view - add ndbinfo_sql and make it generate ndbinfo.sql
1 parent 4259065 commit b68dad1

74 files changed

Lines changed: 4213 additions & 1841 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

libmysqld/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ noinst_HEADERS = embedded_priv.h emb_qcache.h
4848

4949
sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \
5050
ha_ndbcluster.cc ha_ndbcluster_cond.cc \
51-
ha_ndbcluster_connection.cc \
51+
ha_ndbcluster_connection.cc ha_ndbinfo.cc \
5252
ha_ndbcluster_binlog.cc ha_partition.cc \
5353
handler.cc sql_handler.cc \
5454
hostname.cc init.cc password.c \
@@ -120,6 +120,9 @@ ha_ndbcluster_binlog.o: ha_ndbcluster_binlog.cc
120120
ha_ndbcluster_connection.o: ha_ndbcluster_connection.cc
121121
$(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
122122

123+
ha_ndbinfo.o: ha_ndbinfo.cc
124+
$(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<
125+
123126
# Until we can remove dependency on ha_ndbcluster.h
124127
handler.o: handler.cc
125128
$(CXXCOMPILE) @ndbcluster_includes@ $(LM_CFLAGS) -c $<

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ ndb_table_temporary #
4444
ndb_use_copying_alter_table #
4545
ndb_use_exact_count #
4646
ndb_use_transactions #
47+
ndbinfo_database #
48+
ndbinfo_max_bytes #
49+
ndbinfo_max_rows #
50+
ndbinfo_show_hidden #
51+
ndbinfo_table_prefix #
4752
CREATE TABLE t1 (
4853
pk1 INT NOT NULL PRIMARY KEY,
4954
attr1 INT NOT NULL,
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
result_format: 2
2+
3+
4+
SELECT * FROM information_schema.plugins WHERE PLUGIN_NAME = 'ndbinfo';
5+
PLUGIN_NAME PLUGIN_VERSION PLUGIN_STATUS PLUGIN_TYPE PLUGIN_TYPE_VERSION PLUGIN_LIBRARY PLUGIN_LIBRARY_VERSION PLUGIN_AUTHOR PLUGIN_DESCRIPTION PLUGIN_LICENSE
6+
ndbinfo 0.1 ACTIVE STORAGE ENGINE 50139.0 NULL NULL Sun Microsystems Inc. MySQL Cluster system information storage engine GPL
7+
8+
## Creation of temporary tables should not be supported by NDBINFO engine
9+
CREATE TEMPORARY TABLE `t1` (
10+
`dummy` INT UNSIGNED
11+
) ENGINE=NDBINFO;
12+
ERROR HY000: Table storage engine 'ndbinfo' does not support the create option 'TEMPORARY'
13+
14+
@have_ndbinfo:= COUNT(*)
15+
1
16+
USE ndbinfo;
17+
18+
SHOW CREATE TABLE ndb$tables;
19+
Table Create Table
20+
ndb$tables CREATE TABLE `ndb$tables` (
21+
`table_id` int(10) unsigned DEFAULT NULL,
22+
`table_name` varchar(512) DEFAULT NULL,
23+
`comment` varchar(512) DEFAULT NULL
24+
) ENGINE=NDBINFO DEFAULT CHARSET=latin1
25+
26+
SELECT * FROM ndb$tables;
27+
table_id table_name comment
28+
0 tables
29+
1 columns
30+
2 memusage
31+
3 logdestination
32+
4 backup_records
33+
5 backup_parameters
34+
6 pools
35+
7 test
36+
8 trp_status
37+
SELECT COUNT(*) FROM ndb$tables;
38+
COUNT(*)
39+
9
40+
SELECT * FROM ndb$tables WHERE table_id = 2;
41+
table_id table_name comment
42+
2 memusage
43+
SELECT * FROM ndb$tables WHERE table_id > 5;
44+
table_id table_name comment
45+
6 pools
46+
7 test
47+
8 trp_status
48+
SELECT * FROM ndb$tables WHERE table_name = 'LOGDESTINATION';
49+
table_id table_name comment
50+
3 logdestination
51+
SELECT COUNT(*) FROM ndb$tables t1, ndb$tables t2 WHERE t1.table_id = t1.table_id;
52+
COUNT(*)
53+
81
54+
55+
SELECT table_id, table_name, comment from ndb$tables
56+
WHERE table_id > 2 AND table_id <= 5 ORDER BY table_id;
57+
table_id table_name comment
58+
3 logdestination
59+
4 backup_records
60+
5 backup_parameters
61+
SELECT table_id FROM ndb$tables WHERE table_id = 2 ORDER BY table_name;
62+
table_id
63+
2
64+
SELECT table_id, table_name FROM ndb$tables ORDER BY table_name;
65+
table_id table_name
66+
5 backup_parameters
67+
4 backup_records
68+
1 columns
69+
3 logdestination
70+
2 memusage
71+
6 pools
72+
0 tables
73+
7 test
74+
8 trp_status
75+
76+
SELECT table_id, column_id, column_name FROM ndb$columns LIMIT 7;
77+
table_id column_id column_name
78+
0 0 table_id
79+
0 1 table_name
80+
0 2 comment
81+
1 0 table_id
82+
1 1 column_id
83+
1 2 column_name
84+
1 3 column_type
85+
86+
UPDATE ndb$tables SET table_id=2 WHERE table_id=3;
87+
ERROR HY000: Table 'ndb$tables' is read only
88+
89+
UPDATE ndb$tables SET table_id=9 WHERE 1=0;
90+
ERROR HY000: Table 'ndb$tables' is read only
91+
92+
UPDATE ndb$tables SET table_id=9 WHERE table_id > 1;
93+
ERROR HY000: Table 'ndb$tables' is read only
94+
95+
DELETE FROM ndb$tables WHERE table_id=3;
96+
ERROR HY000: Table 'ndb$tables' is read only
97+
98+
DELETE FROM ndb$tables WHERE 1=0;
99+
ERROR HY000: Table 'ndb$tables' is read only
100+
101+
DELETE FROM ndb$tables WHERE table_id > 1;
102+
ERROR HY000: Table 'ndb$tables' is read only
103+
104+
FLUSH TABLES;
105+
SELECT table_id FROM ndb$tables;
106+
table_id
107+
0
108+
1
109+
2
110+
3
111+
4
112+
5
113+
6
114+
7
115+
8
116+
117+
TRUNCATE ndb$tables;
118+
ERROR HY000: Table 'ndb$tables' is read only
119+
120+
## Variables and status
121+
SHOW GLOBAL STATUS LIKE 'ndbinfo\_%';
122+
Variable_name Value
123+
SHOW GLOBAL VARIABLES LIKE 'ndbinfo\_%';
124+
Variable_name Value
125+
ndbinfo_database ndbinfo
126+
ndbinfo_max_bytes 0
127+
ndbinfo_max_rows 10
128+
ndbinfo_show_hidden OFF
129+
ndbinfo_table_prefix ndb$
130+
131+
SELECT counter, HEX(counter2) FROM ndb$test LIMIT 10;
132+
counter HEX(counter2)
133+
0 0
134+
1 100000000
135+
2 200000000
136+
3 300000000
137+
4 400000000
138+
5 500000000
139+
6 600000000
140+
7 700000000
141+
8 800000000
142+
9 900000000
143+
144+
SHOW TABLES LIKE 'ndb$te%';
145+
Tables_in_ndbinfo (ndb$te%)
146+
set @@ndbinfo_show_hidden=TRUE;
147+
SHOW TABLES LIKE 'ndb$te%';
148+
Tables_in_ndbinfo (ndb$te%)
149+
ndb$test
150+
set @@ndbinfo_show_hidden=default;
151+
152+
set @@ndbinfo_table_prefix="somethingelse";
153+
ERROR HY000: Variable 'ndbinfo_table_prefix' is a read only variable
154+
155+
set @@ndbinfo_database="somethingelse";
156+
ERROR HY000: Variable 'ndbinfo_database' is a read only variable
157+
158+
## Cleanup
159+
DROP DATABASE ndbinfo;
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
--result_format 2
2+
--source include/have_ndb.inc
3+
--source have_ndbinfo.inc
4+
5+
SELECT * FROM information_schema.plugins WHERE PLUGIN_NAME = 'ndbinfo';
6+
7+
## Creation of temporary tables should not be supported by NDBINFO engine
8+
--error ER_ILLEGAL_HA_CREATE_OPTION
9+
CREATE TEMPORARY TABLE `t1` (
10+
`dummy` INT UNSIGNED
11+
) ENGINE=NDBINFO;
12+
13+
# Run the ndbinfo.sql script that creates ndbinfo database, tables and views
14+
--exec $MYSQL < $NDBINFO_SQL 2>&1
15+
16+
USE ndbinfo;
17+
18+
SHOW CREATE TABLE ndb$tables;
19+
20+
SELECT * FROM ndb$tables;
21+
SELECT COUNT(*) FROM ndb$tables;
22+
SELECT * FROM ndb$tables WHERE table_id = 2;
23+
SELECT * FROM ndb$tables WHERE table_id > 5;
24+
SELECT * FROM ndb$tables WHERE table_name = 'LOGDESTINATION';
25+
SELECT COUNT(*) FROM ndb$tables t1, ndb$tables t2 WHERE t1.table_id = t1.table_id;
26+
27+
SELECT table_id, table_name, comment from ndb$tables
28+
WHERE table_id > 2 AND table_id <= 5 ORDER BY table_id;
29+
SELECT table_id FROM ndb$tables WHERE table_id = 2 ORDER BY table_name;
30+
SELECT table_id, table_name FROM ndb$tables ORDER BY table_name;
31+
32+
SELECT table_id, column_id, column_name FROM ndb$columns LIMIT 7;
33+
34+
--error ER_OPEN_AS_READONLY
35+
UPDATE ndb$tables SET table_id=2 WHERE table_id=3;
36+
37+
--error ER_OPEN_AS_READONLY
38+
UPDATE ndb$tables SET table_id=9 WHERE 1=0;
39+
40+
--error ER_OPEN_AS_READONLY
41+
UPDATE ndb$tables SET table_id=9 WHERE table_id > 1;
42+
43+
--error ER_OPEN_AS_READONLY
44+
DELETE FROM ndb$tables WHERE table_id=3;
45+
46+
--error ER_OPEN_AS_READONLY
47+
DELETE FROM ndb$tables WHERE 1=0;
48+
49+
--error ER_OPEN_AS_READONLY
50+
DELETE FROM ndb$tables WHERE table_id > 1;
51+
52+
FLUSH TABLES;
53+
SELECT table_id FROM ndb$tables;
54+
55+
--error ER_OPEN_AS_READONLY
56+
TRUNCATE ndb$tables;
57+
58+
## Variables and status
59+
SHOW GLOBAL STATUS LIKE 'ndbinfo\_%';
60+
SHOW GLOBAL VARIABLES LIKE 'ndbinfo\_%';
61+
62+
SELECT counter, HEX(counter2) FROM ndb$test LIMIT 10;
63+
64+
# All tables that contain data are hidden by default
65+
# and becomes visible with ndbinfo_show_hidden
66+
SHOW TABLES LIKE 'ndb$te%';
67+
set @@ndbinfo_show_hidden=TRUE;
68+
SHOW TABLES LIKE 'ndb$te%';
69+
set @@ndbinfo_show_hidden=default;
70+
71+
# Check that ndbinfo_table_prefix is readonly
72+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
73+
set @@ndbinfo_table_prefix="somethingelse";
74+
75+
# Check that ndbinfo_database is readonly
76+
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
77+
set @@ndbinfo_database="somethingelse";
78+
79+
## Cleanup
80+
DROP DATABASE ndbinfo;

sql/Makefile.am

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \
6161
ha_ndbcluster.h ha_ndbcluster_cond.h \
6262
ha_ndbcluster_binlog.h ha_ndbcluster_tables.h \
6363
ha_ndbcluster_connection.h ha_ndbcluster_connection.h \
64-
ha_ndbcluster_lock_ext.h \
64+
ha_ndbcluster_lock_ext.h ha_ndbinfo.h \
6565
ha_partition.h rpl_constants.h \
6666
opt_range.h protocol.h rpl_tblmap.h rpl_utility.h \
6767
rpl_reporting.h \
@@ -133,7 +133,8 @@ libndb_la_CPPFLAGS= @ndbcluster_includes@
133133
libndb_la_SOURCES= ha_ndbcluster.cc \
134134
ha_ndbcluster_binlog.cc \
135135
ha_ndbcluster_connection.cc \
136-
ha_ndbcluster_cond.cc
136+
ha_ndbcluster_cond.cc \
137+
ha_ndbinfo.cc
137138

138139
gen_lex_hash_SOURCES = gen_lex_hash.cc
139140
gen_lex_hash_LDFLAGS = @NOINST_LDFLAGS@

sql/ha_ndbcluster.cc

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13473,6 +13473,14 @@ SHOW_VAR ndb_status_variables_export[]= {
1347313473
struct st_mysql_storage_engine ndbcluster_storage_engine=
1347413474
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
1347513475

13476+
13477+
#include "ha_ndbinfo.h"
13478+
13479+
extern struct st_mysql_sys_var* ndbinfo_system_variables[];
13480+
13481+
struct st_mysql_storage_engine ndbinfo_storage_engine=
13482+
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
13483+
1347613484
mysql_declare_plugin(ndbcluster)
1347713485
{
1347813486
MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -13481,12 +13489,26 @@ mysql_declare_plugin(ndbcluster)
1348113489
"MySQL AB",
1348213490
"Clustered, fault-tolerant tables",
1348313491
PLUGIN_LICENSE_GPL,
13484-
ndbcluster_init, /* Plugin Init */
13485-
NULL, /* Plugin Deinit */
13486-
0x0100 /* 1.0 */,
13492+
ndbcluster_init, /* plugin init */
13493+
NULL, /* plugin deinit */
13494+
0x0100, /* plugin version */
1348713495
ndb_status_variables_export,/* status variables */
1348813496
NULL, /* system variables */
1348913497
NULL /* config options */
13498+
},
13499+
{
13500+
MYSQL_STORAGE_ENGINE_PLUGIN,
13501+
&ndbinfo_storage_engine,
13502+
"ndbinfo",
13503+
"Sun Microsystems Inc.",
13504+
"MySQL Cluster system information storage engine",
13505+
PLUGIN_LICENSE_GPL,
13506+
ndbinfo_init, /* plugin init */
13507+
ndbinfo_deinit, /* plugin deinit */
13508+
0x0001, /* plugin version */
13509+
NULL, /* status variables */
13510+
ndbinfo_system_variables, /* system variables */
13511+
NULL /* config options */
1349013512
}
1349113513
mysql_declare_plugin_end;
1349213514

0 commit comments

Comments
 (0)