From 218092f92e7ca26574d386641e92de6faada3b4e Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Mon, 27 May 2013 13:51:13 +0530 Subject: [PATCH] Reverting "Move drizzle related code to PMA_DBI_Drizzle class" part of 17b3df142 --- libraries/DatabaseInterface.class.php | 53 +++++++++++++++- libraries/dbi/DBIAbstractExtension.class.php | 41 ------------ libraries/dbi/DBIDrizzle.class.php | 66 +------------------- libraries/dbi/DBIDummy.class.php | 4 +- libraries/dbi/DBIExtension.int.php | 15 ----- libraries/dbi/DBIMysql.class.php | 4 +- libraries/dbi/DBIMysqli.class.php | 4 +- 7 files changed, 60 insertions(+), 127 deletions(-) delete mode 100644 libraries/dbi/DBIAbstractExtension.class.php diff --git a/libraries/DatabaseInterface.class.php b/libraries/DatabaseInterface.class.php index b00dc77769..8c21784703 100644 --- a/libraries/DatabaseInterface.class.php +++ b/libraries/DatabaseInterface.class.php @@ -1204,7 +1204,58 @@ class PMA_DatabaseInterface */ public function getColumnsSql($database, $table, $column = null, $full = false) { - return $this->_extension->getColumnsSql($database, $table, $column, $full); + if (PMA_DRIZZLE) { + // `Key` column: + // * used in primary key => PRI + // * unique one-column => UNI + // * indexed, one-column or first in multi-column => MUL + // Promotion of UNI to PRI in case no promary index exists + // is done after query is executed + $sql = "SELECT + column_name AS `Field`, + (CASE + WHEN character_maximum_length > 0 + THEN concat(lower(data_type), '(', character_maximum_length, ')') + WHEN numeric_precision > 0 OR numeric_scale > 0 + THEN concat(lower(data_type), '(', numeric_precision, + ',', numeric_scale, ')') + WHEN enum_values IS NOT NULL + THEN concat(lower(data_type), '(', enum_values, ')') + ELSE lower(data_type) END) + AS `Type`, + " . ($full ? " + collation_name AS `Collation`," : '') . " + (CASE is_nullable + WHEN 1 THEN 'YES' + ELSE 'NO' END) AS `Null`, + (CASE + WHEN is_used_in_primary THEN 'PRI' + WHEN is_unique AND NOT is_multi THEN 'UNI' + WHEN is_indexed + AND (NOT is_multi OR is_first_in_multi) THEN 'MUL' + ELSE '' END) AS `Key`, + column_default AS `Default`, + (CASE + WHEN is_auto_increment THEN 'auto_increment' + WHEN column_default_update <> '' + THEN 'on update ' || column_default_update + ELSE '' END) AS `Extra` + " . ($full ? " , + NULL AS `Privileges`, + column_comment AS `Comment`" : '') . " + FROM data_dictionary.columns + WHERE table_schema = '" . PMA_Util::sqlAddSlashes($database) . "' + AND table_name = '" . PMA_Util::sqlAddSlashes($table) . "' + " . (($column != null) ? " + AND column_name = '" . PMA_Util::sqlAddSlashes($column) . "'" : ''); + // ORDER BY ordinal_position + } else { + $sql = 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM ' + . PMA_Util::backquote($database) . '.' . PMA_Util::backquote($table) + . (($column != null) ? "LIKE '" + . PMA_Util::sqlAddSlashes($column, true) . "'" : ''); + } + return $sql; } /** diff --git a/libraries/dbi/DBIAbstractExtension.class.php b/libraries/dbi/DBIAbstractExtension.class.php deleted file mode 100644 index e03971a10c..0000000000 --- a/libraries/dbi/DBIAbstractExtension.class.php +++ /dev/null @@ -1,41 +0,0 @@ -getColumns() - * to get correct values. - * - * @param string $database name of database - * @param string $table name of table to retrieve columns from - * @param string $column name of column, null to show all columns - * @param boolean $full whether to return full info or only column names - * - * @return string - */ - public function getColumnsSql($database, $table, $column = null, $full = false) - { - return 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM ' - . PMA_Util::backquote($database) . '.' . PMA_Util::backquote($table) - . (($column != null) ? "LIKE '" - . PMA_Util::sqlAddSlashes($column, true) . "'" : ''); - } -} -?> \ No newline at end of file diff --git a/libraries/dbi/DBIDrizzle.class.php b/libraries/dbi/DBIDrizzle.class.php index b786cc1139..e56f92247d 100644 --- a/libraries/dbi/DBIDrizzle.class.php +++ b/libraries/dbi/DBIDrizzle.class.php @@ -20,7 +20,7 @@ if (! defined('PHPMYADMIN')) { require_once './libraries/logging.lib.php'; require_once './libraries/dbi/drizzle-wrappers.lib.php'; -require_once './libraries/dbi/DBIAbstractExtension.class.php'; +require_once './libraries/dbi/DBIExtension.int.php'; /** * MySQL client API @@ -35,7 +35,7 @@ if (! defined('PMA_MYSQL_CLIENT_API')) { * @package PhpMyAdmin-DBI * @subpackage Drizzle */ -class PMA_DBI_Drizzle extends PMA_DBI_AbstractExtension +class PMA_DBI_Drizzle implements PMA_DBI_Extension { /** * Helper function for connecting to the database server @@ -692,67 +692,5 @@ class PMA_DBI_Drizzle extends PMA_DBI_AbstractExtension { return false; } - - /** - * Returns SQL query for fetching columns for a table - * - * The 'Key' column is not calculated properly, use $GLOBALS['dbi']->getColumns() - * to get correct values. - * - * @param string $database name of database - * @param string $table name of table to retrieve columns from - * @param string $column name of column, null to show all columns - * @param boolean $full whether to return full info or only column names - * - * @return string - */ - public function getColumnsSql($database, $table, $column = null, $full = false) - { - // `Key` column: - // * used in primary key => PRI - // * unique one-column => UNI - // * indexed, one-column or first in multi-column => MUL - // Promotion of UNI to PRI in case no promary index exists - // is done after query is executed - $sql = "SELECT - column_name AS `Field`, - (CASE - WHEN character_maximum_length > 0 - THEN concat(lower(data_type), '(', character_maximum_length, ')') - WHEN numeric_precision > 0 OR numeric_scale > 0 - THEN concat(lower(data_type), '(', numeric_precision, - ',', numeric_scale, ')') - WHEN enum_values IS NOT NULL - THEN concat(lower(data_type), '(', enum_values, ')') - ELSE lower(data_type) END) - AS `Type`, - " . ($full ? " - collation_name AS `Collation`," : '') . " - (CASE is_nullable - WHEN 1 THEN 'YES' - ELSE 'NO' END) AS `Null`, - (CASE - WHEN is_used_in_primary THEN 'PRI' - WHEN is_unique AND NOT is_multi THEN 'UNI' - WHEN is_indexed - AND (NOT is_multi OR is_first_in_multi) THEN 'MUL' - ELSE '' END) AS `Key`, - column_default AS `Default`, - (CASE - WHEN is_auto_increment THEN 'auto_increment' - WHEN column_default_update <> '' - THEN 'on update ' || column_default_update - ELSE '' END) AS `Extra` - " . ($full ? " , - NULL AS `Privileges`, - column_comment AS `Comment`" : '') . " - FROM data_dictionary.columns - WHERE table_schema = '" . PMA_Util::sqlAddSlashes($database) . "' - AND table_name = '" . PMA_Util::sqlAddSlashes($table) . "' - " . (($column != null) ? " - AND column_name = '" . PMA_Util::sqlAddSlashes($column) . "'" : ''); - // ORDER BY ordinal_position - return $sql; - } } ?> \ No newline at end of file diff --git a/libraries/dbi/DBIDummy.class.php b/libraries/dbi/DBIDummy.class.php index dc484169e3..0a7d4a5a45 100644 --- a/libraries/dbi/DBIDummy.class.php +++ b/libraries/dbi/DBIDummy.class.php @@ -14,7 +14,7 @@ if (! defined('PHPMYADMIN')) { exit; } -require_once './libraries/dbi/DBIAbstractExtension.class.php'; +require_once './libraries/dbi/DBIExtension.int.php'; /** * Array of queries this "driver" supports @@ -280,7 +280,7 @@ if (! defined('PMA_DRIZZLE')) { * @package PhpMyAdmin-DBI * @subpackage Dummy */ -class PMA_DBI_Dummy extends PMA_DBI_AbstractExtension +class PMA_DBI_Dummy implements PMA_DBI_Extension { /** * connects to the database server diff --git a/libraries/dbi/DBIExtension.int.php b/libraries/dbi/DBIExtension.int.php index bb4b2e4067..9cc743300b 100644 --- a/libraries/dbi/DBIExtension.int.php +++ b/libraries/dbi/DBIExtension.int.php @@ -244,20 +244,5 @@ interface PMA_DBI_Extension * @return string field flags */ public function fieldFlags($result, $i); - - /** - * Returns SQL query for fetching columns for a table - * - * The 'Key' column is not calculated properly, use $GLOBALS['dbi']->getColumns() - * to get correct values. - * - * @param string $database name of database - * @param string $table name of table to retrieve columns from - * @param string $column name of column, null to show all columns - * @param boolean $full whether to return full info or only column names - * - * @return string - */ - public function getColumnsSql($database, $table, $column = null, $full = false); } ?> \ No newline at end of file diff --git a/libraries/dbi/DBIMysql.class.php b/libraries/dbi/DBIMysql.class.php index 19e06d7ca0..41f3dcd98a 100644 --- a/libraries/dbi/DBIMysql.class.php +++ b/libraries/dbi/DBIMysql.class.php @@ -11,7 +11,7 @@ if (! defined('PHPMYADMIN')) { } require_once './libraries/logging.lib.php'; -require_once './libraries/dbi/DBIAbstractExtension.class.php'; +require_once './libraries/dbi/DBIExtension.int.php'; /** * MySQL client API @@ -34,7 +34,7 @@ if (! defined('PMA_MYSQL_CLIENT_API')) { * @package PhpMyAdmin-DBI * @subpackage MySQL */ -class PMA_DBI_Mysql extends PMA_DBI_AbstractExtension +class PMA_DBI_Mysql implements PMA_DBI_Extension { /** * Helper function for connecting to the database server diff --git a/libraries/dbi/DBIMysqli.class.php b/libraries/dbi/DBIMysqli.class.php index ebbeebde1a..0f1c126cf7 100644 --- a/libraries/dbi/DBIMysqli.class.php +++ b/libraries/dbi/DBIMysqli.class.php @@ -11,7 +11,7 @@ if (! defined('PHPMYADMIN')) { } require_once './libraries/logging.lib.php'; -require_once './libraries/dbi/DBIAbstractExtension.class.php'; +require_once './libraries/dbi/DBIExtension.int.php'; /** * MySQL client API @@ -63,7 +63,7 @@ if (! defined('MYSQLI_TYPE_VARCHAR')) { * @package PhpMyAdmin-DBI * @subpackage MySQLi */ -class PMA_DBI_Mysqli extends PMA_DBI_AbstractExtension +class PMA_DBI_Mysqli implements PMA_DBI_Extension { /** * Helper function for connecting to the database server