Skip to content

Commit 2c8ec68

Browse files
author
jonas oreland
committed
ndb - merge 71 to 72
2 parents f2c6ff8 + e248917 commit 2c8ec68

23 files changed

+269
-108
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,8 @@ count(*) as num1
12981298
from information_schema.tables t
12991299
inner join information_schema.columns c1
13001300
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
1301-
where t.table_schema = 'information_schema' and
1301+
where t.table_name not like 'ndb%' and
1302+
t.table_schema = 'information_schema' and
13021303
c1.ordinal_position =
13031304
(select isnull(c2.column_type) -
13041305
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 where Tables_in_information_schema NOT LIKE 'Innodb%';
6+
show tables where Tables_in_information_schema NOT LIKE 'Innodb%' and 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,8 @@ select t.table_name, group_concat(t.table_schema, '.', t.table_name),
10051005
from information_schema.tables t
10061006
inner join information_schema.columns c1
10071007
on t.table_schema = c1.table_schema AND t.table_name = c1.table_name
1008-
where t.table_schema = 'information_schema' and
1008+
where t.table_name not like 'ndb%' and
1009+
t.table_schema = 'information_schema' and
10091010
c1.ordinal_position =
10101011
(select isnull(c2.column_type) -
10111012
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
@@ -16,7 +16,7 @@ drop function if exists f2;
1616

1717
use INFORMATION_SCHEMA;
1818
--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema
19-
show tables where Tables_in_INFORMATION_SCHEMA NOT LIKE 'Innodb%';
19+
show tables where Tables_in_INFORMATION_SCHEMA NOT LIKE 'Innodb%' and Tables_in_INFORMATION_SCHEMA NOT LIKE 'ndb%';
2020
--replace_result 'Tables_in_INFORMATION_SCHEMA (T%)' 'Tables_in_information_schema (T%)'
2121
show tables from INFORMATION_SCHEMA like 'T%';
2222
create database `inf%`;

mysql-test/t/mysqlshow.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# Don't test when thread_pool active
66
--source include/not_threadpool.inc
77

8+
# Test lists tables in Information_schema, and ndb adds some
9+
-- source include/not_ndb_is.inc
10+
811
--disable_warnings
912
DROP TABLE IF EXISTS t1,t2,test1,test2;
1013
--enable_warnings

sql/ha_ndbcluster.cc

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18213,12 +18213,8 @@ struct st_mysql_storage_engine ndbcluster_storage_engine=
1821318213
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
1821418214

1821518215

18216-
#include "ha_ndbinfo.h"
18217-
18218-
extern struct st_mysql_sys_var* ndbinfo_system_variables[];
18219-
18220-
struct st_mysql_storage_engine ndbinfo_storage_engine=
18221-
{ MYSQL_HANDLERTON_INTERFACE_VERSION };
18216+
extern struct st_mysql_plugin i_s_ndb_transid_mysql_connection_map_plugin;
18217+
extern struct st_mysql_plugin ndbinfo_plugin;
1822218218

1822318219
mysql_declare_plugin(ndbcluster)
1822418220
{
@@ -18236,21 +18232,9 @@ mysql_declare_plugin(ndbcluster)
1823618232
NULL, /* config options */
1823718233
0 /* flags */
1823818234
},
18239-
{
18240-
MYSQL_STORAGE_ENGINE_PLUGIN,
18241-
&ndbinfo_storage_engine,
18242-
"ndbinfo",
18243-
"Sun Microsystems Inc.",
18244-
"MySQL Cluster system information storage engine",
18245-
PLUGIN_LICENSE_GPL,
18246-
ndbinfo_init, /* plugin init */
18247-
ndbinfo_deinit, /* plugin deinit */
18248-
0x0001, /* plugin version */
18249-
NULL, /* status variables */
18250-
ndbinfo_system_variables, /* system variables */
18251-
NULL, /* config options */
18252-
0 /* flags */
18253-
}
18235+
ndbinfo_plugin, /* ndbinfo plugin */
18236+
/* IS plugin table which maps between mysql connection id and ndb trans-id */
18237+
i_s_ndb_transid_mysql_connection_map_plugin
1825418238
mysql_declare_plugin_end;
1825518239

1825618240
#endif

sql/ha_ndbcluster_connection.cc

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,4 +303,118 @@ void ndb_get_connection_stats(Uint64* statsArr)
303303
}
304304
}
305305

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

sql/ha_ndbinfo.cc

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@ ndbinfo_find_files(handlerton *hton, THD *thd,
737737

738738
handlerton* ndbinfo_hton;
739739

740-
int ndbinfo_init(void *plugin)
740+
static
741+
int
742+
ndbinfo_init(void *plugin)
741743
{
742744
DBUG_ENTER("ndbinfo_init");
743745

@@ -782,7 +784,9 @@ int ndbinfo_init(void *plugin)
782784
DBUG_RETURN(0);
783785
}
784786

785-
int ndbinfo_deinit(void *plugin)
787+
static
788+
int
789+
ndbinfo_deinit(void *plugin)
786790
{
787791
DBUG_ENTER("ndbinfo_deinit");
788792

@@ -807,6 +811,28 @@ struct st_mysql_sys_var* ndbinfo_system_variables[]= {
807811
NULL
808812
};
809813

814+
struct st_mysql_storage_engine ndbinfo_storage_engine=
815+
{
816+
MYSQL_HANDLERTON_INTERFACE_VERSION
817+
};
818+
819+
struct st_mysql_plugin ndbinfo_plugin =
820+
{
821+
MYSQL_STORAGE_ENGINE_PLUGIN,
822+
&ndbinfo_storage_engine,
823+
"ndbinfo",
824+
"Sun Microsystems Inc.",
825+
"MySQL Cluster system information storage engine",
826+
PLUGIN_LICENSE_GPL,
827+
ndbinfo_init, /* plugin init */
828+
ndbinfo_deinit, /* plugin deinit */
829+
0x0001, /* plugin version */
830+
NULL, /* status variables */
831+
ndbinfo_system_variables, /* system variables */
832+
NULL, /* config options */
833+
0
834+
};
835+
810836
template class Vector<const NdbInfoRecAttr*>;
811837

812838
#endif

sql/ha_ndbinfo.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121

2222
#include <mysql/plugin.h>
2323

24-
int ndbinfo_init(void *plugin);
25-
int ndbinfo_deinit(void *plugin);
26-
2724
class ha_ndbinfo: public handler
2825
{
2926
public:

sql/ndb_thd_ndb.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ Thd_ndb::seize(THD* thd)
4343
delete thd_ndb;
4444
thd_ndb= NULL;
4545
}
46+
else
47+
{
48+
thd_ndb->ndb->setCustomData64(thd_get_thread_id(thd));
49+
}
4650
DBUG_RETURN(thd_ndb);
4751
}
4852

@@ -81,6 +85,10 @@ Thd_ndb::recycle_ndb(THD* thd)
8185
ndb->getNdbError().message));
8286
DBUG_RETURN(false);
8387
}
88+
else
89+
{
90+
ndb->setCustomData64(thd_get_thread_id(thd));
91+
}
8492
DBUG_RETURN(true);
8593
}
8694

storage/ndb/include/ndbapi/Ndb.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,19 @@ class Ndb
17621762
/* Get/Set per-Ndb custom data pointer */
17631763
void setCustomData(void*);
17641764
void* getCustomData() const;
1765-
1765+
1766+
/* Get/Set per-Ndb custom data pointer */
1767+
/* NOTE: shares storage with void*
1768+
* i.e can not be used together with setCustomData
1769+
*/
1770+
void setCustomData64(Uint64);
1771+
Uint64 getCustomData64() const;
1772+
1773+
/**
1774+
* transid next startTransaction() on this ndb-object will get
1775+
*/
1776+
Uint64 getNextTransactionId() const;
1777+
17661778
/* Some client behaviour counters to assist
17671779
* optimisation
17681780
*/

storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20680,31 +20680,6 @@ Dbdict::createFile_parse(Signal* signal, bool master,
2068020680
return;
2068120681
}
2068220682

20683-
/**
20684-
* auto-connect
20685-
*/
20686-
if (f.FilegroupId == RNIL && f.FilegroupVersion == RNIL)
20687-
{
20688-
jam();
20689-
Filegroup_hash::Iterator it;
20690-
c_filegroup_hash.first(it);
20691-
while (!it.isNull())
20692-
{
20693-
jam();
20694-
if ((f.FileType == DictTabInfo::Undofile &&
20695-
it.curr.p->m_type == DictTabInfo::LogfileGroup) ||
20696-
(f.FileType == DictTabInfo::Datafile &&
20697-
it.curr.p->m_type == DictTabInfo::Tablespace))
20698-
{
20699-
jam();
20700-
f.FilegroupId = it.curr.p->key;
20701-
f.FilegroupVersion = it.curr.p->m_version;
20702-
break;
20703-
}
20704-
c_filegroup_hash.next(it);
20705-
}
20706-
}
20707-
2070820683
// Get Filegroup
2070920684
FilegroupPtr fg_ptr;
2071020685
if(!c_filegroup_hash.find(fg_ptr, f.FilegroupId))
@@ -21433,21 +21408,6 @@ Dbdict::createFilegroup_parse(Signal* signal, bool master,
2143321408
setError(error, CreateFilegroupRef::InvalidExtentSize, __LINE__);
2143421409
return;
2143521410
}
21436-
21437-
/**
21438-
* auto-connect
21439-
*/
21440-
if (fg.TS_LogfileGroupId == RNIL && fg.TS_LogfileGroupVersion == RNIL)
21441-
{
21442-
jam();
21443-
Filegroup_hash::Iterator it;
21444-
if (c_filegroup_hash.first(it))
21445-
{
21446-
jam();
21447-
fg.TS_LogfileGroupId = it.curr.p->key;
21448-
fg.TS_LogfileGroupVersion = it.curr.p->m_version;
21449-
}
21450-
}
2145121411
}
2145221412
else if(fg.FilegroupType == DictTabInfo::LogfileGroup)
2145321413
{

0 commit comments

Comments
 (0)