Skip to content

Commit

Permalink
wl#9819 patch #4: Define ndbinfo.processes view and ndb$processes bas…
Browse files Browse the repository at this point in the history
…e table
  • Loading branch information
jdduncan committed Mar 30, 2017
1 parent 718244e commit 98aed4b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
22 changes: 22 additions & 0 deletions scripts/mysql_system_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,11 @@ PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`processes`','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @str=IF(@have_ndbinfo,'DROP VIEW IF EXISTS `ndbinfo`.`resources`','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
Expand Down Expand Up @@ -3096,6 +3101,17 @@ PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

# ndbinfo.ndb$processes
SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$processes`','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

SET @str=IF(@have_ndbinfo,'CREATE TABLE `ndbinfo`.`ndb$processes` (`reporting_node_id` INT UNSIGNED COMMENT "Reporting data node ID",`node_id` INT UNSIGNED COMMENT "Connected node ID",`node_type` INT UNSIGNED COMMENT "Type of node",`host_addr` VARCHAR(512) COMMENT "IPv4 address of connected node",`node_version` VARCHAR(512) COMMENT "Node MySQL Cluster version string",`process_id` INT UNSIGNED COMMENT "PID of node process on host",`angel_process_id` INT UNSIGNED COMMENT "PID of node\'s angel process, if any",`process_name` VARCHAR(512) COMMENT "Node\'s executable process name",`connection_name` VARCHAR(512) COMMENT "Connection name of API node",`application_port` INT UNSIGNED COMMENT "Node\'s declared application port number") COMMENT="Process ID and Name information for connected nodes" ENGINE=NDBINFO','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

# ndbinfo.ndb$resources
SET @str=IF(@have_ndbinfo,'DROP TABLE IF EXISTS `ndbinfo`.`ndb$resources`','SET @dummy = 0');
PREPARE stmt FROM @str;
Expand Down Expand Up @@ -3502,6 +3518,12 @@ PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

# ndbinfo.processes
SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`processes` AS SELECT DISTINCT node_id, CASE node_type WHEN 0 THEN "NDB" WHEN 1 THEN "API" WHEN 2 THEN "MGM" ELSE NULL END AS node_type, host_addr, node_version, NULLIF(process_id, 0) AS process_id, NULLIF(angel_process_id, 0) AS angel_process_id, process_name, connection_name, NULLIF(application_port, 0) AS application_port FROM `ndbinfo`.`ndb$processes`','SET @dummy = 0');
PREPARE stmt FROM @str;
EXECUTE stmt;
DROP PREPARE stmt;

# ndbinfo.resources
SET @str=IF(@have_ndbinfo,'CREATE OR REPLACE DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `ndbinfo`.`resources` AS SELECT node_id, CASE resource_id WHEN 0 THEN "RESERVED" WHEN 1 THEN "DISK_OPERATIONS" WHEN 2 THEN "DISK_RECORDS" WHEN 3 THEN "DATA_MEMORY" WHEN 4 THEN "JOBBUFFER" WHEN 5 THEN "FILE_BUFFERS" WHEN 6 THEN "TRANSPORTER_BUFFERS" WHEN 7 THEN "DISK_PAGE_BUFFER" WHEN 8 THEN "QUERY_MEMORY" WHEN 9 THEN "SCHEMA_TRANS_MEMORY" ELSE "<unknown>" END AS resource_name, reserved, used, max FROM `ndbinfo`.`ndb$resources`','SET @dummy = 0');
PREPARE stmt FROM @str;
Expand Down
3 changes: 2 additions & 1 deletion storage/ndb/src/kernel/vm/Ndbinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Ndbinfo {
TABLE_DIST_STATUS_ALL_TABLEID =34,
TABLE_FRAGMENTS_ALL_TABLEID =35,
TABLE_REPLICAS_ALL_TABLEID = 36,
STORED_TABLES_TABLEID = 37
STORED_TABLES_TABLEID = 37,
PROCESSES_TABLEID = 38
};

struct Table {
Expand Down
18 changes: 17 additions & 1 deletion storage/ndb/src/kernel/vm/NdbinfoTables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,21 @@ DECLARE_NDBINFO_TABLE(STORED_TABLES, 20) =
}
};

DECLARE_NDBINFO_TABLE(PROCESSES, 10) =
{ { "processes", 10, 0, "Process ID and Name information for connected nodes" },
{
{ "reporting_node_id", Ndbinfo::Number, "Reporting data node ID"},
{ "node_id", Ndbinfo::Number, "Connected node ID"},
{ "node_type", Ndbinfo::Number, "Type of node"},
{ "host_addr", Ndbinfo::String, "IPv4 address of connected node"},
{ "node_version", Ndbinfo::String, "Node MySQL Cluster version string"},
{ "process_id", Ndbinfo::Number, "PID of node process on host"},
{ "angel_process_id", Ndbinfo::Number, "PID of node\\\'s angel process, if any"},
{ "process_name", Ndbinfo::String, "Node\\\'s executable process name"},
{ "connection_name", Ndbinfo::String, "Connection name of API node"},
{ "application_port", Ndbinfo::Number, "Node\\\'s declared application port number"}
}
};
#define DBINFOTBL(x) { Ndbinfo::x##_TABLEID, (Ndbinfo::Table*)&ndbinfo_##x }

static
Expand Down Expand Up @@ -918,7 +933,8 @@ struct ndbinfo_table_list_entry {
DBINFOTBL(TABLE_DIST_STATUS_ALL),
DBINFOTBL(TABLE_FRAGMENTS_ALL),
DBINFOTBL(TABLE_REPLICAS_ALL),
DBINFOTBL(STORED_TABLES)
DBINFOTBL(STORED_TABLES),
DBINFOTBL(PROCESSES)
};

static int no_ndbinfo_tables =
Expand Down
15 changes: 15 additions & 0 deletions storage/ndb/tools/ndbinfo_sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,21 @@ struct view {
"LEFT JOIN `<NDBINFO_DB>`.config_params cp4 ON p.config_param4 = cp4.param_number"
},
#endif
{ "processes",
"SELECT DISTINCT node_id, "
"CASE node_type"
" WHEN 0 THEN \"NDB\""
" WHEN 1 THEN \"API\""
" WHEN 2 THEN \"MGM\""
" ELSE NULL "
" END AS node_type, "
" host_addr, node_version, "
" NULLIF(process_id, 0) AS process_id, "
" NULLIF(angel_process_id, 0) AS angel_process_id, "
" process_name, connection_name, "
" NULLIF(application_port, 0) AS application_port "
"FROM `<NDBINFO_DB>`.`<TABLE_PREFIX>processes`"
},
{ "resources",
"SELECT node_id, "
" CASE resource_id"
Expand Down

0 comments on commit 98aed4b

Please sign in to comment.