Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
atul516 committed Jul 24, 2012
2 parents 9649f51 + f14f035 commit 81456ec
Show file tree
Hide file tree
Showing 52 changed files with 2,945 additions and 920 deletions.
17 changes: 9 additions & 8 deletions export.php
Expand Up @@ -42,8 +42,6 @@
// Check export type
if (! isset($export_plugin)) {
PMA_fatalError(__('Bad type!'));
} else {
$export_plugin_properties = $export_plugin->getProperties();
}

/**
Expand Down Expand Up @@ -92,9 +90,10 @@
}

// Does export require to be into file?
if (isset($export_plugin_properties['force_file']) && ! $asfile) {

$message = PMA_Message::error(__('Selected export type has to be saved in file!'));
if ($export_plugin->getProperties()->getForceFile() != null && ! $asfile) {
$message = PMA_Message::error(
__('Selected export type has to be saved in file!')
);
if ($export_type == 'server') {
$active_page = 'server_export.php';
include 'server_export.php';
Expand Down Expand Up @@ -326,13 +325,15 @@ function PMA_exportOutputHandler($line)

// Grab basic dump extension and mime type
// Check if the user already added extension; get the substring where the extension would be if it was included
$extension_start_pos = strlen($filename) - strlen($export_plugin_properties['extension']) - 1;
$extension_start_pos = strlen($filename) - strlen(
$export_plugin->getProperties()->getExtension()
) - 1;
$user_extension = substr($filename, $extension_start_pos, strlen($filename));
$required_extension = "." . $export_plugin_properties['extension'];
$required_extension = "." . $export_plugin->getProperties()->getExtension();
if (strtolower($user_extension) != $required_extension) {
$filename .= $required_extension;
}
$mime_type = $export_plugin_properties['mime_type'];
$mime_type = $export_plugin->getProperties()->getMimeType();

// If dump is going to be compressed, set correct mime_type and add
// compression to extension
Expand Down
6 changes: 5 additions & 1 deletion import.php
Expand Up @@ -430,6 +430,10 @@
unset($skip);
}

// This array contain the data like numberof valid sql queries in the statement
// and complete valid sql statement (which affected for rows)
$sql_data = array('valid_sql' => array(), 'valid_queries' => 0);

if (! $error) {
// Check for file existance
require_once("libraries/plugin_interface.lib.php");
Expand All @@ -445,7 +449,7 @@
);
} else {
// Do the real import
$import_plugin->doImport();
$import_plugin->doImport($sql_data);
}
}

Expand Down
3 changes: 1 addition & 2 deletions libraries/CommonFunctions.class.php
Expand Up @@ -3541,8 +3541,7 @@ public function getSelectUploadFileBlock($import_list, $uploaddir)
if (! empty($extensions)) {
$extensions .= '|';
}
$properties = $import_plugin->getProperties();
$extensions .= $properties['extension'];
$extensions .= $import_plugin->getProperties()->getExtension();
}

$matcher = '@\.(' . $extensions . ')(\.('
Expand Down
25 changes: 14 additions & 11 deletions libraries/DisplayResults.class.php
Expand Up @@ -940,7 +940,7 @@ private function _getAdditionalFieldsForTableNavigation(
private function _getTableHeaders(
&$is_display, $analyzed_sql = '',
$sort_expression = '', $sort_expression_nodirection = '',
$sort_direction = ''
$sort_direction = '', $is_limited_display = false
) {

$table_headers_html = '';
Expand Down Expand Up @@ -1002,7 +1002,7 @@ private function _getTableHeaders(
$this->__set('_vertical_display', $vertical_display);

// Display options (if we are not in print view)
if (! (isset($printview) && ($printview == '1'))) {
if (! (isset($printview) && ($printview == '1')) && ! $is_limited_display) {

$table_headers_html .= $this->_getOptionsBlock();

Expand Down Expand Up @@ -2422,8 +2422,9 @@ private function _addClass(
*
* @see getTable()
*/
private function _getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
{
private function _getTableBody(
&$dt_result, &$is_display, $map, $analyzed_sql, $is_limited_display = false
) {

global $row; // mostly because of browser transformations,
// to make the row-data accessible in a plugin
Expand All @@ -2447,8 +2448,9 @@ private function _getTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
$vertical_display['data'] = array();
$vertical_display['row_delete'] = array();
$this->__set('_vertical_display', $vertical_display);

// name of the class added to all grid editable elements
$grid_edit_class = 'grid_edit';
$grid_edit_class = $is_limited_display ? '' : 'grid_edit';

// prepare to get the column order, if available
list($col_order, $col_visib) = $this->_getColumnParams($analyzed_sql);
Expand Down Expand Up @@ -4246,9 +4248,10 @@ public function setConfigParamsForDisplayTable()
*
* @see sql.php file
*/
public function getTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
{

public function getTable(
&$dt_result, &$the_disp_mode, $analyzed_sql, $is_limited_display = false
) {

$table_html = '';
// Following variable are needed for use in isset/empty or
// use with array indexes/safe use in foreach
Expand Down Expand Up @@ -4394,13 +4397,13 @@ public function getTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
// 3. ----- Prepare the results table -----
$table_html .= $this->_getTableHeaders(
$is_display, $analyzed_sql, $sort_expression,
$sort_expression_nodirection, $sort_direction
$sort_expression_nodirection, $sort_direction, $is_limited_display
)
. '<tbody>' . "\n";

$url_query = '';
$table_html .= $this->_getTableBody(
$dt_result, $is_display, $map, $analyzed_sql
$dt_result, $is_display, $map, $analyzed_sql, $is_limited_display
);

// vertical output case
Expand Down Expand Up @@ -4439,7 +4442,7 @@ public function getTable(&$dt_result, &$the_disp_mode, $analyzed_sql)


// 6. ----- Prepare "Query results operations"
if (! isset($printview) || ($printview != '1')) {
if ((! isset($printview) || ($printview != '1')) && ! $is_limited_display) {
$table_html .= $this->_getResultsOperations(
$the_disp_mode, $analyzed_sql
);
Expand Down
23 changes: 23 additions & 0 deletions libraries/database_interface.lib.php
Expand Up @@ -177,6 +177,29 @@ function PMA_DBI_try_query($query, $link = null, $options = 0,
return $r;
}

/**
* Run multi query statement and return results
*
* @param string $multi_query multi query statement to execute
* @param mysqli $link mysqli object
*
* @return mysqli_result collection | boolean(false)
*/
function PMA_DBI_try_multi_query($multi_query = '', $link = null)
{

if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}

return PMA_DBI_real_multi_query($link, $multi_query);

}

/**
* converts charset of a mysql message, usually coming from mysql_error(),
* into PMA charset, usally UTF-8
Expand Down
18 changes: 18 additions & 0 deletions libraries/dbi/mysql.dbi.lib.php
Expand Up @@ -53,6 +53,24 @@ function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persist
return $link;
}

/**
* Run the multi query and output the results
*
* @param mysqli $link mysqli object
* @param string $query multi query statement to execute
*
* @return boolean false always false since mysql extention not support
* for multi query executions
*/
function PMA_DBI_real_multi_query($link, $query)
{
// N.B.: PHP's 'mysql' extension does not support
// multi_queries so this function will always
// return false. Use the 'mysqli' extension, if
// you need support for multi_queries.
return false;
}

/**
* connects to the database server
*
Expand Down
30 changes: 30 additions & 0 deletions libraries/dbi/mysqli.dbi.lib.php
Expand Up @@ -253,6 +253,19 @@ function PMA_DBI_real_query($query, $link, $options)
return mysqli_query($link, $query, $method);
}

/**
* Run the multi query and output the results
*
* @param mysqli $link mysqli object
* @param string $query multi query statement to execute
*
* @return mysqli_result collection | boolean(false)
*/
function PMA_DBI_real_multi_query($link, $query)
{
return mysqli_multi_query($link, $query);
}

/**
* returns array of rows with associative and numeric keys from $result
*
Expand Down Expand Up @@ -354,6 +367,23 @@ function PMA_DBI_next_result($link = null)
return mysqli_next_result($link);
}

/**
* Store the result returned from multi query
*
* @return mixed false when empty results / result set when not empty
*/
function PMA_DBI_store_result()
{
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return false;
}
}
return mysqli_store_result($link);
}

/**
* Returns a string representing the type of connection used
*
Expand Down
23 changes: 22 additions & 1 deletion libraries/import.lib.php
Expand Up @@ -81,7 +81,7 @@ function PMA_detectCompression($filepath)
* @return void
* @access public
*/
function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_data = array())
{
global $import_run_buffer, $go_sql, $complete_query, $display_query,
$sql_query, $my_die, $error, $reload,
Expand All @@ -97,6 +97,14 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
if (! empty($import_run_buffer['sql'])
&& trim($import_run_buffer['sql']) != ''
) {

// USE query changes the database, son need to track
// while running multiple queries
$is_use_query
= (stripos($import_run_buffer['sql'], "use ") !== false)
? true
: false;

$max_sql_len = max($max_sql_len, strlen($import_run_buffer['sql']));
if (! $sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
Expand All @@ -108,7 +116,9 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
$GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.'));
$error = true;
} else {

$executed_queries++;

if ($run_query
&& $GLOBALS['finished']
&& empty($sql)
Expand All @@ -126,6 +136,9 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
$sql_data['valid_queries']++;

// If a 'USE <db>' SQL-clause was found,
// set our current $db to the new one
list($db, $reload) = PMA_lookForUse(
Expand All @@ -134,13 +147,15 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
$reload
);
} elseif ($run_query) {

if ($controluser) {
$result = PMA_queryAsControlUser(
$import_run_buffer['sql']
);
} else {
$result = PMA_DBI_try_query($import_run_buffer['sql']);
}

$msg = '# ';
if ($result === false) { // execution failed
if (! isset($my_die)) {
Expand Down Expand Up @@ -169,6 +184,12 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false)
} else {
$msg .= __('MySQL returned an empty result set (i.e. zero rows).');
}

if (($a_num_rows > 0) || $is_use_query) {
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
$sql_data['valid_queries']++;
}

}
if (! $sql_query_disabled) {
$sql_query .= $msg . "\n";
Expand Down

0 comments on commit 81456ec

Please sign in to comment.