1
0
mirror of https://github.com/phpmyadmin/phpmyadmin.git synced 2026-10-28 07:41:55 +03:00

bug #1084820, End>> and InnoDB

This commit is contained in:
Marc Delisle
2005-01-18 15:35:50 +00:00
parent bd03889a22
commit 4766676ee2
5 changed files with 63 additions and 14 deletions

View File

@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-01-18 Marc Delisle <lem9@users.sourceforge.net>
* sql.php, libraries/common.lib.php, /display_tbl.lib.php, /functions.js,
lang/*.php: bug #1084820: ask a confirmation when a user wants to
reach the End of rows, and count the exact number of rows to
go to the real end
TODO: page number selector
2005-01-18 Alexander M. Turek <me@derrabus.de>
* server_engines.php, server_links.php libraries/storage_engines.lib.php:
Emulation for < MySQL 4.1.2.

View File

@@ -1532,21 +1532,24 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
* @param string the current database name
* @param string the current table name
* @param boolean whether to retain or to displays the result
* @param boolean whether to force an exact count
*
* @return mixed the number of records if retain is required, true else
*
* @access public
*/
function PMA_countRecords($db, $table, $ret = FALSE)
function PMA_countRecords($db, $table, $ret = FALSE, $force_exact = FALSE)
{
global $err_url, $cfg;
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
if (!$force_exact) {
$result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
$showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
}
PMA_DBI_free_result($result);
}
PMA_DBI_free_result($result);
if (!isset($num)) {
$result = PMA_DBI_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));

View File

@@ -329,12 +329,19 @@ function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="sql_query" value="<?php echo $encoded_query; ?>" />
<input type="hidden" name="pos" value="<?php echo @((ceil($unlim_num_rows / $session_max_rows)- 1) * $session_max_rows); ?>" />
<?php
if ($unlim_num_rows > $GLOBALS['cfg']['MaxExactCount']) {
echo '<input type="hidden" name="find_real_end" value="1" />' . "\n";
// no backquote around this message
$onclick = ' onclick="return confirmAction(\'' . PMA_jsFormat($GLOBALS['strLongOperation'], FALSE) . '\')"';
}
?>
<input type="hidden" name="session_max_rows" value="<?php echo $session_max_rows; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo $disp_direction; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo $repeat_cells; ?>" />
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo $dontlimitchars; ?>" />
<input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> />
<input type="submit" name="navig" value="<?php echo $caption4; ?>"<?php echo $title4; ?> <?php echo (empty($onclick) ? '' : $onclick); ?>/>
</form>
</td>
<?php

View File

@@ -24,10 +24,10 @@ function confirmLinkDropDB(theLink, theSqlQuery)
}
return is_confirmed;
} // end of the 'confirmLink()' function
} // end of the 'confirmLinkDropDB()' function
/**
* Displays an confirmation box beforme to submit a "DROP/DELETE/ALTER" query.
* Displays an confirmation box before to submit a "DROP/DELETE/ALTER" query.
* This function is called while clicking links
*
* @param object the link
@@ -52,6 +52,27 @@ function confirmLink(theLink, theSqlQuery)
} // end of the 'confirmLink()' function
/**
* Displays an confirmation box before doing some action
*
* @param object the message to display
*
* @return boolean whether to run the query or not
*/
function confirmAction(theMessage)
{
// TODO: Confirmation is not required in the configuration file
// or browser is Opera (crappy js implementation)
if (typeof(window.opera) != 'undefined') {
return true;
}
var is_confirmed = confirm(theMessage);
return is_confirmed;
} // end of the 'confirmAction()' function
/**
* Displays an error message if a "DROP DATABASE" statement is submitted
* while it isn't allowed, else confirms a "DROP/DELETE/ALTER" query before
@@ -97,9 +118,6 @@ function confirmQuery(theForm1, sqlQuery1)
// For now, I just added a ^ to check for the statement at
// beginning of expression
//var do_confirm_re_0 = new RegExp('DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
//var do_confirm_re_1 = new RegExp('ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
//var do_confirm_re_2 = new RegExp('DELETE\\s+FROM\\s', 'i');
var do_confirm_re_0 = new RegExp('^DROP\\s+(IF EXISTS\\s+)?(TABLE|DATABASE)\\s', 'i');
var do_confirm_re_1 = new RegExp('^ALTER\\s+TABLE\\s+((`[^`]+`)|([A-Za-z0-9_$]+))\\s+DROP\\s', 'i');
var do_confirm_re_2 = new RegExp('^DELETE\\s+FROM\\s', 'i');

16
sql.php
View File

@@ -68,6 +68,15 @@ if (!defined('PMA_CHK_DROP')
} // end if
/**
* Need to find the real end of rows?
*/
if (isset($find_real_end) && $find_real_end) {
$unlim_num_rows = PMA_countRecords($db, $table, TRUE, TRUE);
$pos = @((ceil($unlim_num_rows / $session_max_rows) - 1) * $session_max_rows);
}
/**
* Bookmark add
*/
@@ -429,11 +438,16 @@ else {
// because SQL_CALC_FOUND_ROWS
// is not quick on large InnoDB tables
// but do not count again if we did it previously
// due to $find_real_end == TRUE
if (!$is_group
&& !isset($analyzed_sql[0]['queryflags']['union'])
&& !isset($analyzed_sql[0]['table_ref'][1]['table_name'])
&& (empty($analyzed_sql[0]['where_clause'])
|| $analyzed_sql[0]['where_clause'] == '1 ')) {
|| $analyzed_sql[0]['where_clause'] == '1 ')
&& !isset($find_real_end)
) {
// "j u s t b r o w s i n g"
$unlim_num_rows = PMA_countRecords($db, $table, TRUE);