Skip to content

Commit e248917

Browse files
author
jonas oreland
committed
ndb - merge 70 to 71
2 parents bd50c3f + 57e2e94 commit e248917

25 files changed

+285
-125
lines changed

mysql-test/include/not_ndb_is.inc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Check if cluster is available by selecting from is.engines
3+
# if an error about no such table occurs bail out
4+
#
5+
6+
disable_result_log;
7+
disable_query_log;
8+
9+
--error 0, 1109
10+
select @have_ndb_is:= count(*) from information_schema.plugins
11+
where plugin_name like '%ndb%'
12+
and PLUGIN_TYPE = 'INFORMATION SCHEMA';
13+
14+
15+
if ($mysql_errno){
16+
# For backward compatibility, implement old fashioned way
17+
# to check here ie. use SHOW VARIABLES LIKE "have_ndb"
18+
die Can not determine if server supports ndb without is.engines table;
19+
}
20+
21+
22+
if (`select @have_ndb_is`){
23+
skip NDB information schema table installed;
24+
}
25+
26+
enable_query_log;
27+
enable_result_log;

mysql-test/r/information_schema.result

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ insert into t5 values (10);
3939
create view v1 (c) as
4040
SELECT table_name FROM information_schema.TABLES
4141
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
42-
table_name<>'ndb_binlog_index' AND
43-
table_name<>'ndb_apply_status';
42+
table_name not like 'ndb%';
4443
select * from v1;
4544
c
4645
CHARACTER_SETS
@@ -850,7 +849,7 @@ VIEWS TABLE_NAME select
850849
delete from mysql.user where user='mysqltest_4';
851850
delete from mysql.db where user='mysqltest_4';
852851
flush privileges;
853-
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
852+
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name not like 'ndb%' GROUP BY TABLE_SCHEMA;
854853
table_schema count(*)
855854
information_schema 28
856855
mysql 22
@@ -1230,7 +1229,8 @@ INNER JOIN
12301229
information_schema.columns c1
12311230
ON t.table_schema = c1.table_schema AND
12321231
t.table_name = c1.table_name
1233-
WHERE t.table_schema = 'information_schema' AND
1232+
WHERE t.table_name not like 'ndb%' AND
1233+
t.table_schema = 'information_schema' AND
12341234
c1.ordinal_position =
12351235
( SELECT COALESCE(MIN(c2.ordinal_position),1)
12361236
FROM information_schema.columns c2
@@ -1273,7 +1273,8 @@ INNER JOIN
12731273
information_schema.columns c1
12741274
ON t.table_schema = c1.table_schema AND
12751275
t.table_name = c1.table_name
1276-
WHERE t.table_schema = 'information_schema' AND
1276+
WHERE t.table_name not like 'ndb%' AND
1277+
t.table_schema = 'information_schema' AND
12771278
c1.ordinal_position =
12781279
( SELECT COALESCE(MIN(c2.ordinal_position),1)
12791280
FROM information_schema.columns c2
@@ -1365,7 +1366,8 @@ count(*) as num1
13651366
from information_schema.tables t
13661367
inner join information_schema.columns c1
13671368
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
1368-
where t.table_schema = 'information_schema' and
1369+
where t.table_name not like 'ndb%' and
1370+
t.table_schema = 'information_schema' and
13691371
c1.ordinal_position =
13701372
(select isnull(c2.column_type) -
13711373
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +

mysql-test/r/information_schema_db.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ drop view if exists v1,v2;
33
drop function if exists f1;
44
drop function if exists f2;
55
use INFORMATION_SCHEMA;
6-
show tables;
6+
show tables where Tables_in_information_schema NOT LIKE 'ndb%';
77
Tables_in_information_schema
88
CHARACTER_SETS
99
COLLATIONS

mysql-test/t/information_schema.test

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ insert into t5 values (10);
4444
create view v1 (c) as
4545
SELECT table_name FROM information_schema.TABLES
4646
WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND
47-
table_name<>'ndb_binlog_index' AND
48-
table_name<>'ndb_apply_status';
47+
table_name not like 'ndb%';
4948
select * from v1;
5049

5150
select c,table_name from v1
@@ -539,7 +538,7 @@ flush privileges;
539538
# Bug#9404 information_schema: Weird error messages
540539
# with SELECT SUM() ... GROUP BY queries
541540
#
542-
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name<>'ndb_binlog_index' AND table_name<>'ndb_apply_status' GROUP BY TABLE_SCHEMA;
541+
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') AND table_name not like 'ndb%' GROUP BY TABLE_SCHEMA;
543542

544543

545544
#
@@ -921,7 +920,8 @@ SELECT t.table_name, c1.column_name
921920
information_schema.columns c1
922921
ON t.table_schema = c1.table_schema AND
923922
t.table_name = c1.table_name
924-
WHERE t.table_schema = 'information_schema' AND
923+
WHERE t.table_name not like 'ndb%' AND
924+
t.table_schema = 'information_schema' AND
925925
c1.ordinal_position =
926926
( SELECT COALESCE(MIN(c2.ordinal_position),1)
927927
FROM information_schema.columns c2
@@ -935,7 +935,8 @@ SELECT t.table_name, c1.column_name
935935
information_schema.columns c1
936936
ON t.table_schema = c1.table_schema AND
937937
t.table_name = c1.table_name
938-
WHERE t.table_schema = 'information_schema' AND
938+
WHERE t.table_name not like 'ndb%' AND
939+
t.table_schema = 'information_schema' AND
939940
c1.ordinal_position =
940941
( SELECT COALESCE(MIN(c2.ordinal_position),1)
941942
FROM information_schema.columns c2
@@ -1032,7 +1033,8 @@ select t.table_name, group_concat(t.table_schema, '.', t.table_name),
10321033
from information_schema.tables t
10331034
inner join information_schema.columns c1
10341035
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
1035-
where t.table_schema = 'information_schema' and
1036+
where t.table_name not like 'ndb%' and
1037+
t.table_schema = 'information_schema' and
10361038
c1.ordinal_position =
10371039
(select isnull(c2.column_type) -
10381040
isnull(group_concat(c2.table_schema, '.', c2.table_name)) +

mysql-test/t/information_schema_db.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ drop function if exists f2;
1313

1414
use INFORMATION_SCHEMA;
1515
--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema
16-
show tables;
16+
show tables where Tables_in_INFORMATION_SCHEMA NOT LIKE 'ndb%';
1717
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
1818
show tables from INFORMATION_SCHEMA like 'T%';
1919
create database `inf%`;

mysql-test/t/mysqlshow.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Can't run test of external client with embedded server
22
-- source include/not_embedded.inc
33

4+
# Test lists tables in Information_schema, and ndb adds some
5+
-- source include/not_ndb_is.inc
6+
47
--disable_warnings
58
DROP TABLE IF EXISTS t1,t2,test1,test2;
69
--enable_warnings

sql/ha_ndb_index_stat.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,7 @@ ndb_index_stat_thread_func(void *arg __attribute__((unused)))
19841984
}
19851985

19861986
/* Get thd_ndb for this thread */
1987-
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
1987+
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb(thd)))
19881988
{
19891989
sql_print_error("Could not allocate Thd_ndb object");
19901990
pthread_mutex_lock(&LOCK_ndb_index_stat_thread);

sql/ha_ndbcluster.cc

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11419,7 +11419,8 @@ int ha_ndbcluster::close(void)
1141911419
wait on condition for a Ndb object to be released.
1142011420
- Alt.2 Seize/release from pool, wait until next release
1142111421
*/
11422-
Thd_ndb* ha_ndbcluster::seize_thd_ndb()
11422+
Thd_ndb*
11423+
ha_ndbcluster::seize_thd_ndb(THD * thd)
1142311424
{
1142411425
Thd_ndb *thd_ndb;
1142511426
DBUG_ENTER("seize_thd_ndb");
@@ -11442,6 +11443,10 @@ Thd_ndb* ha_ndbcluster::seize_thd_ndb()
1144211443
delete thd_ndb;
1144311444
thd_ndb= NULL;
1144411445
}
11446+
else
11447+
{
11448+
thd_ndb->ndb->setCustomData64(thd_get_thread_id(thd));
11449+
}
1144511450
DBUG_RETURN(thd_ndb);
1144611451
}
1144711452

@@ -11478,7 +11483,10 @@ bool Thd_ndb::recycle_ndb(THD* thd)
1147811483
ndb->getNdbError().message));
1147911484
DBUG_RETURN(false);
1148011485
}
11481-
11486+
else
11487+
{
11488+
ndb->setCustomData64(thd_get_thread_id(thd));
11489+
}
1148211490
DBUG_RETURN(true);
1148311491
}
1148411492

@@ -11516,7 +11524,7 @@ Ndb* check_ndb_in_thd(THD* thd, bool validate_ndb)
1151611524
Thd_ndb *thd_ndb= get_thd_ndb(thd);
1151711525
if (!thd_ndb)
1151811526
{
11519-
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
11527+
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb(thd)))
1152011528
return NULL;
1152111529
set_thd_ndb(thd, thd_ndb);
1152211530
}
@@ -14850,7 +14858,7 @@ pthread_handler_t ndb_util_thread_func(void *arg __attribute__((unused)))
1485014858
pthread_mutex_unlock(&LOCK_ndb_util_thread);
1485114859

1485214860
/* Get thd_ndb for this thread */
14853-
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
14861+
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb(thd)))
1485414862
{
1485514863
sql_print_error("Could not allocate Thd_ndb object");
1485614864
pthread_mutex_lock(&LOCK_ndb_util_thread);
@@ -17310,12 +17318,8 @@ struct st_mysql_storage_engine ndbcluster_storage_engine=
1731017318
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
1731117319

1731217320

17313-
#include "ha_ndbinfo.h"
17314-
17315-
extern struct st_mysql_sys_var* ndbinfo_system_variables[];
17316-
17317-
struct st_mysql_storage_engine ndbinfo_storage_engine=
17318-
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
17321+
extern struct st_mysql_plugin i_s_ndb_transid_mysql_connection_map_plugin;
17322+
extern struct st_mysql_plugin ndbinfo_plugin;
1731917323

1732017324
mysql_declare_plugin(ndbcluster)
1732117325
{
@@ -17332,20 +17336,9 @@ mysql_declare_plugin(ndbcluster)
1733217336
system_variables, /* system variables */
1733317337
NULL /* config options */
1733417338
},
17335-
{
17336-
MYSQL_STORAGE_ENGINE_PLUGIN,
17337-
&ndbinfo_storage_engine,
17338-
"ndbinfo",
17339-
"Sun Microsystems Inc.",
17340-
"MySQL Cluster system information storage engine",
17341-
PLUGIN_LICENSE_GPL,
17342-
ndbinfo_init, /* plugin init */
17343-
ndbinfo_deinit, /* plugin deinit */
17344-
0x0001, /* plugin version */
17345-
NULL, /* status variables */
17346-
ndbinfo_system_variables, /* system variables */
17347-
NULL /* config options */
17348-
}
17339+
ndbinfo_plugin, /* ndbinfo plugin */
17340+
/* IS plugin table which maps between mysql connection id and ndb trans-id */
17341+
i_s_ndb_transid_mysql_connection_map_plugin
1734917342
mysql_declare_plugin_end;
1735017343

1735117344
#endif

sql/ha_ndbcluster.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ class ha_ndbcluster: public handler
682682
int ndb_update_row(const uchar *old_data, uchar *new_data,
683683
int is_bulk_update);
684684

685-
static Thd_ndb* seize_thd_ndb();
685+
static Thd_ndb* seize_thd_ndb(THD*);
686686
static void release_thd_ndb(Thd_ndb* thd_ndb);
687687

688688
static void set_dbname(const char *pathname, char *dbname);

sql/ha_ndbcluster_binlog.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ int ndbcluster_log_schema_op(THD *thd,
20982098
Thd_ndb *thd_ndb= get_thd_ndb(thd);
20992099
if (!thd_ndb)
21002100
{
2101-
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
2101+
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb(thd)))
21022102
{
21032103
sql_print_error("Could not allocate Thd_ndb object");
21042104
DBUG_RETURN(1);
@@ -6765,7 +6765,7 @@ ndb_binlog_thread_func(void *arg)
67656765
int have_injector_mutex_lock= 0;
67666766
do_ndbcluster_binlog_close_connection= BCCC_exit;
67676767

6768-
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb()))
6768+
if (!(thd_ndb= ha_ndbcluster::seize_thd_ndb(thd)))
67696769
{
67706770
sql_print_error("Could not allocate Thd_ndb object");
67716771
ndb_binlog_thread_running= -1;

sql/ha_ndbcluster_connection.cc

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,115 @@ void ndb_get_connection_stats(Uint64* statsArr)
306306
}
307307
}
308308

309+
static ST_FIELD_INFO ndb_transid_mysql_connection_map_fields_info[] =
310+
{
311+
{
312+
"mysql_connection_id",
313+
MY_INT64_NUM_DECIMAL_DIGITS,
314+
MYSQL_TYPE_LONGLONG,
315+
0,
316+
MY_I_S_UNSIGNED,
317+
"",
318+
SKIP_OPEN_TABLE
319+
},
320+
321+
{
322+
"node_id",
323+
MY_INT64_NUM_DECIMAL_DIGITS,
324+
MYSQL_TYPE_LONG,
325+
0,
326+
MY_I_S_UNSIGNED,
327+
"",
328+
SKIP_OPEN_TABLE
329+
},
330+
{
331+
"ndb_transid",
332+
MY_INT64_NUM_DECIMAL_DIGITS,
333+
MYSQL_TYPE_LONGLONG,
334+
0,
335+
MY_I_S_UNSIGNED,
336+
"",
337+
SKIP_OPEN_TABLE
338+
},
339+
340+
{ 0, 0, MYSQL_TYPE_NULL, 0, 0, "", SKIP_OPEN_TABLE }
341+
};
342+
343+
static
344+
int
345+
ndb_transid_mysql_connection_map_fill_table(THD* thd, TABLE_LIST* tables, COND* cond)
346+
{
347+
DBUG_ENTER("ndb_transid_mysql_connection_map_fill_table");
348+
349+
if (check_global_access(thd, PROCESS_ACL))
350+
{
351+
DBUG_RETURN(0);
352+
}
353+
354+
TABLE* table= tables->table;
355+
for (uint i = 0; i<g_pool_alloc; i++)
356+
{
357+
if (g_pool[i])
358+
{
359+
g_pool[i]->lock_ndb_objects();
360+
const Ndb * p = g_pool[i]->get_next_ndb_object(0);
361+
while (p)
362+
{
363+
table->field[0]->set_notnull();
364+
table->field[0]->store(p->getCustomData64(), true);
365+
table->field[1]->set_notnull();
366+
table->field[1]->store(g_pool[i]->node_id());
367+
table->field[2]->set_notnull();
368+
table->field[2]->store(p->getNextTransactionId(), true);
369+
schema_table_store_record(thd, table);
370+
p = g_pool[i]->get_next_ndb_object(p);
371+
}
372+
g_pool[i]->unlock_ndb_objects();
373+
}
374+
}
375+
376+
DBUG_RETURN(0);
377+
}
378+
379+
static
380+
int
381+
ndb_transid_mysql_connection_map_init(void *p)
382+
{
383+
DBUG_ENTER("ndb_transid_mysql_connection_map_init");
384+
ST_SCHEMA_TABLE* schema = reinterpret_cast<ST_SCHEMA_TABLE*>(p);
385+
schema->fields_info = ndb_transid_mysql_connection_map_fields_info;
386+
schema->fill_table = ndb_transid_mysql_connection_map_fill_table;
387+
DBUG_RETURN(0);
388+
}
389+
390+
static
391+
int
392+
ndb_transid_mysql_connection_map_deinit(void *p)
393+
{
394+
DBUG_ENTER("ndb_transid_mysql_connection_map_deinit");
395+
DBUG_RETURN(0);
396+
}
397+
398+
#include <mysql/plugin.h>
399+
static struct st_mysql_information_schema i_s_info =
400+
{
401+
MYSQL_INFORMATION_SCHEMA_INTERFACE_VERSION
402+
};
403+
404+
struct st_mysql_plugin i_s_ndb_transid_mysql_connection_map_plugin =
405+
{
406+
MYSQL_INFORMATION_SCHEMA_PLUGIN,
407+
&i_s_info,
408+
"ndb_transid_mysql_connection_map",
409+
"Oracle Corporation",
410+
"Map between mysql connection id and ndb transaction id",
411+
PLUGIN_LICENSE_GPL,
412+
ndb_transid_mysql_connection_map_init,
413+
ndb_transid_mysql_connection_map_deinit,
414+
0x0001,
415+
NULL,
416+
NULL,
417+
NULL
418+
};
419+
309420
#endif /* WITH_NDBCLUSTER_STORAGE_ENGINE */

0 commit comments

Comments
 (0)