Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Foellmann <foellmann@foe-services.de>2014-07-28 14:13:10 +0400
committerChristian Foellmann <foellmann@foe-services.de>2014-07-28 14:13:10 +0400
commit276394119dfbe117acd411a3862de597ba35a2ad (patch)
tree3dc394a15f459d6324e3452e15e9446e47fe3bd0 /libraries/sql.lib.php
parentc8c2e72886de1b71f5abcaa295075da9666096b5 (diff)
UPDATE phpmyadmin 4.2.6 multilanguage
Diffstat (limited to 'libraries/sql.lib.php')
-rw-r--r--libraries/sql.lib.php150
1 files changed, 95 insertions, 55 deletions
diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php
index 838e77dbaa..1042e4ad21 100644
--- a/libraries/sql.lib.php
+++ b/libraries/sql.lib.php
@@ -304,6 +304,28 @@ function PMA_getColumnNameInColumnDropSql($sql)
}
/**
+ * Verify whether the result set has columns from just one table
+ *
+ * @param array $fields_meta meta fields
+ *
+ * @return boolean whether the result set has columns from just one table
+ */
+function PMA_resultSetHasJustOneTable($fields_meta)
+{
+ $just_one_table = true;
+ $prev_table = $fields_meta[0]->table;
+ foreach ($fields_meta as $one_field_meta) {
+ if (! empty($one_field_meta->table)
+ && $one_field_meta->table != $prev_table
+ ) {
+ $just_one_table = false;
+ break;
+ }
+ }
+ return $just_one_table;
+}
+
+/**
* Verify whether the result set contains all the columns
* of at least one unique key
*
@@ -352,11 +374,6 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
{
$foreigners = PMA_getForeigners($db, $table, $column);
- $display_field = PMA_getDisplayField(
- $foreigners[$column]['foreign_db'],
- $foreigners[$column]['foreign_table']
- );
-
$foreignData = PMA_getForeignData($foreigners, $column, false, '', '');
if ($foreignData['disp_row'] == null) {
@@ -373,7 +390,7 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
. '</span>'
. '<a href="browse_foreigners.php'
. PMA_URL_getCommon($_url_params) . '"'
- . ' target="_blank" class="browse_foreign" ' .'>'
+ . ' target="_blank" class="browse_foreign" ' . '>'
. __('Browse foreign values')
. '</a>';
} else {
@@ -511,6 +528,7 @@ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
</script>
EOT;
$profiling_table .= "</div>";
+ $profiling_table .= "<div class='clearfloat'></div>";
//require_once 'libraries/chart.lib.php';
$profiling_table .= '<div id="profilingChartData" style="display:none;">';
@@ -800,7 +818,7 @@ function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $tabl
/**
* Function to check whether to remember the sorting order or not
*
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
*
* @return boolean
@@ -829,7 +847,7 @@ function PMA_isRememberSortingOrder($analyzed_sql_results)
/**
* Function to check whether the LIMIT clause should be appended or not
*
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
*
* @return boolean
@@ -855,7 +873,7 @@ function PMA_isAppendLimitClause($analyzed_sql_results)
/**
* Function to check whether this query is for just browsing
*
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
* @param boolean $find_real_end whether the real end should be found
*
@@ -879,6 +897,7 @@ function PMA_isJustBrowsing($analyzed_sql_results, $find_real_end)
&& empty($analyzed_sql_results['analyzed_sql'][0]['group_by_clause'])
&& ! isset($find_real_end)
&& !$analyzed_sql_results['is_subquery']
+ && empty($analyzed_sql_results['analyzed_sql'][0]['having_clause'])
) {
return true;
} else {
@@ -889,7 +908,7 @@ function PMA_isJustBrowsing($analyzed_sql_results, $find_real_end)
/**
* Function to check whether the reated transformation information shoul be deleted
*
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
*
* @return boolean
@@ -909,7 +928,7 @@ function PMA_isDeleteTransformationInfo($analyzed_sql_results)
/**
* Function to check whether the user has rights to drop the database
*
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
* @param boolean $allowUserDropDatabase whether the user is allowed to drop db
* @param boolean $is_superuser whether this user is a superuser
@@ -1026,11 +1045,11 @@ function PMA_addBookmark($pmaAbsoluteUri, $goto)
$response = PMA_Response::getInstance();
if ($response->isAjax()) {
if ($result) {
- $msg = PMA_message::success(__('Bookmark %s created'));
+ $msg = PMA_message::success(__('Bookmark %s has been created.'));
$msg->addParam($_POST['bkm_fields']['bkm_label']);
$response->addJSON('message', $msg);
} else {
- $msg = PMA_message::error(__('Bookmark not created'));
+ $msg = PMA_message::error(__('Bookmark not created!'));
$response->isSuccess(false);
$response->addJSON('message', $msg);
}
@@ -1068,16 +1087,13 @@ function PMA_findRealEndOfRows($db, $table)
*
* @param String $db the current database
* @param String $table the current table
- * @param String $display_field display field
*
* @return void
*/
-function PMA_getRelationalValues($db, $table, $display_field)
+function PMA_getRelationalValues($db, $table)
{
$column = $_REQUEST['column'];
if ($_SESSION['tmpval']['relational_display'] == 'D'
- && isset($display_field)
- && strlen($display_field)
&& isset($_REQUEST['relation_key_or_display_column'])
&& $_REQUEST['relation_key_or_display_column']
) {
@@ -1250,7 +1266,7 @@ function PMA_storeTheQueryAsBookmark($db, $bkm_user, $sql_query_for_bookmark,
$bookmarks = PMA_Bookmark_getList($db);
foreach ($bookmarks as $key => $val) {
if ($val == $bkm_label) {
- PMA_Bookmark_delete($db, $key);
+ PMA_Bookmark_delete($key);
}
}
}
@@ -1363,10 +1379,8 @@ function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
&& strlen($table)
) {
PMA_relationsCleanupColumn($db, $table, $dropped_column);
- if (isset($extra_data)) {
- // to refresh the list of indexes (Ajax mode)
- $extra_data['indexes_list'] = PMA_Index::getView($table, $db);
- }
+ // to refresh the list of indexes (Ajax mode)
+ $extra_data['indexes_list'] = PMA_Index::getView($table, $db);
}
return $extra_data;
@@ -1382,7 +1396,7 @@ function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
* @param string $db the current database
* @param string $table the current table
* @param array $parsed_sql parsed sql
- * @param array $analyzed_sql_results the analyzed query and other varibles set
+ * @param array $analyzed_sql_results the analyzed query and other variables set
* after analyzing the query
*
* @return int $unlim_num_rows unlimited number of rows
@@ -1407,11 +1421,30 @@ function PMA_countQueryResults(
// However, do not count again if we did it previously
// due to $find_real_end == true
if ($justBrowsing) {
+ // Get row count (is approximate for InnoDB)
$unlim_num_rows = PMA_Table::countRecords(
$db,
$table,
- true
+ false
);
+ /**
+ * @todo Can we know at this point that this is InnoDB,
+ * (in this case there would be no need for getting
+ * an exact count)?
+ */
+ if ($unlim_num_rows < $GLOBALS['cfg']['MaxExactCount']) {
+ // Get the exact count if approximate count
+ // is less than MaxExactCount
+ /**
+ * @todo In countRecords(), MaxExactCount is also verified,
+ * so can we avoid checking it twice?
+ */
+ $unlim_num_rows = PMA_Table::countRecords(
+ $db,
+ $table,
+ true
+ );
+ }
} else {
// add select expression after the SQL_CALC_FOUND_ROWS
@@ -1497,7 +1530,7 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
$db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data
) {
// Only if we ask to see the php code
- if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
+ if (isset($GLOBALS['show_as_php'])) {
$result = null;
$num_rows = 0;
$unlim_num_rows = 0;
@@ -1552,6 +1585,11 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
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,
@@ -1638,8 +1676,6 @@ function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results
} elseif (isset($GLOBALS['show_as_php'])) {
/* User disable showing as PHP, query is only displayed */
$message = PMA_Message::notice(__('Showing SQL query'));
- } elseif (! empty($GLOBALS['validatequery'])) {
- $message = PMA_Message::notice(__('Validated SQL'));
} else {
$message = PMA_Message::success(
__('MySQL returned an empty result set (i.e. zero rows).')
@@ -1647,7 +1683,9 @@ function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results
}
if (isset($GLOBALS['querytime'])) {
- $_querytime = PMA_Message::notice('(' . __('Query took %01.4f sec') . ')');
+ $_querytime = PMA_Message::notice(
+ '(' . __('Query took %01.4f seconds.') . ')'
+ );
$_querytime->addParam($GLOBALS['querytime']);
$message->addMessage($_querytime);
}
@@ -1692,7 +1730,7 @@ function PMA_sendAjaxResponseForNoResultsReturned($message, $analyzed_sql,
$createViewHTML = $displayResultsObject->getCreateViewQueryResultOp(
$analyzed_sql
);
- $response->addHTML($createViewHTML.'<br />');
+ $response->addHTML($createViewHTML . '<br />');
}
$response->addJSON(isset($extra_data) ? $extra_data : array());
@@ -1807,7 +1845,7 @@ function PMA_getHtmlForSqlQueryResults($previous_update_query_html,
function PMA_getBookmarkCreatedMessage()
{
if (isset($_GET['label'])) {
- $bookmark_created_msg = PMA_message::success(__('Bookmark %s created'));
+ $bookmark_created_msg = PMA_message::success(__('Bookmark %s has been created.'));
$bookmark_created_msg->addParam($_GET['label']);
} else {
$bookmark_created_msg = null;
@@ -1950,7 +1988,7 @@ function PMA_getHtmlForIndexesProblems($query_type, $selected, $db)
&& is_array($selected)
) {
$indexes_problems_html = '';
- foreach ($selected as $idx => $tbl_name) {
+ foreach ($selected as $tbl_name) {
$check = PMA_Index::findDuplicates($tbl_name, $db);
if (! empty($check)) {
$indexes_problems_html .= sprintf(
@@ -2055,7 +2093,9 @@ function PMA_sendQueryResponseForResultsReturned($result, $justBrowsing,
$db, $table, $fields_meta
);
- $editable = $has_unique || $updatableView;
+ $just_one_table = PMA_resultSetHasJustOneTable($fields_meta);
+
+ $editable = ($has_unique || $updatableView) && $just_one_table;
// Displays the results in a table
if (empty($disp_mode)) {
@@ -2233,29 +2273,29 @@ function PMA_sendQueryResponse($num_rows, $unlim_num_rows, $is_affected,
/**
* Function to execute the query and send the response
*
- * @param array $analyzed_sql_results analysed sql results
- * @param bool $is_gotofile whether goto file or not
- * @param string $db current database
- * @param string $table current table
- * @param bool $find_real_end whether to find real end or not
- * @param string $sql_query_for_bookmark the sql query to be stored as bookmark
- * @param array $extra_data extra data
- * @param bool $is_affected whether affected or not
- * @param string $message_to_show message to show
- * @param string $disp_mode display mode
- * @param string $message message
- * @param array $sql_data sql data
- * @param string $goto goto page url
- * @param string $pmaThemeImage uri of the PMA theme image
- * @param string $disp_query display query
- * @param string $disp_message display message
- * @param string $query_type query type
- * @param string $sql_query sql query
- * @param bool $selected whether check table, optimize table,
- * analyze table or repair table has been
- * selected with respect to the selected
- * tables from the database structure page
- * @param string $complete_query complete query
+ * @param array $analyzed_sql_results analysed sql results
+ * @param bool $is_gotofile whether goto file or not
+ * @param string $db current database
+ * @param string $table current table
+ * @param bool|null $find_real_end whether to find real end or not
+ * @param string $sql_query_for_bookmark the sql query to be stored as bookmark
+ * @param array|null $extra_data extra data
+ * @param bool $is_affected whether affected or not
+ * @param string $message_to_show message to show
+ * @param string $disp_mode display mode
+ * @param string $message message
+ * @param array|null $sql_data sql data
+ * @param string $goto goto page url
+ * @param string $pmaThemeImage uri of the PMA theme image
+ * @param string $disp_query display query
+ * @param string $disp_message display message
+ * @param string $query_type query type
+ * @param string $sql_query sql query
+ * @param bool|null $selected whether check table, optimize table,
+ * analyze table or repair table has been
+ * selected with respect to the selected
+ * tables from the database structure page
+ * @param string $complete_query complete query
*
* @return void
*/