Fix merge conflicts

This commit is contained in:
Marc Delisle 2013-05-13 15:48:21 -04:00
commit d5add05ba5
5 changed files with 98 additions and 31 deletions

View File

@ -7,6 +7,7 @@ phpMyAdmin - ChangeLog
- bug #3915 Import of CSV file (Replace table data with file) with duplicate
values
- bug #3898 Structure not refreshed after column drop
- bug #3926 View is not updatable
4.0.1.0 (not yet released)
- bug #3879 Import broken for CSV using LOAD DATA

View File

@ -152,7 +152,7 @@ class PMA_DisplayResults
'mime_map' => null,
/** boolean */
'resultSetContainsUniqueKey' => null
'editable' => null
);
/**
@ -249,7 +249,7 @@ class PMA_DisplayResults
* @param type $showtable array table definitions
* @param type $printview string
* @param type $url_query string URL query
* @param type $resultSetContainsUniqueKey boolean
* @param type $editable boolean whether the resutls set is editable
*
* @return void
*
@ -259,7 +259,7 @@ class PMA_DisplayResults
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage, $text_dir,
$is_maint, $is_explain, $is_show, $showtable, $printview, $url_query,
$resultSetContainsUniqueKey
$editable
) {
$this->__set('unlim_num_rows', $unlim_num_rows);
@ -279,7 +279,7 @@ class PMA_DisplayResults
$this->__set('showtable', $showtable);
$this->__set('printview', $printview);
$this->__set('url_query', $url_query);
$this->__set('resultSetContainsUniqueKey', $resultSetContainsUniqueKey);
$this->__set('editable', $editable);
} // end of the 'setProperties()' function
@ -2469,7 +2469,7 @@ class PMA_DisplayResults
// name of the class added to all grid editable elements;
// if we don't have all the columns of a unique key in the result set,
// do not permit grid editing
if ($is_limited_display || ! $this->__get('resultSetContainsUniqueKey')) {
if ($is_limited_display || ! $this->__get('editable')) {
$grid_edit_class = '';
} else {
switch ($GLOBALS['cfg']['GridEditing']) {

View File

@ -208,6 +208,73 @@ class PMA_Table
return $result ? true : false;
}
/**
* Returns whether the table is actually an updatable view
*
* @param string $db database
* @param string $table table
*
* @return boolean whether the given is an updatable view
*/
static public function isUpdatableView($db = null, $table = null)
{
if (empty($db) || empty($table)) {
return false;
}
$result = PMA_DBI_fetch_result(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($table) . "'
AND IS_UPDATABLE = 'YES'"
);
return $result ? true : false;
}
/**
* Returns the analysis of 'SHOW CREATE TABLE' query for the table.
* In case of a view, the values are taken from the information_schema.
*
* @param string $db database
* @param string $table table
*
* @return array analysis of 'SHOW CREATE TABLE' query for the table
*/
static public function analyzeStructure($db = null, $table = null)
{
if (empty($db) || empty($table)) {
return false;
}
$analyzed_sql = array();
if (self::isView($db, $table)) {
// For a view, 'SHOW CREATE TABLE' returns the definition,
// but the structure of the view. So, we try to mock
// the result of analyzing 'SHOW CREATE TABLE' query.
$analyzed_sql[0] = array();
$analyzed_sql[0]['create_table_fields'] = array();
$results = PMA_DBI_fetch_result(
"SELECT COLUMN_NAME, DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($table) . "'"
);
foreach ($results as $result) {
$analyzed_sql[0]['create_table_fields'][$result['COLUMN_NAME']]
= array('type' => strtoupper($result['DATA_TYPE']));
}
} else {
$show_create_table = PMA_DBI_fetch_value(
'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table),
0,
1
);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
}
}
/**
* sets given $value for given $param
*

43
sql.php
View File

@ -753,6 +753,7 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
// Counts the total number of rows for the same 'SELECT' query without the
// 'LIMIT' clause that may have been programatically added
$justBrowsing = false;
if (empty($sql_limit_to_append)) {
$unlim_num_rows = $num_rows;
// if we did not append a limit, set this to get a correct
@ -778,6 +779,7 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) {
&& ! isset($find_real_end)
) {
// "j u s t b r o w s i n g"
$justBrowsing = true;
$unlim_num_rows = PMA_Table::countRecords($db, $table);
} else { // n o t " j u s t b r o w s i n g "
@ -1233,7 +1235,13 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
// hide edit and delete links:
// - for information_schema
// - if the result set does not contain all the columns of a unique key
if (PMA_is_system_schema($db) || ! $resultSetContainsUniqueKey) {
// and we are not just browing all the columns of an updatable view
$updatableView
= $justBrowsing
&& trim($analyzed_sql[0]['select_expr_clause']) == '*'
&& PMA_Table::isUpdatableView($db, $table);
$editable = $resultSetContainsUniqueKey || $updatableView;
if (PMA_is_system_schema($db) || ! $editable) {
$disp_mode = 'nnnn110111';
$msg = PMA_message::notice(
__(
@ -1262,7 +1270,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
echo getTableHtmlForMultipleQueries(
$displayResultsObject, $db, $sql_data, $goto,
$pmaThemeImage, $text_dir, $printview, $url_query,
$disp_mode, $sql_limit_to_append, $resultSetContainsUniqueKey
$disp_mode, $sql_limit_to_append, $editable
);
} else {
$_SESSION['is_multi_query'] = false;
@ -1270,7 +1278,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) {
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
$printview, $url_query, $resultSetContainsUniqueKey
$printview, $url_query, $editable
);
echo $displayResultsObject->getTable($result, $disp_mode, $analyzed_sql);
@ -1462,27 +1470,24 @@ function PMA_getTableNameBySQL($sql, $tables)
* Generate table html when SQL statement have multiple queries
* which return displayable results
*
* @param PMA_DisplayResults $displayResultsObject object
* @param string $db database name
* @param array $sql_data information about
* SQL statement
* @param string $goto URL to go back in case
* of errors
* @param string $pmaThemeImage path for theme images
* directory
* @param string $text_dir text direction
* @param string $printview whether printview is enabled
* @param string $url_query URL query
* @param array $disp_mode the display mode
* @param string $sql_limit_to_append limit clause
* @param bool $resultSetContainsUniqueKey result contains a unique key
* @param PMA_DisplayResults $displayResultsObject object
* @param string $db database name
* @param array $sql_data information about SQL statement
* @param string $goto URL to go back in case of errors
* @param string $pmaThemeImage path for theme images directory
* @param string $text_dir text direction
* @param string $printview whether printview is enabled
* @param string $url_query URL query
* @param array $disp_mode the display mode
* @param string $sql_limit_to_append limit clause
* @param bool $editable whether result set is editable
*
* @return string $table_html html content
*/
function getTableHtmlForMultipleQueries(
$displayResultsObject, $db, $sql_data, $goto, $pmaThemeImage,
$text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append,
$resultSetContainsUniqueKey
$editable
) {
$table_html = '';
@ -1592,7 +1597,7 @@ function getTableHtmlForMultipleQueries(
$unlim_num_rows, $fields_meta, $is_count, $is_export, $is_func,
$is_analyse, $num_rows, $fields_cnt, $querytime, $pmaThemeImage,
$text_dir, $is_maint, $is_explain, $is_show, $showtable,
$printview, $url_query, $resultSetContainsUniqueKey
$printview, $url_query, $editable
);
}

View File

@ -131,14 +131,8 @@ if (! empty($disp_message)) {
/**
* Get the analysis of SHOW CREATE TABLE for this table
* @todo should be handled by class Table
*/
$show_create_table = PMA_DBI_fetch_value(
'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table),
0, 1
);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
unset($show_create_table);
$analyzed_sql = PMA_Table::analyzeStructure($db, $table);
/**
* Get the list of the fields of the current table