replaced MYSQL_MAJOR_VERSION and MYSQL_MINOR_VERSION constants by MYSQL_INT_VERSION

This commit is contained in:
Loïc Chapeaux
2001-08-21 16:28:36 +00:00
parent ba9aaa4c0f
commit 8fafafb823
12 changed files with 42 additions and 37 deletions

View File

@@ -27,6 +27,11 @@ $Source$
* lib.inc.php3; db_readdump.php3, line 82: restored the use of the
remove_remarks function that is required (else sql dump files starting
with comments won't be successfully splitted into single queries).
* defines.inc.php3; db_details.php3; ldi_check.php3; lib.inc.php3;
tbl_copy.php3; tbl_create.php3; tbl_dump.php3; tbl_printview.php3;
tbl_properties.inc.php3; tbl_properties.php3; user_details.php3:
replaced MYSQL_MAJOR_VERSION and MYSQL_MINOR_VERSION constants by
MYSQL_INT_VERSION.
2001-08-20 Olivier M<>ller <om@omnis.ch>
* db_stats.php3: new file and feature (sorry :) : simply display an

View File

@@ -39,9 +39,9 @@ if (mysql_error() != '') {
}
// speedup view on locked tables - staybyte - 11 June 2001
if ($num_tables > 0 && MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 3) {
if ($num_tables > 0 && MYSQL_INT_VERSION >= 32303) {
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfgSkipLockedTables == TRUE && MYSQL_MAJOR_VERSION == 3.23 && intval(MYSQL_MINOR_VERSION) >= 30) {
if ($cfgSkipLockedTables == TRUE && MYSQL_INT_VERSION >= 32330) {
$query = 'SHOW OPEN TABLES FROM ' . backquote($db);
$result = mysql_query($query);
// Blending out tables in use
@@ -89,7 +89,7 @@ if ($num_tables == 0) {
echo $strNoTablesFound . "\n";
}
// show table size on mysql >= 3.23 - staybyte - 11 June 2001
else if (MYSQL_MAJOR_VERSION >= 3.23 && isset($tbl_cache)) {
else if (MYSQL_INT_VERSION >= 32300 && isset($tbl_cache)) {
?>
@@ -466,7 +466,7 @@ if ($num_tables > 0) {
</tr>
<?php
// Add backquotes checkbox
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 6) {
if (MYSQL_INT_VERSION >= 32306) {
?>
<tr>
<td<?php echo $colspan; ?>>

View File

@@ -5,13 +5,12 @@
/**
* DEFINES VARIABLES & CONSTANTS
* Overview:
* MYSQL_MAJOR_VERSION (double) - eg: 3.23
* MYSQL_MINOR_VERSION (double) - eg: 39
* PHPMYADMIN_VERSION (string) - phpMyAdmin version string
* PHP_INT_VERSION (int) - eg: 30017 instead of 3.0.17 or
* 40006 instead of 4.0.6RC3
* PMA_WINDOWS (bool) - mark if phpMyAdmin running on windows
* server
* MYSQL_INT_VERSION (int) - eg: 32339 instead of 3.23.39
*/
// phpMyAdmin release
if (!defined('PHPMYADMIN_VERSION')) {
@@ -51,21 +50,28 @@ if (!defined('MYSQL_MAJOR_VERSION') && isset($link)) {
if (!empty($server)) {
$result = mysql_query('SELECT VERSION() AS version');
if ($result != FALSE && @mysql_num_rows($result) > 0) {
$row = mysql_fetch_array($result);
define('MYSQL_MAJOR_VERSION', (double)substr($row['version'], 0, 4));
define('MYSQL_MINOR_VERSION', (double)substr($row['version'], 5));
$row = mysql_fetch_array($result);
$match = explode('.', $row['version']);
} else {
$result = @mysql_query('SHOW VARIABLES LIKE \'version\'');
if ($result != FALSE && @mysql_num_rows($result) > 0){
$row = mysql_fetch_row($result);
define('MYSQL_MAJOR_VERSION', (double)substr($row[1], 0, 4));
define('MYSQL_MINOR_VERSION', (double)substr($row[1], 5));
$row = mysql_fetch_row($result);
$match = explode('.', $row[1]);
}
}
} // end server id is defined case
if (!defined('MYSQL_MAJOR_VERSION')) {
define('MYSQL_MAJOR_VERSION', 3.21);
define('MYSQL_MINOR_VERSION', 0);
} // end if
if (!isset($match) || !isset($match[0])) {
$match[0] = 3;
}
if (!isset($match[1])) {
$match[1] = 21;
}
if (!isset($match[2])) {
$match[2] = 0;
}
define('MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
unset($match);
}
?>

View File

@@ -65,7 +65,7 @@ if (isset($btnLDI) && ($textfile != 'none')) {
$query .= ' LINES TERMINATED BY \'' . $line_terminator . '\'';
}
if (strlen($column_name) > 0) {
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 6) {
if (MYSQL_INT_VERSION >= 32306) {
$query .= ' (';
$tmp = split(',( ?)', $column_name);
for ($i = 0; $i < count($tmp); $i++) {

View File

@@ -130,8 +130,6 @@ if (!defined('__LIB_INC__')){
*/
function mysql_die($error_message = '', $the_query = '')
{
global $sql_query;
if (!$error_message) {
$error_message = mysql_error();
}
@@ -424,7 +422,7 @@ if (!defined('__LIB_INC__')){
function backquote($a_name, $do_it = TRUE)
{
if ($do_it
&& MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 6
&& MYSQL_INT_VERSION >= 32306
&& !empty($a_name) && $a_name != '*') {
return '`' . $a_name . '`';
} else {
@@ -1279,7 +1277,7 @@ var errorMsg2 = '<?php echo(str_replace('\'', '\\\'', $GLOBALS['strNotValidNumbe
// Steve Alberty's patch for complete table dump,
// modified by Lem9 to allow older MySQL versions to continue to work
if (MYSQL_MAJOR_VERSION == 3.23 && intval(MYSQL_MINOR_VERSION) > 20) {
if (MYSQL_MAJOR_VERSION >= 32321) {
// Whether to quote table and fields names or not
if ($use_backquotes) {
mysql_query('SET SQL_QUOTE_SHOW_CREATE = 1');

View File

@@ -56,7 +56,7 @@ if (isset($new_name) && trim($new_name) != '') {
// Copy the data
if ($result != FALSE && $what == 'data') {
// speedup copy table - staybyte - 22. Juni 2001
if (MYSQL_MAJOR_VERSION >= 3.23) {
if (MYSQL_INT_VERSION >= 32300) {
$sql_insert_data = 'INSERT INTO ' . backquote($new_name) . ' SELECT * FROM ' . backquote($table);
$result = mysql_query($sql_insert_data) or mysql_die();
} // end MySQL >= 3.23

View File

@@ -121,7 +121,7 @@ if (isset($submit)) {
if (!empty($tbl_type) && ($tbl_type != 'Default')) {
$sql_query .= ' TYPE = ' . $tbl_type;
}
if (MYSQL_MAJOR_VERSION == 3.23 && !empty($comment)) {
if (MYSQL_INT_VERSION >= 32300 && !empty($comment)) {
$sql_query .= ' comment = \'' . sql_addslashes($comment) . '\'';
}

View File

@@ -170,7 +170,7 @@ else {
: '\'' . $db . '\'';
$dump_buffer .= $crlf
. '# ' . $strGenTime . ': ' . date('F j, Y, g:i a') . $crlf
. '# ' . $strServerVersion . ': ' . MYSQL_MAJOR_VERSION . '.' . MYSQL_MINOR_VERSION . $crlf
. '# ' . $strServerVersion . ': ' . substr(MYSQL_INT_VERSION, 0, 1) . '.' . substr(MYSQL_INT_VERSION, 1, 2) . '.' . substr(MYSQL_INT_VERSION, 3) . $crlf
. '# ' . $strPHPVersion . ': ' . phpversion() . $crlf
. '# ' . $strDatabase . ': ' . $formatted_db_name . $crlf;

View File

@@ -23,7 +23,7 @@ mysql_select_db($db);
/**
* Displays the comments of the table is MySQL >= 3.23
*/
if (MYSQL_MAJOR_VERSION >= 3.23) {
if (MYSQL_INT_VERSION >= 32300) {
$result = mysql_query('SHOW TABLE STATUS LIKE \'' . sql_addslashes($table, TRUE) . '\'') or mysql_die();
$row = mysql_fetch_array($result);
if (!empty($row['Comment'])) {

View File

@@ -216,7 +216,7 @@ for ($i = 0 ; $i < $num_fields; $i++) {
<br />
<?php
if ($action == 'tbl_create.php3' && MYSQL_MAJOR_VERSION >= 3.23) {
if ($action == 'tbl_create.php3' && MYSQL_INT_VERSION >= 32300) {
echo "\n";
?>
<table>

View File

@@ -67,7 +67,7 @@ $url_query = 'lang=' . $lang
* Gets table informations
*/
// 1. Get table type and comments ('show table' works correct since 3.23.03)
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 3) {
if (MYSQL_INT_VERSION >= 32303) {
// Update table type, comment and order if required by the user
if (isset($submitcomment)) {
if (get_magic_quotes_gpc()) {
@@ -326,7 +326,7 @@ $nonisam = FALSE;
if (!eregi('ISAM|HEAP', $showtable['Type'])) {
$nonisam = TRUE;
}
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) > 3 && $nonisam == FALSE && isset($showtable)) {
if (MYSQL_INT_VERSION >= 32303 && $nonisam == FALSE && isset($showtable)) {
// Gets some sizes
$mergetable = FALSE;
if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
@@ -625,7 +625,7 @@ while (list($junk, $fieldname) = each($aryFields)) {
</li>
<?php
if (MYSQL_MAJOR_VERSION >= 3.23 && MYSQL_MINOR_VERSION >= 34) {
if (MYSQL_INT_VERSION >= 32334) {
?>
<!-- Order the table -->
<li>
@@ -695,7 +695,7 @@ echo "\n";
<?php echo $strExtendedInserts; ?><br />
<?php
// Add backquotes checkbox
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 6) {
if (MYSQL_INT_VERSION >= 32306) {
?>
<input type="checkbox" name="use_backquotes" value="1" />
<?php echo $strUseBackquotes; ?><br />
@@ -820,7 +820,7 @@ echo "\n";
</li>
<?php
if (MYSQL_MAJOR_VERSION >= 3.23 && intval(MYSQL_MINOR_VERSION) >= 22) {
if (MYSQL_INT_VERSION >= 32322) {
if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
?>
<!-- Table maintenance -->

View File

@@ -235,15 +235,11 @@ function grant_operations()
}
function protect_name(db_or_table) {
var js_mysql_major_version, js_mysql_minor_version;
js_mysql_major_version = <?php echo MYSQL_MAJOR_VERSION ?>;
js_mysql_minor_version = <?php echo MYSQL_MINOR_VERSION ?>;
var js_mysql_version = <?php echo MYSQL_INT_VERSION ?>;
if (js_mysql_major_version >= "3.23") {
if (js_mysql_minor_version >= "6") {
if (js_mysql_version >= 32306) {
<!-- return "`" + db_or_table + "`"; -->
return db_or_table;
}
}
else {
return db_or_table;