Skip to content

Commit

Permalink
Merge branch 'QA_4_0'
Browse files Browse the repository at this point in the history
Conflicts:
	libraries/DisplayResults.class.php
	libraries/information_schema_relations.lib.php
  • Loading branch information
madhuracj committed Sep 14, 2013
2 parents 74aed05 + 3c8e4fb commit a34a46c
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 19 deletions.
81 changes: 62 additions & 19 deletions libraries/DisplayResults.class.php
Expand Up @@ -157,12 +157,12 @@ class PMA_DisplayResults
);

/**
* This global variable represent the columns which needs to be syntax
* highlighted in each database tables
* This variable contains the column transformation information
* for some of the system databases.
* One element of this array represent all relavant columns in all tables in
* one specific database
*/
public $syntax_highlighting_column_info;
public $transformation_info;


/**
Expand Down Expand Up @@ -208,25 +208,68 @@ public function __set($property, $value)
*/
public function __construct($db, $table, $goto, $sql_query)
{
$this->syntax_highlighting_column_info = array(
'information_schema' => array(
'processlist' => array(
'info' => array(
'libraries/plugins/transformations/'
. 'Text_Plain_Formatted.class.php',
'Text_Plain_Formatted',
'Text_Plain'
)
)
)
);
$this->_setDefaultTransformations();

$this->__set('db', $db);
$this->__set('table', $table);
$this->__set('goto', $goto);
$this->__set('sql_query', $sql_query);
}

/**
* Sets default transformations for some columns
*
* @return void
*/
private function _setDefaultTransformations()
{
$sql_highlighting_data = array(
'libraries/plugins/transformations/Text_Plain_Formatted.class.php',
'Text_Plain_Formatted',
'Text_Plain'
);
$this->transformation_info = array(
'information_schema' => array(
'events' => array(
'event_definition' => $sql_highlighting_data
),
'processlist' => array(
'info' => $sql_highlighting_data
),
'routines' => array(
'routine_definition' => $sql_highlighting_data
),
'triggers' => array(
'action_statement' => $sql_highlighting_data
),
'views' => array(
'view_definition' => $sql_highlighting_data
)
)
);

$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['db']) {
$this->transformation_info[$cfgRelation['db']] = array();
$relDb = &$this->transformation_info[$cfgRelation['db']];
if ($cfgRelation['history']) {
$relDb[$cfgRelation['history']] = array(
'sqlquery' => $sql_highlighting_data
);
}
if ($cfgRelation['bookmark']) {
$relDb[$cfgRelation['bookmark']] = array(
'query' => $sql_highlighting_data
);
}
if ($cfgRelation['tracking']) {
$relDb[$cfgRelation['tracking']] = array(
'schema_sql' => $sql_highlighting_data,
'data_sql' => $sql_highlighting_data
);
}
}
}

/**
* Set properties which were not initialized at the constructor
Expand Down Expand Up @@ -2791,8 +2834,8 @@ private function _getRowValues(
) {

$row[$i] = PMA_Util::formatSql($row[$i]);
include_once $this->syntax_highlighting_column_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][0];
$transformation_plugin = new $this->syntax_highlighting_column_info
include_once $this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][0];
$transformation_plugin = new $this->transformation_info
[strtolower($this->__get('db'))]
[strtolower($this->__get('table'))]
[strtolower($meta->name)][1](null);
Expand All @@ -2805,7 +2848,7 @@ private function _getRowValues(

$meta->mimetype = str_replace(
'_', '/',
$this->syntax_highlighting_column_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][2]
$this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($meta->name)][2]
);

}
Expand Down Expand Up @@ -3032,7 +3075,7 @@ private function _gatherLinksForLaterOutputs(
*/
private function _isNeedToSyntaxHighlight($field)
{
if (! empty($this->syntax_highlighting_column_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($field)])) {
if (! empty($this->transformation_info[strtolower($this->__get('db'))][strtolower($this->__get('table'))][strtolower($field)])) {
return true;
}
return false;
Expand Down
188 changes: 188 additions & 0 deletions libraries/information_schema_relations.lib.php
Expand Up @@ -18,6 +18,11 @@
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
)
),
'COLLATIONS' => array(
Expand Down Expand Up @@ -63,6 +68,50 @@
'foreign_field' => 'SCHEMA_NAME'
)
),
'EVENTS' => array(
'EVENT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_CLIENT' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_CONNECTION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'DATABASE_COLLATION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'FILES' => array(
'TABLESPACE_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'TABLESPACES',
'foreign_field' => 'TABLESPACE_NAME'
),
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'COLLATION_CONNECTION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'ENGINE' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'ENGINES',
'foreign_field' => 'ENGINE'
)
),
'KEY_COLUMN_USAGE' => array(
'CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
Expand All @@ -73,20 +122,103 @@
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'REFERENCED_TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'PARAMETERS' => array(
'SPECIFIC_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'PARTITIONS' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'TABLESPACE_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'TABLESPACES',
'foreign_field' => 'TABLESPACE_NAME'
)
),
'PROCESSLIST' => array(
'DB' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'REFERENTIAL_CONSTRAINTS' => array(
'CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'UNIQUE_CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'ROUTINES' => array(
'ROUTINE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'CHARACTER_SET_CLIENT' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_CONNECTION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'DATABASE_COLLATION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'SCHEMATA' => array(
'DEFAULT_CHARACTER_SET_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'DEFAULT_COLLATION_NAME' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'SCHEMA_PRIVILEGES' => array(
Expand All @@ -96,6 +228,18 @@
'foreign_field' => 'SCHEMA_NAME'
)
),
'STATISTICS' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'INDEX_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
)
),
'TABLES' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
Expand All @@ -113,6 +257,13 @@
'foreign_field' => 'ENGINE'
),
),
'TABLESAPCES' => array(
'ENGINE' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'ENGINES',
'foreign_field' => 'ENGINE'
)
),
'TABLE_CONSTRAINTS' => array(
'CONSTRAINT_SCHEMA' => array(
'foreign_db' => 'information_schema',
Expand All @@ -132,11 +283,48 @@
'foreign_field' => 'SCHEMA_NAME'
)
),
'TRIGGERS' => array(
'TRIGGER_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'EVENT_OBJECT_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_CLIENT' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_CONNECTION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
),
'DATABASE_COLLATION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
),
'VIEWS' => array(
'TABLE_SCHEMA' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'SCHEMATA',
'foreign_field' => 'SCHEMA_NAME'
),
'CHARACTER_SET_CLIENT' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'CHARACTER_SETS',
'foreign_field' => 'CHARACTER_SET_NAME'
),
'COLLATION_CONNECTION' => array(
'foreign_db' => 'information_schema',
'foreign_table' => 'COLLATIONS',
'foreign_field' => 'COLLATION_NAME'
)
)
);
Expand Down

0 comments on commit a34a46c

Please sign in to comment.