Skip to content

Commit

Permalink
Resolve conflicts from upstream
Browse files Browse the repository at this point in the history
Signed-off-by: Jason <[email protected]>
  • Loading branch information
gzzhanghao committed Jul 23, 2015
1 parent 465a9ed commit 6636153
Show file tree
Hide file tree
Showing 30 changed files with 1,145 additions and 1,119 deletions.
3 changes: 2 additions & 1 deletion db_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@
$is_show_stats, $table_is_view, $sum_size, $overhead_size
);

if (! PMA_Table::isMerge($db, $current_table['TABLE_NAME'])) {
$_table = new PMA_Table($current_table['TABLE_NAME'], $db);
if (! $_table->isMerge()) {
$sum_entries += $current_table['TABLE_ROWS'];
}

Expand Down
7 changes: 2 additions & 5 deletions libraries/DBQbe.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,11 +1471,8 @@ private function _getMasterTable($search_tables, $search_columns,
$csize = array();
foreach ($candidate_columns as $table) {
if ($checked_tables[$table] != 1) {
$tsize[$table] = PMA_Table::countRecords(
$this->_db,
$table,
false
);
$_table = new PMA_Table($table, $this->_db);
$tsize[$table] = $_table->countRecords();
$checked_tables[$table] = 1;
}
$csize[$table] = $tsize[$table];
Expand Down
72 changes: 65 additions & 7 deletions libraries/DatabaseInterface.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
require_once './libraries/logging.lib.php';
require_once './libraries/Index.class.php';
require_once './libraries/SystemDatabase.class.php';
require_once './libraries/util.lib.php';

use PMA\Util;

/**
* Main interface for database interactions
Expand Down Expand Up @@ -42,6 +45,11 @@ class PMA_DatabaseInterface
*/
private $_extension;

/**
* @var array Table data cache
*/
private $_table_cache;

/**
* Constructor
*
Expand All @@ -50,6 +58,7 @@ class PMA_DatabaseInterface
function __construct($ext)
{
$this->_extension = $ext;
$this->_table_cache = array();
}

/**
Expand Down Expand Up @@ -87,6 +96,54 @@ public function query($query, $link = null, $options = 0,
return $res;
}

/**
* Get a cached value from table cache.
*
* @param $contentPath string Dot notation of the target value
* @param $default mixed Return value on cache miss
* @return mixed
*/
public function getCachedTableContent($contentPath, $default = null) {
return Util\get($this->_table_cache, $contentPath, $default);
}

/**
* Set an item in table cache using dot notation.
*
* @param $contentPath string Dot notation of the target path
* @param $value mixed Target value
*/
public function cacheTableContent($contentPath, $value) {
$loc = &$this->_table_cache;

if (!isset($contentPath)) {
$loc = $value;
return;
}

$keys = explode('.', $contentPath);

while (count($keys) > 1) {
$key = array_shift($keys);

// If the key doesn't exist at this depth, we will just create an empty array
// to hold the next value, allowing us to create the arrays to hold final
// values at the correct depth. Then we'll keep digging into the array.
if (!isset($loc[$key]) || !is_array($loc[$key])) {
$loc[$key] = array();
}
$loc = &$loc[$key];
}

$loc[array_shift($keys)] = $value;
}

/**
* Clear the table cache.
*/
public function clearTableCache() {
$this->_table_cache = array();
}

/**
* Caches table data so PMA_Table does not require to issue
Expand All @@ -107,18 +164,18 @@ private function _cacheTableData($tables, $table)
// we would lose a db name that consists only of numbers

foreach ($tables as $one_database => $its_tables) {
if (isset(PMA_Table::$cache[$one_database])) {
if (isset($this->_table_cache[$one_database])) {
// the + operator does not do the intended effect
// when the cache for one table already exists
if ($table
&& isset(PMA_Table::$cache[$one_database][$table])
&& isset($this->_table_cache[$one_database][$table])
) {
unset(PMA_Table::$cache[$one_database][$table]);
unset($this->_table_cache[$one_database][$table]);
}
PMA_Table::$cache[$one_database]
= PMA_Table::$cache[$one_database] + $tables[$one_database];
$this->_table_cache[$one_database]
= $this->_table_cache[$one_database] + $tables[$one_database];
} else {
PMA_Table::$cache[$one_database] = $tables[$one_database];
$this->_table_cache[$one_database] = $tables[$one_database];
}
}
}
Expand Down Expand Up @@ -873,7 +930,8 @@ public function getVirtualTables($db)

foreach ($tables_full as $table=>$tmp) {

if (PMA_Table::isView($db, $table)) {
$_table = $this->getTable($db, $table);
if ($_table->isView($db, $table)) {
$views[] = $table;
}

Expand Down
11 changes: 7 additions & 4 deletions libraries/DisplayResults.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ private function _setDisplayParts($displayParts, &$the_total)
|| ($displayParts['sort_lnk'] == '1'))
&& (/*overload*/mb_strlen($db) && !empty($table))
) {
$the_total = PMA_Table::countRecords($db, $table);
$the_total = $GLOBALS['dbi']->getTable($db, $table)->countRecords();
}

// if for COUNT query, number of rows returned more than 1
Expand All @@ -643,9 +643,10 @@ private function _setDisplayParts($displayParts, &$the_total)
// - For a VIEW we (probably) did not count the number of rows
// so don't test this number here, it would remove the possibility
// of sorting VIEW results.
$_table = new PMA_Table($table, $db);
if (isset($unlim_num_rows)
&& ($unlim_num_rows < 2)
&& ! PMA_Table::isView($db, $table)
&& ! $_table->isView()
) {
$displayParts['sort_lnk'] = (string) '0';
}
Expand Down Expand Up @@ -1671,7 +1672,8 @@ private function _getDataForResettingColumnOrder()
}

// generate table create time
if (! PMA_Table::isView($this->__get('db'), $this->__get('table'))) {
$table = new PMA_Table($this->__get('table'), $this->__get('db'));
if (! $table->isView()) {
$data_html .= '<input class="table_create_time" type="hidden" value="'
. PMA_Table::sGetStatusInfo(
$this->__get('db'), $this->__get('table'), 'Create_time'
Expand Down Expand Up @@ -4649,7 +4651,8 @@ private function _setMessageInformation(

}

if (PMA_Table::isView($this->__get('db'), $this->__get('table'))
$table = new PMA_Table($this->__get('table'), $this->__get('db'));
if ($table->isView()
&& ($total == $GLOBALS['cfg']['MaxExactCountViews'])
) {

Expand Down
6 changes: 4 additions & 2 deletions libraries/Menu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ private function _getAllowedTabs($level)
private function _getBreadcrumbs()
{
$retval = '';
$tbl_is_view = PMA_Table::isView($this->_db, $this->_table);
$table = new PMA_Table($this->_table, $this->_db);
$tbl_is_view = $table->isView();
$server_info = ! empty($GLOBALS['cfg']['Server']['verbose'])
? $GLOBALS['cfg']['Server']['verbose']
: $GLOBALS['cfg']['Server']['host'];
Expand Down Expand Up @@ -298,7 +299,8 @@ private function _getBreadcrumbs()
private function _getTableTabs()
{
$db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
$tbl_is_view = PMA_Table::isView($this->_db, $this->_table);
$table = new PMA_Table($this->_table, $this->_db);
$tbl_is_view = $table->isView();
$is_superuser = $GLOBALS['dbi']->isSuperuser();
$isCreateOrGrantUser = $GLOBALS['dbi']->isUserType('grant')
|| $GLOBALS['dbi']->isUserType('create');
Expand Down
Loading

0 comments on commit 6636153

Please sign in to comment.