unset($_SESSION['tmpval']['navi_limit_offset']); } $_SESSION['tmpval']['previous_server'] = $GLOBALS['server']; } else { // end server connecting // No need to check for 'PMA_BYPASS_GET_INSTANCE' since this execution path // applies only to initial login $response = PMA_Response::getInstance(); $response->getHeader()->disableMenuAndConsole(); $response->getFooter()->setMinimal(); } /** * check if profiling was requested and remember it * (note: when $cfg['ServerDefault'] = 0, constant is not defined) */ if (isset($_REQUEST['profiling']) && PMA_Util::profilingSupported()) { $_SESSION['profiling'] = true; } elseif (isset($_REQUEST['profiling_form'])) { // the checkbox was unchecked unset($_SESSION['profiling']); } // load user preferences $GLOBALS['PMA_Config']->loadUserPreferences(); /** * Inclusion of profiling scripts is needed on various * pages like sql, tbl_sql, db_sql, tbl_select */ if (!defined('PMA_BYPASS_GET_INSTANCE')) { $response = PMA_Response::getInstance(); } if (isset($_SESSION['profiling'])) {
/** * Function to handle all aspects relating to executing the query * * @param array $analyzed_sql_results analyzed sql results * @param String $full_sql_query full sql query * @param boolean $is_gotofile whether to go to a file * @param String $db current database * @param String $table current table * @param boolean $find_real_end whether to find the real end * @param String $sql_query_for_bookmark sql query to be stored as bookmark * @param array $extra_data extra data * * @return mixed */ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data) { $response = PMA_Response::getInstance(); $response->getHeader()->getMenu()->setTable($table); // Only if we ask to see the php code if (isset($GLOBALS['show_as_php'])) { $result = null; $num_rows = 0; $unlim_num_rows = 0; } else { // If we don't ask to see the php code if (isset($_SESSION['profiling']) && PMA_Util::profilingSupported()) { $GLOBALS['dbi']->query('SET PROFILING=1;'); } $result = PMA_executeQueryAndStoreResults($full_sql_query); // Displays an error message if required and stop parsing the script $error = $GLOBALS['dbi']->getError(); if ($error) { PMA_handleQueryExecuteError($is_gotofile, $error, $full_sql_query); } // If there are no errors and bookmarklabel was given, // store the query as a bookmark if (!empty($_POST['bkm_label']) && !empty($sql_query_for_bookmark)) { $cfgBookmark = PMA_Bookmark_getParams(); PMA_storeTheQueryAsBookmark($db, $cfgBookmark['user'], $sql_query_for_bookmark, $_POST['bkm_label'], isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null); } // end store bookmarks // Gets the number of rows affected/returned // (This must be done immediately after the query because // mysql_affected_rows() reports about the last query done) $num_rows = PMA_getNumberOfRowsAffectedOrChanged($analyzed_sql_results['is_affected'], $result, isset($num_rows) ? $num_rows : null); // Grabs the profiling results if (isset($_SESSION['profiling']) && PMA_Util::profilingSupported()) { $profiling_results = $GLOBALS['dbi']->fetchResult('SHOW PROFILE;'); } $justBrowsing = PMA_isJustBrowsing($analyzed_sql_results, isset($find_real_end) ? $find_real_end : null); $unlim_num_rows = PMA_countQueryResults($num_rows, $analyzed_sql_results['is_select'], $justBrowsing, $db, $table, $analyzed_sql_results['parsed_sql'], $analyzed_sql_results); $extra_data = PMA_cleanupRelations(isset($db) ? $db : '', isset($table) ? $table : '', isset($_REQUEST['dropped_column']) ? $_REQUEST['dropped_column'] : null, isset($_REQUEST['purge']) ? $_REQUEST['purge'] : null, isset($extra_data) ? $extra_data : null); // Update Indexes list. if (isset($_REQUEST['index_change'])) { $extra_data['indexes_list'] = PMA_Index::getView($table, $db); } } return array($result, $num_rows, $unlim_num_rows, isset($profiling_results) ? $profiling_results : null, $extra_data); }
/** * Returns JSon for query_analyzer * * @return Array */ function PMA_getJsonForQueryAnalyzer() { $return = array(); if (strlen($_REQUEST['database'])) { $GLOBALS['dbi']->selectDb($_REQUEST['database']); } if ($profiling = PMA_Util::profilingSupported()) { $GLOBALS['dbi']->query('SET PROFILING=1;'); } // Do not cache query $query = preg_replace('/^(\\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query']); $result = $GLOBALS['dbi']->tryQuery($query); $return['affectedRows'] = $GLOBALS['cached_affected_rows']; $result = $GLOBALS['dbi']->tryQuery('EXPLAIN ' . $query); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $return['explain'][] = $row; } // In case an error happened $return['error'] = $GLOBALS['dbi']->getError(); $GLOBALS['dbi']->freeResult($result); if ($profiling) { $return['profiling'] = array(); $result = $GLOBALS['dbi']->tryQuery('SELECT seq,state,duration FROM INFORMATION_SCHEMA.PROFILING' . ' WHERE QUERY_ID=1 ORDER BY seq'); while ($row = $GLOBALS['dbi']->fetchAssoc($result)) { $return['profiling'][] = $row; } $GLOBALS['dbi']->freeResult($result); } return $return; }
} } PMA_Bookmark_save($bfields, isset($bkm_all_users)); $bookmark_created = true; } // end store bookmarks // Gets the number of rows affected/returned // (This must be done immediately after the query because // mysql_affected_rows() reports about the last query done) if (!$is_affected) { $num_rows = $result ? @PMA_DBI_num_rows($result) : 0; } elseif (!isset($num_rows)) { $num_rows = @PMA_DBI_affected_rows(); } // Grabs the profiling results if (isset($_SESSION['profiling']) && PMA_Util::profilingSupported()) { $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;'); } // Checks if the current database has changed // This could happen if the user sends a query like "USE `database`;" /** * commented out auto-switching to active database - really required? * bug #2558 win: table list disappears (mixed case db names) * https://sourceforge.net/p/phpmyadmin/bugs/2558/ * @todo RELEASE test and comit or rollback before release $current_db = PMA_DBI_fetch_value('SELECT DATABASE()'); if ($db !== $current_db) { $db = $current_db; $reload = 1; } unset($current_db);
'SHOW GLOBAL VARIABLES WHERE Variable_name IN' . ' ("general_log","slow_query_log","long_query_time","log_output")', 0, 1 ); exit(json_encode($loggingVars)); } if (isset($_REQUEST['query_analyzer'])) { $return = array(); if (strlen($_REQUEST['database'])) { PMA_DBI_select_db($_REQUEST['database']); } if ($profiling == PMA_Util::profilingSupported()) { PMA_DBI_query('SET PROFILING=1;'); } // Do not cache query $query = preg_replace( '/^(\s*SELECT)/i', '\\1 SQL_NO_CACHE', $_REQUEST['query'] ); $result = PMA_DBI_try_query($query); $return['affectedRows'] = $GLOBALS['cached_affected_rows']; $result = PMA_DBI_try_query('EXPLAIN ' . $query); while ($row = PMA_DBI_fetch_assoc($result)) {
$_SESSION['tmpval']['previous_server'] = $GLOBALS['server']; } else { // end server connecting // No need to check for 'PMA_BYPASS_GET_INSTANCE' since this execution path // applies only to initial login $response = PMA_Response::getInstance(); $response->getHeader()->disableMenuAndConsole(); $response->getFooter()->setMinimal(); } /** * check if profiling was requested and remember it * (note: when $cfg['ServerDefault'] = 0, constant is not defined) */ if (isset($_REQUEST['profiling']) && PMA_Util::profilingSupported() ) { $_SESSION['profiling'] = true; } elseif (isset($_REQUEST['profiling_form'])) { // the checkbox was unchecked unset($_SESSION['profiling']); } // load user preferences $GLOBALS['PMA_Config']->loadUserPreferences(); /** * Inclusion of profiling scripts is needed on various * pages like sql, tbl_sql, db_sql, tbl_select */ if (! defined('PMA_BYPASS_GET_INSTANCE')) {