config option to disable use of information_schema (if ok backport to QA_2_11)

This commit is contained in:
Sebastian Mendel
2007-12-13 10:07:01 +00:00
parent d462d869ad
commit 560c6d4f6f
2 changed files with 286 additions and 159 deletions

View File

@@ -312,6 +312,15 @@ $cfg['Servers'][$i]['AllowRoot'] = true;
*/ */
$cfg['Servers'][$i]['AllowDeny']['order'] = ''; $cfg['Servers'][$i]['AllowDeny']['order'] = '';
/**
* Disable use of INFORMATION_SCHEMA
*
* @see http://sf.net/support/tracker.php?aid=1849494
* @see http://bugs.mysql.com/19588
* @global boolean $cfg['Servers'][$i]['DisableIS']
*/
$cfg['Servers'][$i]['DisableIS'] = true;
/** /**
* Host authentication rules, leave blank for defaults * Host authentication rules, leave blank for defaults
* *

View File

@@ -230,6 +230,7 @@ function PMA_DBI_get_tables_full($database, $table = false,
$tables = array(); $tables = array();
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
// get table information from information_schema // get table information from information_schema
if ($table) { if ($table) {
if (true === $tbl_is_group) { if (true === $tbl_is_group) {
@@ -286,6 +287,7 @@ function PMA_DBI_get_tables_full($database, $table = false,
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'), $tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'),
null, $link); null, $link);
unset($sql_where_table, $sql); unset($sql_where_table, $sql);
}
// If permissions are wrong on even one database directory, // If permissions are wrong on even one database directory,
// information_schema does not return any table info for any database // information_schema does not return any table info for any database
@@ -411,6 +413,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$apply_limit_and_order_manual = true; $apply_limit_and_order_manual = true;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
/** /**
* if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT * if $GLOBALS['cfg']['NaturalOrder'] is enabled, we cannot use LIMIT
* cause MySQL does not support natural ordering, we have to do it afterward * cause MySQL does not support natural ordering, we have to do it afterward
@@ -485,6 +488,49 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
unset($drop); unset($drop);
} }
unset($sql_where_schema, $sql, $drops); unset($sql_where_schema, $sql, $drops);
} else {
foreach ($GLOBALS['PMA_List_Database']->items as $database_name) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
if ($force_stats) {
require_once 'mysql_charsets.lib.php';
$databases[$database_name]['DEFAULT_COLLATION_NAME']
= PMA_getDbCollation($database_name);
// get additonal info about tables
$databases[$database_name]['SCHEMA_TABLES'] = 0;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($database_name) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS']
+= $row['Rows'];
$databases[$database_name]['SCHEMA_DATA_LENGTH']
+= $row['Data_length'];
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH']
+= $row['Max_data_length'];
$databases[$database_name]['SCHEMA_INDEX_LENGTH']
+= $row['Index_length'];
$databases[$database_name]['SCHEMA_DATA_FREE']
+= $row['Data_free'];
$databases[$database_name]['SCHEMA_LENGTH']
+= $row['Data_length'] + $row['Index_length'];
}
PMA_DBI_free_result($res);
unset($res);
}
}
}
/** /**
* apply limit and order manually now * apply limit and order manually now
@@ -534,6 +580,7 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
{ {
$columns = array(); $columns = array();
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$sql_wheres = array(); $sql_wheres = array();
$array_keys = array(); $array_keys = array();
@@ -572,7 +619,78 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
$sql .= "\n" . ' WHERE ' . implode(' AND ', $sql_wheres); $sql .= "\n" . ' WHERE ' . implode(' AND ', $sql_wheres);
} }
return PMA_DBI_fetch_result($sql, $array_keys, null, $link); $columns = PMA_DBI_fetch_result($sql, $array_keys, null, $link);
unset($sql_wheres, $sql);
} else {
if (null === $database) {
foreach ($GLOBALS['PMA_List_Database']->items as $database) {
$columns[$database] = PMA_DBI_get_columns_full($database, null,
null, $link);
}
return $columns;
} elseif (null === $table) {
$tables = PMA_DBI_get_tables($database);
foreach ($tables as $table) {
$columns[$table] = PMA_DBI_get_columns_full(
$database, $table, null, $link);
}
return $columns;
}
$sql = 'SHOW FULL COLUMNS FROM '
. PMA_backquote($database) . '.' . PMA_backquote($table);
if (null !== $column) {
$sql .= " LIKE '" . $column . "'";
}
$columns = PMA_DBI_fetch_result($sql, 'Field', null, $link);
$ordinal_position = 1;
foreach ($columns as $column_name => $each_column) {
// MySQL forward compatibility
// so pma could use this array as if every server is of version >5.0
$columns[$column_name]['COLUMN_NAME'] =& $columns[$column_name]['Field'];
$columns[$column_name]['COLUMN_TYPE'] =& $columns[$column_name]['Type'];
$columns[$column_name]['COLLATION_NAME'] =& $columns[$column_name]['Collation'];
$columns[$column_name]['IS_NULLABLE'] =& $columns[$column_name]['Null'];
$columns[$column_name]['COLUMN_KEY'] =& $columns[$column_name]['Key'];
$columns[$column_name]['COLUMN_DEFAULT'] =& $columns[$column_name]['Default'];
$columns[$column_name]['EXTRA'] =& $columns[$column_name]['Extra'];
$columns[$column_name]['PRIVILEGES'] =& $columns[$column_name]['Privileges'];
$columns[$column_name]['COLUMN_COMMENT'] =& $columns[$column_name]['Comment'];
$columns[$column_name]['TABLE_CATALOG'] = null;
$columns[$column_name]['TABLE_SCHEMA'] = $database;
$columns[$column_name]['TABLE_NAME'] = $table;
$columns[$column_name]['ORDINAL_POSITION'] = $ordinal_position;
$columns[$column_name]['DATA_TYPE'] =
substr($columns[$column_name]['COLUMN_TYPE'], 0,
strpos($columns[$column_name]['COLUMN_TYPE'], '('));
/**
* @todo guess CHARACTER_MAXIMUM_LENGTH from COLUMN_TYPE
*/
$columns[$column_name]['CHARACTER_MAXIMUM_LENGTH'] = null;
/**
* @todo guess CHARACTER_OCTET_LENGTH from CHARACTER_MAXIMUM_LENGTH
*/
$columns[$column_name]['CHARACTER_OCTET_LENGTH'] = null;
$columns[$column_name]['NUMERIC_PRECISION'] = null;
$columns[$column_name]['NUMERIC_SCALE'] = null;
$columns[$column_name]['CHARACTER_SET_NAME'] =
substr($columns[$column_name]['COLLATION_NAME'], 0,
strpos($columns[$column_name]['COLLATION_NAME'], '_'));
$ordinal_position++;
}
if (null !== $column) {
reset($columns);
$columns = current($columns);
}
}
return $columns;
} }
/** /**