removed MySQL < 5 code
This commit is contained in:
@@ -226,10 +226,7 @@ class PMA_Table {
|
|||||||
if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) {
|
if (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view']) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// old MySQL version: no view
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 50000) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// This would be the correct way of doing the check but at least in
|
// This would be the correct way of doing the check but at least in
|
||||||
// MySQL 5.0.33 it's too slow when there are hundreds of databases
|
// MySQL 5.0.33 it's too slow when there are hundreds of databases
|
||||||
// and/or tables (more than 3 minutes for 400 tables)
|
// and/or tables (more than 3 minutes for 400 tables)
|
||||||
@@ -296,8 +293,7 @@ class PMA_Table {
|
|||||||
$query .= ' ' . $attribute;
|
$query .= ' ' . $attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation)
|
if (!empty($collation) && $collation != 'NULL'
|
||||||
&& $collation != 'NULL'
|
|
||||||
&& preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
|
&& preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type)) {
|
||||||
$query .= PMA_generateCharsetQueryPart($collation);
|
$query .= PMA_generateCharsetQueryPart($collation);
|
||||||
}
|
}
|
||||||
@@ -346,7 +342,7 @@ class PMA_Table {
|
|||||||
} // end if
|
} // end if
|
||||||
} // end if (auto_increment)
|
} // end if (auto_increment)
|
||||||
}
|
}
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) {
|
if (!empty($comment)) {
|
||||||
$query .= " COMMENT '" . PMA_sqlAddslashes($comment) . "'";
|
$query .= " COMMENT '" . PMA_sqlAddslashes($comment) . "'";
|
||||||
}
|
}
|
||||||
return $query;
|
return $query;
|
||||||
@@ -800,7 +796,7 @@ class PMA_Table {
|
|||||||
PMA_query_as_cu($table_query);
|
PMA_query_as_cu($table_query);
|
||||||
unset($table_query);
|
unset($table_query);
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
|
$GLOBALS['sql_query'] .= "\n\n" . $sql_drop_query . ';';
|
||||||
// end if ($move)
|
// end if ($move)
|
||||||
} else {
|
} else {
|
||||||
@@ -843,7 +839,7 @@ class PMA_Table {
|
|||||||
$where_fields = array('db_name' => $source_db, 'table_name' => $source_table);
|
$where_fields = array('db_name' => $source_db, 'table_name' => $source_table);
|
||||||
$new_fields = array('db_name' => $target_db, 'table_name' => $target_table);
|
$new_fields = array('db_name' => $target_db, 'table_name' => $target_table);
|
||||||
PMA_Table::duplicateInfo('displaywork', 'table_info', $get_fields, $where_fields, $new_fields);
|
PMA_Table::duplicateInfo('displaywork', 'table_info', $get_fields, $where_fields, $new_fields);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo revise this code when we support cross-db relations
|
* @todo revise this code when we support cross-db relations
|
||||||
|
164
sql.php
164
sql.php
@@ -283,25 +283,6 @@ if (strlen($db)) {
|
|||||||
PMA_DBI_select_db($db);
|
PMA_DBI_select_db($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the query is a DELETE query with no WHERE clause, get the number of
|
|
||||||
// rows that will be deleted (mysql_affected_rows will always return 0 in
|
|
||||||
// this case)
|
|
||||||
// Note: testing shows that this no longer applies since MySQL 4.0.x
|
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 40000) {
|
|
||||||
if ($is_delete
|
|
||||||
&& preg_match('@^DELETE([[:space:]].+)?(FROM[[:space:]](.+))$@i', $sql_query, $parts)
|
|
||||||
&& !preg_match('@[[:space:]]WHERE[[:space:]]@i', $parts[3])) {
|
|
||||||
$cnt_all_result = @PMA_DBI_try_query('SELECT COUNT(*) as count ' . $parts[2]);
|
|
||||||
if ($cnt_all_result) {
|
|
||||||
list($num_rows) = PMA_DBI_fetch_row($cnt_all_result);
|
|
||||||
PMA_DBI_free_result($cnt_all_result);
|
|
||||||
} else {
|
|
||||||
$num_rows = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// E x e c u t e t h e q u e r y
|
// E x e c u t e t h e q u e r y
|
||||||
|
|
||||||
// Only if we didn't ask to see the php code (mikebeck)
|
// Only if we didn't ask to see the php code (mikebeck)
|
||||||
@@ -312,7 +293,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
|
|||||||
if (isset($_SESSION['profiling'])) {
|
if (isset($_SESSION['profiling'])) {
|
||||||
PMA_DBI_query('SET PROFILING=1;');
|
PMA_DBI_query('SET PROFILING=1;');
|
||||||
}
|
}
|
||||||
|
|
||||||
// garvin: Measure query time.
|
// garvin: Measure query time.
|
||||||
// TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
|
// TODO-Item http://sourceforge.net/tracker/index.php?func=detail&aid=571934&group_id=23067&atid=377411
|
||||||
$querytime_before = array_sum(explode(' ', microtime()));
|
$querytime_before = array_sum(explode(' ', microtime()));
|
||||||
@@ -347,7 +328,7 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
|
|||||||
if (isset($_SESSION['profiling'])) {
|
if (isset($_SESSION['profiling'])) {
|
||||||
$profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
|
$profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the current database has changed
|
// Checks if the current database has changed
|
||||||
// This could happen if the user sends a query like "USE `database`;"
|
// This could happen if the user sends a query like "USE `database`;"
|
||||||
$res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
|
$res = PMA_DBI_query('SELECT DATABASE() AS \'db\';');
|
||||||
@@ -399,122 +380,53 @@ if (isset($GLOBALS['show_as_php']) || !empty($GLOBALS['validatequery'])) {
|
|||||||
|
|
||||||
} else { // n o t " j u s t b r o w s i n g "
|
} else { // n o t " j u s t b r o w s i n g "
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 40000) {
|
// add select expression after the SQL_CALC_FOUND_ROWS
|
||||||
|
|
||||||
// detect this case:
|
// for UNION, just adding SQL_CALC_FOUND_ROWS
|
||||||
// SELECT DISTINCT x AS foo, y AS bar FROM sometable
|
// after the first SELECT works.
|
||||||
|
|
||||||
if (isset($analyzed_sql[0]['queryflags']['distinct'])) {
|
// take the left part, could be:
|
||||||
$count_what = 'DISTINCT ';
|
// SELECT
|
||||||
$first_expr = true;
|
// (SELECT
|
||||||
foreach ($analyzed_sql[0]['select_expr'] as $part) {
|
$count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
|
||||||
$count_what .= (!$first_expr ? ', ' : '') . $part['expr'];
|
$count_query .= ' SQL_CALC_FOUND_ROWS ';
|
||||||
$first_expr = false;
|
// add everything that was after the first SELECT
|
||||||
}
|
$count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
|
||||||
} else {
|
// ensure there is no semicolon at the end of the
|
||||||
$count_what = '*';
|
// count query because we'll probably add
|
||||||
}
|
// a LIMIT 1 clause after it
|
||||||
// this one does not apply to VIEWs
|
$count_query = rtrim($count_query);
|
||||||
$count_query = 'SELECT COUNT(' . $count_what . ') AS count';
|
$count_query = rtrim($count_query, ';');
|
||||||
}
|
|
||||||
|
|
||||||
// add the remaining of select expression if there is
|
|
||||||
// a GROUP BY or HAVING clause
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 40000
|
|
||||||
&& $count_what =='*'
|
|
||||||
&& (!empty($analyzed_sql[0]['group_by_clause'])
|
|
||||||
|| !empty($analyzed_sql[0]['having_clause']))) {
|
|
||||||
$count_query .= ' ,' . $analyzed_sql[0]['select_expr_clause'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40000) {
|
|
||||||
// add select expression after the SQL_CALC_FOUND_ROWS
|
|
||||||
|
|
||||||
// for UNION, just adding SQL_CALC_FOUND_ROWS
|
|
||||||
// after the first SELECT works.
|
|
||||||
|
|
||||||
// take the left part, could be:
|
|
||||||
// SELECT
|
|
||||||
// (SELECT
|
|
||||||
$count_query = PMA_SQP_formatHtml($parsed_sql, 'query_only', 0, $analyzed_sql[0]['position_of_first_select'] + 1);
|
|
||||||
$count_query .= ' SQL_CALC_FOUND_ROWS ';
|
|
||||||
// add everything that was after the first SELECT
|
|
||||||
$count_query .= PMA_SQP_formatHtml($parsed_sql, 'query_only', $analyzed_sql[0]['position_of_first_select']+1);
|
|
||||||
// ensure there is no semicolon at the end of the
|
|
||||||
// count query because we'll probably add
|
|
||||||
// a LIMIT 1 clause after it
|
|
||||||
$count_query = rtrim($count_query);
|
|
||||||
$count_query = rtrim($count_query, ';');
|
|
||||||
} else { // PMA_MYSQL_INT_VERSION < 40000
|
|
||||||
|
|
||||||
if (!empty($analyzed_sql[0]['from_clause'])) {
|
|
||||||
$count_query .= ' FROM ' . $analyzed_sql[0]['from_clause'];
|
|
||||||
}
|
|
||||||
if (!empty($analyzed_sql[0]['where_clause'])) {
|
|
||||||
$count_query .= ' WHERE ' . $analyzed_sql[0]['where_clause'];
|
|
||||||
}
|
|
||||||
if (!empty($analyzed_sql[0]['group_by_clause'])) {
|
|
||||||
$count_query .= ' GROUP BY ' . $analyzed_sql[0]['group_by_clause'];
|
|
||||||
}
|
|
||||||
if (!empty($analyzed_sql[0]['having_clause'])) {
|
|
||||||
$count_query .= ' HAVING ' . $analyzed_sql[0]['having_clause'];
|
|
||||||
}
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
// if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
|
// if using SQL_CALC_FOUND_ROWS, add a LIMIT to avoid
|
||||||
// long delays. Returned count will be complete anyway.
|
// long delays. Returned count will be complete anyway.
|
||||||
// (but a LIMIT would disrupt results in an UNION)
|
// (but a LIMIT would disrupt results in an UNION)
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40000
|
if (!isset($analyzed_sql[0]['queryflags']['union'])) {
|
||||||
&& !isset($analyzed_sql[0]['queryflags']['union'])) {
|
|
||||||
$count_query .= ' LIMIT 1';
|
$count_query .= ' LIMIT 1';
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the count query
|
// run the count query
|
||||||
|
|
||||||
if (PMA_MYSQL_INT_VERSION < 40000) {
|
PMA_DBI_try_query($count_query);
|
||||||
if ($cnt_all_result = PMA_DBI_try_query($count_query)) {
|
// if (mysql_error()) {
|
||||||
if ($is_group && $count_what == '*') {
|
// void.
|
||||||
$unlim_num_rows = @PMA_DBI_num_rows($cnt_all_result);
|
// I tried the case
|
||||||
} else {
|
// (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
|
||||||
$unlim_num_rows = PMA_DBI_fetch_assoc($cnt_all_result);
|
// UNION (SELECT `User`, `Host`, "%" AS "Db",
|
||||||
$unlim_num_rows = $unlim_num_rows['count'];
|
// `Select_priv`
|
||||||
}
|
// FROM `user`) ORDER BY `User`, `Host`, `Db`;
|
||||||
PMA_DBI_free_result($cnt_all_result);
|
// and although the generated count_query is wrong
|
||||||
} else {
|
// the SELECT FOUND_ROWS() work! (maybe it gets the
|
||||||
if (PMA_DBI_getError()) {
|
// count from the latest query that worked)
|
||||||
|
//
|
||||||
// there are some cases where the generated
|
// another case where the count_query is wrong:
|
||||||
// count_query (for MySQL 3) is wrong,
|
// SELECT COUNT(*), f1 from t1 group by f1
|
||||||
// so we get here.
|
// and you click to sort on count(*)
|
||||||
/**
|
// }
|
||||||
* @todo use a big unlimited query to get the correct
|
$cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;');
|
||||||
* number of rows (depending on a config variable?)
|
list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result);
|
||||||
*/
|
@PMA_DBI_free_result($cnt_all_result);
|
||||||
$unlim_num_rows = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
PMA_DBI_try_query($count_query);
|
|
||||||
// if (mysql_error()) {
|
|
||||||
// void.
|
|
||||||
// I tried the case
|
|
||||||
// (SELECT `User`, `Host`, `Db`, `Select_priv` FROM `db`)
|
|
||||||
// UNION (SELECT `User`, `Host`, "%" AS "Db",
|
|
||||||
// `Select_priv`
|
|
||||||
// FROM `user`) ORDER BY `User`, `Host`, `Db`;
|
|
||||||
// and although the generated count_query is wrong
|
|
||||||
// the SELECT FOUND_ROWS() work! (maybe it gets the
|
|
||||||
// count from the latest query that worked)
|
|
||||||
//
|
|
||||||
// another case where the count_query is wrong:
|
|
||||||
// SELECT COUNT(*), f1 from t1 group by f1
|
|
||||||
// and you click to sort on count(*)
|
|
||||||
// }
|
|
||||||
$cnt_all_result = PMA_DBI_query('SELECT FOUND_ROWS() as count;');
|
|
||||||
list($unlim_num_rows) = PMA_DBI_fetch_row($cnt_all_result);
|
|
||||||
@PMA_DBI_free_result($cnt_all_result);
|
|
||||||
}
|
|
||||||
} // end else "just browsing"
|
} // end else "just browsing"
|
||||||
|
|
||||||
} else { // not $is_select
|
} else { // not $is_select
|
||||||
@@ -678,7 +590,7 @@ else {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hide edit and delete links for information_schema
|
// hide edit and delete links for information_schema
|
||||||
if (PMA_MYSQL_INT_VERSION >= 50002 && $db == 'information_schema') {
|
if ($db == 'information_schema') {
|
||||||
$disp_mode = 'nnnn110111';
|
$disp_mode = 'nnnn110111';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -262,17 +262,13 @@ if (strstr($show_comment, '; InnoDB free') === false) {
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php
|
|
||||||
if (PMA_MYSQL_INT_VERSION >= 40100) {
|
|
||||||
?>
|
|
||||||
<!-- Table character set -->
|
<!-- Table character set -->
|
||||||
<tr><td><?php echo $strCollation; ?></td>
|
<tr><td><?php echo $strCollation; ?></td>
|
||||||
<td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
|
<td><?php echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION,
|
||||||
'tbl_collation', null, $tbl_collation, false, 3); ?>
|
'tbl_collation', null, $tbl_collation, false, 3); ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
|
||||||
if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM') {
|
if ($tbl_type == 'MYISAM' || $tbl_type == 'ISAM') {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
Reference in New Issue
Block a user