Commit 4822696e authored by Chad MILLER's avatar Chad MILLER

Pull 5.1 treatment of community features into 5.0.

parent 14f923c0
......@@ -661,7 +661,6 @@ then
fi
fi
AC_ARG_WITH(server-suffix,
[ --with-server-suffix Append value to the version string.],
[ MYSQL_SERVER_SUFFIX=`echo "$withval" | sed -e 's/^\(...................................\)..*$/\1/'` ],
......@@ -724,17 +723,42 @@ else
AC_MSG_RESULT([no])
fi
AC_MSG_CHECKING(whether features provided by the user community should be included.)
AC_ARG_ENABLE(community-features,
AC_HELP_STRING(
[--enable-community-features],
[Enable additional features provided by the user community.]),
[ ENABLE_COMMUNITY_FEATURES=$enableval ],
[ ENABLE_COMMUNITY_FEATURES=no ]
)
if test "$ENABLE_COMMUNITY_FEATURES" = "yes"
then
AC_DEFINE([COMMUNITY_SERVER], [1],
[Whether features provided by the user community should be included])
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
# Add query profiler
AC_MSG_CHECKING(whether query profiling should be included)
AC_ARG_ENABLE(profiling,
AS_HELP_STRING([--disable-profiling], [Build a version without query profiling code]),
AS_HELP_STRING([--enable-profiling], [Add query-profiling code.]),
[ ENABLED_PROFILING=$enableval ],
[ ENABLED_PROFILING=yes ])
[ ENABLED_PROFILING=no ])
if test "$ENABLED_PROFILING" = "yes"
then
AC_DEFINE([ENABLED_PROFILING], [1],
[If SHOW PROFILE should be enabled])
AC_MSG_RESULT([yes])
if test "$ENABLE_COMMUNITY_FEATURES" = "yes";
then
AC_DEFINE([ENABLED_PROFILING], [1], [If SHOW PROFILE should be enabled])
AC_MSG_RESULT([yes])
else
ENABLED_PROFILING="no"
AC_MSG_RESULT([no, overridden because community-features disabled])
AC_MSG_ERROR([This is almost certainly wrong. Add --enable-community-features or remove --enable-profiling .])
fi
else
AC_MSG_RESULT([no])
fi
......
--require r/have_community_features.require
--disable_query_log
show variables like 'have_community_features';
--enable_query_log
--require r/have_profiling.require
--disable_query_log
show variables like 'have_profiling';
--enable_query_log
Variable_name Value
have_community_features YES
Variable_name Value
have_profiling YES
--source include/have_profiling.inc
# Verify that the protocol isn't violated if we ask for profiling info
# before profiling has recorded anything.
show profiles;
......
......@@ -1479,6 +1479,8 @@ extern SHOW_COMP_OPTION have_query_cache;
extern SHOW_COMP_OPTION have_geometry, have_rtree_keys;
extern SHOW_COMP_OPTION have_crypt;
extern SHOW_COMP_OPTION have_compress;
extern SHOW_COMP_OPTION have_community_features;
extern SHOW_COMP_OPTION have_profiling;
#ifndef __WIN__
extern pthread_t signal_thread;
......
......@@ -538,6 +538,8 @@ SHOW_COMP_OPTION have_isam;
SHOW_COMP_OPTION have_raid, have_ssl, have_symlink, have_query_cache;
SHOW_COMP_OPTION have_geometry, have_rtree_keys, have_dlopen;
SHOW_COMP_OPTION have_crypt, have_compress;
SHOW_COMP_OPTION have_community_features;
SHOW_COMP_OPTION have_profiling;
/* Thread specific variables */
......@@ -5638,7 +5640,7 @@ Disable with --skip-ndbcluster (will save memory).",
"Maximum time in seconds to wait for the port to become free. "
"(Default: no wait)", (gptr*) &mysqld_port_timeout,
(gptr*) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
{"profiling_history_size", OPT_PROFILING, "Limit of query profiling memory",
(gptr*) &global_system_variables.profiling_history_size,
(gptr*) &max_system_variables.profiling_history_size,
......@@ -6685,7 +6687,9 @@ struct show_var_st status_vars[]= {
{"Threads_created", (char*) &thread_created, SHOW_LONG_CONST},
{"Threads_running", (char*) &thread_running, SHOW_INT_CONST},
{"Uptime", (char*) 0, SHOW_STARTTIME},
#ifdef COMMUNITY_SERVER
{"Uptime_since_flush_status",(char*) 0, SHOW_FLUSHTIME},
#endif
{NullS, NullS, SHOW_LONG}
};
......@@ -6992,6 +6996,16 @@ static void mysql_init_variables(void)
#if !defined(my_pthread_setprio) && !defined(HAVE_PTHREAD_SETSCHEDPARAM)
opt_specialflag |= SPECIAL_NO_PRIOR;
#endif
#ifdef ENABLED_PROFILING
have_profiling = SHOW_OPTION_YES;
#else
have_profiling = SHOW_OPTION_NO;
#endif
#ifdef COMMUNITY_SERVER
have_community_features = SHOW_OPTION_YES;
#else
have_community_features = SHOW_OPTION_NO;
#endif
#if defined(__WIN__) || defined(__NETWARE__)
/* Allow Win32 and NetWare users to move MySQL anywhere */
......@@ -8016,7 +8030,9 @@ void refresh_status(THD *thd)
/* Reset the counters of all key caches (default and named). */
process_key_caches(reset_key_cache_counters);
#ifdef COMMUNITY_SERVER
flush_status_time= time((time_t*) 0);
#endif
pthread_mutex_unlock(&LOCK_status);
/*
......
......@@ -564,7 +564,7 @@ static sys_var_thd_bit sys_unique_checks("unique_checks", 0,
set_option_bit,
OPTION_RELAXED_UNIQUE_CHECKS,
1);
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
static sys_var_thd_bit sys_profiling("profiling", NULL, set_option_bit,
ulonglong(OPTION_PROFILING));
static sys_var_thd_ulong sys_profiling_history_size("profiling_history_size",
......@@ -899,6 +899,8 @@ struct show_var_st init_vars[]= {
{"have_bdb", (char*) &have_berkeley_db, SHOW_HAVE},
{"have_blackhole_engine", (char*) &have_blackhole_db, SHOW_HAVE},
{"have_compress", (char*) &have_compress, SHOW_HAVE},
{"have_community_features", (char*) &have_community_features, SHOW_HAVE},
{"have_profiling", (char*) &have_profiling, SHOW_HAVE},
{"have_crypt", (char*) &have_crypt, SHOW_HAVE},
{"have_csv", (char*) &have_csv_db, SHOW_HAVE},
{"have_dynamic_loading", (char*) &have_dlopen, SHOW_HAVE},
......
......@@ -1103,7 +1103,7 @@ sp_head::execute(THD *thd)
*/
thd->spcont->callers_arena= &backup_arena;
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
/* Discard the initial part of executing routines. */
thd->profiling.discard_current_query();
#endif
......@@ -1112,7 +1112,7 @@ sp_head::execute(THD *thd)
sp_instr *i;
uint hip; // Handler ip
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
/*
Treat each "instr" of a routine as discrete unit that could be profiled.
Profiling only records information for segments of code that set the
......@@ -1125,7 +1125,7 @@ sp_head::execute(THD *thd)
i = get_instr(ip); // Returns NULL when we're done.
if (i == NULL)
{
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.discard_current_query();
#endif
break;
......@@ -1209,7 +1209,7 @@ sp_head::execute(THD *thd)
}
} while (!err_status && !thd->killed);
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.finish_current_query();
thd->profiling.start_new_query("tail end of routine");
#endif
......@@ -2633,7 +2633,7 @@ sp_instr_stmt::execute(THD *thd, uint *nextp)
query= thd->query;
query_length= thd->query_length;
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
/* This s-p instr is profilable and will be captured. */
thd->profiling.set_query_source(m_query.str, m_query.length);
#endif
......
......@@ -173,7 +173,7 @@ const char *set_thd_proc_info(THD *thd, const char *info,
{
const char *old_info= thd->proc_info;
DBUG_PRINT("proc_info", ("%s:%d %s", calling_file, calling_line, info));
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.status_change(info, calling_function, calling_file, calling_line);
#endif
thd->proc_info= info;
......@@ -272,7 +272,7 @@ THD::THD()
init();
/* Initialize sub structures */
init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
profiling.set_thd(this);
#endif
user_connect=(USER_CONN *)0;
......
......@@ -1434,7 +1434,7 @@ public:
List <MYSQL_ERROR> warn_list;
uint warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_END];
uint total_warn_count;
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
PROFILING profiling;
#endif
......
......@@ -1355,7 +1355,7 @@ pthread_handler_t handle_bootstrap(void *arg)
thd->db_length+1+QUERY_CACHE_FLAGS_SIZE);
thd->query[length] = '\0';
DBUG_PRINT("query",("%-.4096s",thd->query));
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.set_query_source(thd->query, length);
#endif
......@@ -1594,7 +1594,7 @@ static bool do_command(THD *thd)
net_new_transaction(net);
packet_length= my_net_read(net);
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.start_new_query();
#endif
if (packet_length == packet_error)
......@@ -1642,7 +1642,7 @@ static bool do_command(THD *thd)
return_value= dispatch_command(command, thd, packet+1, (uint) (packet_length));
out:
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.finish_current_query();
#endif
DBUG_RETURN(return_value);
......@@ -1951,7 +1951,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
mysql_log.write(thd,command, format, thd->query_length, thd->query);
DBUG_PRINT("query",("%-.4096s",thd->query));
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.set_query_source(thd->query, thd->query_length);
#endif
......@@ -1981,7 +1981,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
length--;
}
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.finish_current_query();
thd->profiling.start_new_query("continuing");
thd->profiling.set_query_source(next_packet, length);
......@@ -2485,7 +2485,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
Mark this current profiling record to be discarded. We don't
wish to have SHOW commands show up in profiling.
*/
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.discard_current_query();
#endif
break;
......@@ -2961,7 +2961,7 @@ mysql_execute_command(THD *thd)
}
case SQLCOM_SHOW_PROFILES:
{
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.discard_current_query();
res= thd->profiling.show_profiles();
if (res)
......
......@@ -2283,7 +2283,7 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_execute")))
DBUG_VOID_RETURN;
#ifdef ENABLED_PROFILING
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
thd->profiling.set_query_source(stmt->query, stmt->query_length);
#endif
DBUG_PRINT("exec_query", ("%s", stmt->query));
......
......@@ -47,7 +47,7 @@ const char * const _unknown_func_ = "<unknown>";
int fill_query_profile_statistics_info(THD *thd, TABLE_LIST *tables,
Item *cond)
{
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
return(thd->profiling.fill_statistics_info(thd, tables, cond));
#else
my_error(ER_FEATURE_DISABLED, MYF(0), "SHOW PROFILE", "enable-profiling");
......@@ -129,7 +129,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
}
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
#define RUSAGE_USEC(tv) ((tv).tv_sec*1000*1000 + (tv).tv_usec)
#define RUSAGE_DIFF_USEC(tv1, tv2) (RUSAGE_USEC((tv1))-RUSAGE_USEC((tv2)))
......
......@@ -54,7 +54,7 @@ int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table);
#define PROFILE_ALL (~0)
#if defined(ENABLED_PROFILING)
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
#include "mysql_priv.h"
#ifdef HAVE_SYS_RESOURCE_H
......
......@@ -1549,9 +1549,12 @@ static bool show_status_array(THD *thd, const char *wild,
nr= (long) (thd->query_start() - server_start_time);
end= int10_to_str(nr, buff, 10);
break;
#ifdef COMMUNITY_SERVER
case SHOW_FLUSHTIME:
nr= (long) (thd->query_start() - flush_status_time);
end= int10_to_str(nr, buff, 10);
break;
#endif
case SHOW_QUERIES:
end= int10_to_str((long) thd->query_id, buff, 10);
break;
......
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