Commit 3a793b9d authored by Michael Widenius's avatar Michael Widenius

Added new status variables:

feature_dynamic_columns,feature_fulltext,feature_gis,feature_locale,feature_subquery,feature_timezone,feature_trigger,feature_xml
Opened_views, Executed_triggers, Executed_events
Added new process status 'updating status' as part of 'freeing items'

mysql-test/r/features.result:
  Test of feature_xxx status variables
mysql-test/r/mysqld--help.result:
  Removed duplicated 'language' variable.
mysql-test/r/view.result:
  Test of opened_views
mysql-test/suite/rpl/t/rpl_start_stop_slave.test:
  Write more information on failure
mysql-test/t/features.test:
  Test of feature_xxx status variables
mysql-test/t/view.test:
  Test of opened_views
sql/event_scheduler.cc:
  Increment executed_events status variable
sql/field.cc:
  Increment status variable
sql/item_func.cc:
  Increment status variable
sql/item_strfunc.cc:
  Increment status variable
sql/item_subselect.cc:
  Increment status variable
sql/item_xmlfunc.cc:
  Increment status variable
sql/mysqld.cc:
  Add new status variables to 'show status'
sql/mysqld.h:
  Added executed_events
sql/sql_base.cc:
  Increment status variable
sql/sql_class.h:
  Add new status variables
sql/sql_parse.cc:
  Added new process status 'updating status' as part of 'freeing items'
sql/sql_trigger.cc:
  Increment status variable
sql/sys_vars.cc:
  Increment status variable
sql/tztime.cc:
  Increment status variable
parent 5161b3dd
drop table if exists t1;
show status like "feature%";
Variable_name Value
Feature_dynamic_columns 0
Feature_fulltext 0
Feature_gis 0
Feature_locale 0
Feature_subquery 0
Feature_timezone 0
Feature_trigger 0
Feature_xml 0
#
# Feature GIS
#
CREATE TABLE t1 (g POINT);
SHOW FIELDS FROM t1;
Field Type Null Key Default Extra
g point YES NULL
INSERT INTO t1 VALUES
(PointFromText('POINT(10 10)')),
(PointFromText('POINT(20 10)')),
(PointFromText('POINT(20 20)')),
(PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
drop table t1;
show status like "feature_gis";
Variable_name Value
Feature_gis 3
#
# Feature dynamic columns
#
set @a= COLUMN_CREATE(1, 1212 AS int);
set @b= column_add(@a, 2, 1212 as integer);
select column_get(@b, 2 as integer);
column_get(@b, 2 as integer)
1212
show status like "feature_dynamic_columns";
Variable_name Value
Feature_dynamic_columns 2
#
# Feature fulltext
#
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) engine=myisam;
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
select * from t1 where MATCH(a,b) AGAINST ("collections");
a b
Only MyISAM tables support collections
Full-text indexes are called collections
select * from t1 where MATCH(a,b) AGAINST ("indexes");
a b
Full-text indexes are called collections
drop table t1;
show status like "feature_fulltext";
Variable_name Value
Feature_fulltext 2
#
# Feature locale
#
SET lc_messages=sr_RS;
SET lc_messages=en_US;
show status like "feature_locale";
Variable_name Value
Feature_locale 2
#
# Feature subquery
#
select (select 2);
(select 2)
2
SELECT (SELECT 1) UNION SELECT (SELECT 2);
(SELECT 1)
1
2
create table t1 (a int);
insert into t1 values (2);
select (select a from t1 where t1.a=t2.a), a from t1 as t2;
(select a from t1 where t1.a=t2.a) a
2 2
drop table t1;
show status like "feature_subquery";
Variable_name Value
Feature_subquery 4
#
# Feature timezone
#
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
FROM_UNIXTIME(unix_timestamp()) > "1970-01-01"
1
set time_zone="+03:00";
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
FROM_UNIXTIME(unix_timestamp()) > "1970-01-01"
1
set time_zone= @@global.time_zone;
show status like "feature_timezone";
Variable_name Value
Feature_timezone 1
#
# Feature triggers
#
create table t1 (i int);
# let us test some very simple trigger
create trigger trg before insert on t1 for each row set @a:=1;
set @a:=0;
select @a;
@a
0
insert into t1 values (1),(2);
select @a;
@a
1
SHOW TRIGGERS IN test like 't1';
Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation
trg INSERT t1 set @a:=1 BEFORE NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
drop trigger trg;
drop table t1;
show status like "%trigger%";
Variable_name Value
Com_create_trigger 1
Com_drop_trigger 1
Com_show_create_trigger 0
Com_show_triggers 1
Executed_triggers 2
Feature_trigger 2
#
# Feature xml
#
SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
SELECT extractValue(@xml,'/a');
extractValue(@xml,'/a')
a1 a2
select updatexml('<div><div><span>1</span><span>2</span></div></div>',
'/','<tr><td>1</td><td>2</td></tr>') as upd1;
upd1
<tr><td>1</td><td>2</td></tr>
show status like "feature_xml";
Variable_name Value
Feature_xml 2
......@@ -923,7 +923,6 @@ key-cache-age-threshold 300
key-cache-block-size 1024
key-cache-division-limit 100
key-cache-segments 0
language MYSQL_SHAREDIR/
large-pages FALSE
lc-messages en_US
lc-messages-dir MYSQL_SHAREDIR/
......
......@@ -4678,6 +4678,7 @@ DROP TABLE t1,t2,t3;
# LP bug#1007622 Server crashes in handler::increment_statistics on
# inserting into a view over a view
#
flush status;
CREATE TABLE t1 (a INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.* FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
......@@ -4687,6 +4688,15 @@ a
1
drop view v2,v1;
drop table t1;
show status like '%view%';
Variable_name Value
Com_create_view 2
Com_drop_view 1
Opened_views 3
show status like 'Opened_table%';
Variable_name Value
Opened_table_definitions 2
Opened_tables 3
#
# MDEV-486 LP BUG#1010116 Incorrect query results in
# view and derived tables
......
......@@ -21,6 +21,16 @@
connection slave;
--let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`
if(!$connection_id)
{
# Something went wrong (timing)
# Show process list so that we can debug. In this case we will abort with
# wrong result
-- echo "Could not find connect id. Dumping process list for debugging"
SELECT * FROM information_schema.processlist;
exit;
}
set @time_before_kill := (select CURRENT_TIMESTAMP);
--echo [Time before the query]
......
# Testing of feature statistics
-- source include/have_geometry.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
show status like "feature%";
--echo #
--echo # Feature GIS
--echo #
CREATE TABLE t1 (g POINT);
SHOW FIELDS FROM t1;
INSERT INTO t1 VALUES
(PointFromText('POINT(10 10)')),
(PointFromText('POINT(20 10)')),
(PointFromText('POINT(20 20)')),
(PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
drop table t1;
show status like "feature_gis";
--echo #
--echo # Feature dynamic columns
--echo #
set @a= COLUMN_CREATE(1, 1212 AS int);
set @b= column_add(@a, 2, 1212 as integer);
select column_get(@b, 2 as integer);
show status like "feature_dynamic_columns";
--echo #
--echo # Feature fulltext
--echo #
CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) engine=myisam;
INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'),
('Full-text indexes', 'are called collections'),
('Only MyISAM tables','support collections'),
('Function MATCH ... AGAINST()','is used to do a search'),
('Full-text search in MySQL', 'implements vector space model');
select * from t1 where MATCH(a,b) AGAINST ("collections");
select * from t1 where MATCH(a,b) AGAINST ("indexes");
drop table t1;
show status like "feature_fulltext";
--echo #
--echo # Feature locale
--echo #
SET lc_messages=sr_RS;
SET lc_messages=en_US;
show status like "feature_locale";
--echo #
--echo # Feature subquery
--echo #
select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2);
create table t1 (a int);
insert into t1 values (2);
select (select a from t1 where t1.a=t2.a), a from t1 as t2;
drop table t1;
show status like "feature_subquery";
--echo #
--echo # Feature timezone
--echo #
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
set time_zone="+03:00";
SELECT FROM_UNIXTIME(unix_timestamp()) > "1970-01-01";
set time_zone= @@global.time_zone;
show status like "feature_timezone";
--echo #
--echo # Feature triggers
--echo #
create table t1 (i int);
--echo # let us test some very simple trigger
create trigger trg before insert on t1 for each row set @a:=1;
set @a:=0;
select @a;
insert into t1 values (1),(2);
select @a;
SHOW TRIGGERS IN test like 't1';
drop trigger trg;
drop table t1;
show status like "%trigger%";
--echo #
--echo # Feature xml
--echo #
SET @xml='<a aa1="aa1" aa2="aa2">a1<b ba1="ba1">b1<c>c1</c>b2</b>a2</a>';
SELECT extractValue(@xml,'/a');
select updatexml('<div><div><span>1</span><span>2</span></div></div>',
'/','<tr><td>1</td><td>2</td></tr>') as upd1;
show status like "feature_xml";
......@@ -4618,6 +4618,8 @@ DROP TABLE t1,t2,t3;
--echo # inserting into a view over a view
--echo #
flush status;
CREATE TABLE t1 (a INT);
CREATE ALGORITHM=MERGE VIEW v1 AS SELECT a1.* FROM t1 AS a1, t1 AS a2;
CREATE ALGORITHM=MERGE VIEW v2 AS SELECT * FROM v1;
......@@ -4625,6 +4627,8 @@ INSERT INTO v2 (a) VALUES (1) ;
select * from t1;
drop view v2,v1;
drop table t1;
show status like '%view%';
show status like 'Opened_table%';
--echo #
--echo # MDEV-486 LP BUG#1010116 Incorrect query results in
......
......@@ -42,7 +42,7 @@
cond_wait(mythd, abstime, msg, SCHED_FUNC, __LINE__)
extern pthread_attr_t connection_attrib;
extern ulong event_executed;
Event_db_repository *Event_worker_thread::db_repository;
......@@ -557,7 +557,8 @@ Event_scheduler::execute_top(Event_queue_element_for_exec *event_name)
event_name)))
goto error;
++started_events;
started_events++;
executed_events++; // For SHOW STATUS
DBUG_PRINT("info", ("Event is in THD: 0x%lx", (long) new_thd));
DBUG_RETURN(FALSE);
......
......@@ -9395,9 +9395,12 @@ Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length,
#ifdef HAVE_SPATIAL
if (f_is_geom(pack_flag))
{
status_var_increment(current_thd->status_var.feature_gis);
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, share,
pack_length, geom_type);
}
#endif
if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit,
......
......@@ -6046,6 +6046,8 @@ bool Item_func_match::fix_fields(THD *thd, Item **ref)
DBUG_ASSERT(fixed == 0);
Item *UNINIT_VAR(item); // Safe as arg_count is > 1
status_var_increment(thd->status_var.feature_fulltext);
maybe_null=1;
join_key=0;
......
......@@ -3774,6 +3774,7 @@ bool Item_func_dyncol_create::fix_fields(THD *thd, Item **ref)
(arg_count / 2));
nums= (uint *) alloc_root(thd->mem_root,
sizeof(uint) * (arg_count / 2));
status_var_increment(thd->status_var.feature_dynamic_columns);
return res || vals == 0 || nums == 0;
}
......
......@@ -220,6 +220,8 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref)
uint8 uncacheable;
bool res;
status_var_increment(thd->status_var.feature_subquery);
DBUG_ASSERT(fixed == 0);
engine->set_thd((thd= thd_param));
if (!done_first_fix_fields)
......
......@@ -2601,6 +2601,8 @@ void Item_xml_str_func::fix_length_and_dec()
MY_XPATH xpath;
int rc;
status_var_increment(current_thd->status_var.feature_xml);
nodeset_func= 0;
if (agg_arg_charsets_for_comparison(collation, args, arg_count))
......
......@@ -482,6 +482,7 @@ ulonglong binlog_stmt_cache_size=0;
ulonglong max_binlog_stmt_cache_size=0;
ulonglong query_cache_size=0;
ulong refresh_version; /* Increments on each reload */
ulong executed_events=0;
query_id_t global_query_id;
my_atomic_rwlock_t global_query_id_lock;
my_atomic_rwlock_t thread_running_lock;
......@@ -6948,6 +6949,16 @@ SHOW_VAR status_vars[]= {
{"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH},
{"Delayed_writes", (char*) &delayed_insert_writes, SHOW_LONG},
{"Empty_queries", (char*) offsetof(STATUS_VAR, empty_queries), SHOW_LONG_STATUS},
{"Executed_events", (char*) &executed_events, SHOW_LONG_NOFLUSH },
{"Executed_triggers", (char*) offsetof(STATUS_VAR, executed_triggers), SHOW_LONG_STATUS},
{"Feature_dynamic_columns", (char*) offsetof(STATUS_VAR, feature_dynamic_columns), SHOW_LONG_STATUS},
{"Feature_fulltext", (char*) offsetof(STATUS_VAR, feature_fulltext), SHOW_LONG_STATUS},
{"Feature_gis", (char*) offsetof(STATUS_VAR, feature_gis), SHOW_LONG_STATUS},
{"Feature_locale", (char*) offsetof(STATUS_VAR, feature_locale), SHOW_LONG_STATUS},
{"Feature_subquery", (char*) offsetof(STATUS_VAR, feature_subquery), SHOW_LONG_STATUS},
{"Feature_timezone", (char*) offsetof(STATUS_VAR, feature_timezone), SHOW_LONG_STATUS},
{"Feature_trigger", (char*) offsetof(STATUS_VAR, feature_trigger), SHOW_LONG_STATUS},
{"Feature_xml", (char*) offsetof(STATUS_VAR, feature_xml), SHOW_LONG_STATUS},
{"Flush_commands", (char*) &refresh_version, SHOW_LONG_NOFLUSH},
{"Handler_commit", (char*) offsetof(STATUS_VAR, ha_commit_count), SHOW_LONG_STATUS},
{"Handler_delete", (char*) offsetof(STATUS_VAR, ha_delete_count), SHOW_LONG_STATUS},
......@@ -6987,6 +6998,7 @@ SHOW_VAR status_vars[]= {
{"Opened_files", (char*) &my_file_total_opened, SHOW_LONG_NOFLUSH},
{"Opened_tables", (char*) offsetof(STATUS_VAR, opened_tables), SHOW_LONG_STATUS},
{"Opened_table_definitions", (char*) offsetof(STATUS_VAR, opened_shares), SHOW_LONG_STATUS},
{"Opened_views", (char*) offsetof(STATUS_VAR, opened_views), SHOW_LONG_STATUS},
{"Prepared_stmt_count", (char*) &show_prepared_stmt_count, SHOW_FUNC},
{"Rows_sent", (char*) offsetof(STATUS_VAR, rows_sent), SHOW_LONGLONG_STATUS},
{"Rows_read", (char*) offsetof(STATUS_VAR, rows_read), SHOW_LONGLONG_STATUS},
......@@ -7274,6 +7286,7 @@ static int mysql_init_variables(void)
protocol_version= PROTOCOL_VERSION;
what_to_log= ~ (1L << (uint) COM_TIME);
refresh_version= 1L; /* Increments on each reload */
executed_events= 0;
global_query_id= thread_id= 1L;
my_atomic_rwlock_init(&global_query_id_lock);
my_atomic_rwlock_init(&thread_running_lock);
......
......@@ -175,6 +175,7 @@ extern ulong opt_binlog_rows_event_max_size;
extern ulong rpl_recovery_rank, thread_cache_size;
extern ulong stored_program_cache_size;
extern ulong back_log;
extern ulong executed_events;
extern char language[FN_REFLEN];
extern "C" MYSQL_PLUGIN_IMPORT ulong server_id;
extern ulong concurrency;
......
......@@ -9421,6 +9421,7 @@ open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
if (mysql_make_view(thd, parser, table_desc,
(prgflag & OPEN_VIEW_NO_PARSE)))
goto err;
status_var_increment(thd->status_var.opened_views);
}
else
{
......
......@@ -620,25 +620,17 @@ typedef struct system_status_var
ulong ha_savepoint_count;
ulong ha_savepoint_rollback_count;
#if 0
/* KEY_CACHE parts. These are copies of the original */
ulong key_blocks_changed;
ulong key_blocks_used;
ulong key_cache_r_requests;
ulong key_cache_read;
ulong key_cache_w_requests;
ulong key_cache_write;
/* END OF KEY_CACHE parts */
#endif
ulong net_big_packet_count;
ulong opened_tables;
ulong opened_shares;
ulong opened_views; /* +1 opening a view */
ulong select_full_join_count;
ulong select_full_range_join_count;
ulong select_range_count;
ulong select_range_check_count;
ulong select_scan_count;
ulong executed_triggers;
ulong long_query_count;
ulong filesort_merge_passes;
ulong filesort_range_count;
......@@ -653,6 +645,16 @@ typedef struct system_status_var
ulong com_stmt_reset;
ulong com_stmt_close;
/* Features used */
ulong feature_dynamic_columns; /* +1 when creating a dynamic column */
ulong feature_fulltext; /* +1 when MATCH is used */
ulong feature_gis; /* +1 opening a table with GIS features */
ulong feature_locale; /* +1 when LOCALE is set */
ulong feature_subquery; /* +1 when subqueries are used */
ulong feature_timezone; /* +1 when XPATH is used */
ulong feature_trigger; /* +1 opening a table with triggers */
ulong feature_xml; /* +1 when XPATH is used */
ulong empty_queries;
ulong access_denied_errors;
ulong lost_connections;
......
......@@ -1425,6 +1425,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
(thd->open_tables == NULL ||
(thd->locked_tables_mode == LTM_LOCK_TABLES)));
thd_proc_info(thd, "updating status");
/* Finalize server status flags after executing a command. */
thd->update_server_status();
thd->protocol->end_statement();
......
......@@ -1334,6 +1334,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
triggers->definitions_list.elements);
table->triggers= triggers;
status_var_increment(thd->status_var.feature_trigger);
/*
TODO: This could be avoided if there is no triggers
......@@ -2116,6 +2117,8 @@ bool Table_triggers_list::process_triggers(THD *thd,
if (sp_trigger == NULL)
return FALSE;
status_var_increment(thd->status_var.executed_triggers);
if (old_row_is_record1)
{
old_field= record1_field;
......
......@@ -3578,22 +3578,25 @@ static bool check_locale(sys_var *self, THD *thd, set_var *var)
if (!locale->errmsgs->errmsgs)
{
bool res;
mysql_mutex_lock(&LOCK_error_messages);
if (!locale->errmsgs->errmsgs &&
read_texts(ERRMSG_FILE, locale->errmsgs->language,
&locale->errmsgs->errmsgs,
ER_ERROR_LAST - ER_ERROR_FIRST + 1))
res= (!locale->errmsgs->errmsgs &&
read_texts(ERRMSG_FILE, locale->errmsgs->language,
&locale->errmsgs->errmsgs,
ER_ERROR_LAST - ER_ERROR_FIRST + 1));
mysql_mutex_unlock(&LOCK_error_messages);
if (res)
{
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_UNKNOWN_ERROR,
"Can't process error message file for locale '%s'",
locale->name);
mysql_mutex_unlock(&LOCK_error_messages);
return true;
}
mysql_mutex_unlock(&LOCK_error_messages);
}
status_var_increment(thd->status_var.feature_locale);
return false;
}
static Sys_var_struct Sys_lc_messages(
"lc_messages", "Set the language used for the error messages",
SESSION_VAR(lc_messages), NO_CMD_LINE,
......
......@@ -2329,7 +2329,6 @@ my_tz_find(THD *thd, const String *name)
if (!str_to_offset(name->ptr(), name->length(), &offset))
{
if (!(result_tz= (Time_zone_offset *)my_hash_search(&offset_tzs,
(const uchar *)&offset,
sizeof(long))))
......@@ -2371,6 +2370,9 @@ my_tz_find(THD *thd, const String *name)
mysql_mutex_unlock(&tz_LOCK);
if (result_tz && result_tz != my_tz_SYSTEM && result_tz != my_tz_UTC)
status_var_increment(thd->status_var.feature_timezone);
DBUG_RETURN(result_tz);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment