bug #1747215 Export emits blanks at line ends

This commit is contained in:
Marc Delisle
2007-07-11 13:53:58 +00:00
parent 9949e5c0b7
commit f772df4b99
2 changed files with 83 additions and 75 deletions

View File

@@ -77,6 +77,7 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
. [transformations]: remove "auto-detect" MIME-type that was never implemented
+ [display] patch #1749705, Allow multibyte characters in number formatting,
thanks to garas
- bug #1747215 Export emits blanks at line ends
2.10.3.0 (not yet released)

View File

@@ -121,11 +121,6 @@ if (isset($plugin_list)) {
}
} else {
/**
* Marker for comments, -- is needed for ANSI SQL.
*/
$GLOBALS['comment_marker'] = '-- ';
/**
* Avoids undefined variables, use NULL so isset() returns false
*/
@@ -138,11 +133,12 @@ if (! isset($sql_backquotes)) {
*
* @param string Text of comment
*
* @return bool Whether it suceeded
* @return string The formatted comment
*/
function PMA_exportComment($text)
function PMA_exportComment($text = '')
{
return PMA_exportOutputHandler($GLOBALS['comment_marker'] . $text . $GLOBALS['crlf']);
// see http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html
return '--' . (empty($text) ? '' : ' ') . $text . $GLOBALS['crlf'];
}
/**
@@ -196,25 +192,28 @@ function PMA_exportHeader()
if (PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] != 'NONE') {
PMA_DBI_try_query('SET SQL_MODE="' . $GLOBALS['sql_compatibility'] . '"');
}
$head = $GLOBALS['comment_marker'] . 'phpMyAdmin SQL Dump' . $crlf
. $GLOBALS['comment_marker'] . 'version ' . PMA_VERSION . $crlf
. $GLOBALS['comment_marker'] . 'http://www.phpmyadmin.net' . $crlf
. $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
$head = PMA_exportComment('phpMyAdmin SQL Dump')
. PMA_exportComment('version ' . PMA_VERSION)
. PMA_exportComment('http://www.phpmyadmin.net')
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strHost'] . ': ' . $cfg['Server']['host']);
if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3) . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf;
. PMA_exportComment($GLOBALS['strGenTime'] . ': ' . PMA_localisedDate())
. PMA_exportComment($GLOBALS['strServerVersion'] . ': ' . substr(PMA_MYSQL_INT_VERSION, 0, 1) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 1, 2) . '.' . (int) substr(PMA_MYSQL_INT_VERSION, 3))
. PMA_exportComment($GLOBALS['strPHPVersion'] . ': ' . phpversion());
if (isset($GLOBALS['sql_header_comment']) && !empty($GLOBALS['sql_header_comment'])) {
// '\n' is not a newline (like "\n" would be), it's the characters
// backslash and n, as explained on the export interface
$lines = explode('\n', $GLOBALS['sql_header_comment']);
$head .= $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . implode($crlf . $GLOBALS['comment_marker'], $lines) . $crlf
. $GLOBALS['comment_marker'] . $crlf;
$head .= PMA_exportComment();
foreach($lines as $one_line) {
$head .= PMA_exportComment($one_line);
}
$head .= PMA_exportComment();
}
if (isset($GLOBALS['sql_disable_fk'])) {
@@ -292,10 +291,9 @@ function PMA_exportDBCreate($db)
*/
function PMA_exportDBHeader($db)
{
global $crlf;
$head = $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf
. $GLOBALS['comment_marker'] . $crlf;
$head = PMA_exportComment()
. PMA_exportComment($GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''))
. PMA_exportComment();
return PMA_exportOutputHandler($head);
}
@@ -310,7 +308,7 @@ function PMA_exportDBHeader($db)
*/
function PMA_exportDBFooter($db)
{
global $crlf, $comment_marker;
global $crlf;
$result = TRUE;
if (isset($GLOBALS['sql_constraints'])) {
@@ -325,26 +323,26 @@ function PMA_exportDBFooter($db)
if ($procedure_names) {
$delimiter = '$$';
$procs_funcs = $crlf
. $comment_marker . $crlf
. $comment_marker . $GLOBALS['strProcedures'] . $crlf
. $comment_marker . $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strProcedures'])
. PMA_exportComment()
. 'DELIMITER ' . $delimiter . $crlf
. $comment_marker . $crlf;
. PMA_exportComment();
foreach($procedure_names as $procedure_name) {
$procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf;
}
$procs_funcs .= $comment_marker . $crlf
$procs_funcs .= PMA_exportComment()
. 'DELIMITER ;' . $crlf
. $comment_marker . $crlf;
. PMA_exportComment();
}
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($function_names) {
$procs_funcs .= $comment_marker . $GLOBALS['strFunctions'] . $crlf
. $comment_marker . $crlf . $crlf;
$procs_funcs .= PMA_exportComment($GLOBALS['strFunctions'])
. PMA_exportComment() . $crlf;
foreach($function_names as $function_name) {
$procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name) . $crlf . $crlf;
@@ -426,18 +424,18 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
}
if ($show_dates && isset($tmpres['Create_time']) && !empty($tmpres['Create_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
$schema_create .= PMA_exportComment($GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time'])));
$new_crlf = PMA_exportComment() . $crlf;
}
if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
$schema_create .= PMA_exportComment($GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time'])));
$new_crlf = PMA_exportComment() . $crlf;
}
if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) {
$schema_create .= $GLOBALS['comment_marker'] . $GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time'])) . $crlf;
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf;
$schema_create .= PMA_exportComment($GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time'])));
$new_crlf = PMA_exportComment() . $crlf;
}
}
PMA_DBI_free_result($result);
@@ -512,17 +510,19 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
if (isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints = '';
} else {
$sql_constraints = $crlf . $GLOBALS['comment_marker'] .
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForDumped'] .
$crlf . $GLOBALS['comment_marker'] . $crlf;
$sql_constraints = $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strConstraintsForDumped'])
. PMA_exportComment();
}
}
// comments for current table
if (!isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints .= $crlf . $GLOBALS['comment_marker'] .
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table) .
$crlf . $GLOBALS['comment_marker'] . $crlf;
$sql_constraints .= $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table))
. PMA_exportComment();
}
// let's do the work
@@ -621,35 +621,38 @@ function PMA_getTableComments($db, $table, $crlf, $do_relation = false, $do_comm
}
if (isset($comments_map) && count($comments_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
$schema_create .= $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
foreach ($comments_map AS $comment_field => $comment) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $sql_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $sql_backquotes) . $crlf;
$schema_create .= PMA_exportComment(' ' . PMA_backquote($comment_field, $sql_backquotes))
. PMA_exportComment(' ' . PMA_backquote($comment, $sql_backquotes));
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
$schema_create .= PMA_exportComment();
}
if (isset($mime_map) && count($mime_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
$schema_create .= $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
@reset($mime_map);
foreach ($mime_map AS $mime_field => $mime) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $sql_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $sql_backquotes) . $crlf;
$schema_create .= PMA_exportComment(' ' . PMA_backquote($mime_field, $sql_backquotes))
. PMA_exportComment(' ' . PMA_backquote($mime['mimetype'], $sql_backquotes));
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
$schema_create .= PMA_exportComment();
}
if ($have_rel) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf;
$schema_create .= $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
foreach ($res_rel AS $rel_field => $rel) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $sql_backquotes) . $crlf
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $sql_backquotes)
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_backquotes) . $crlf;
$schema_create .= PMA_exportComment(' ' . PMA_backquote($rel_field, $sql_backquotes))
. PMA_exportComment(' ' . PMA_backquote($rel['foreign_table'], $sql_backquotes)
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_backquotes));
}
$schema_create .= $GLOBALS['comment_marker'] . $crlf;
$schema_create .= PMA_exportComment();
}
return $schema_create;
@@ -679,18 +682,21 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
? PMA_backquote($table)
: '\'' . $table . '\'';
$dump = $crlf
. $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf
. $crlf . $GLOBALS['comment_marker'] . $crlf;
. PMA_exportComment(str_repeat('-', 55))
. $crlf
. PMA_exportComment();
switch($export_mode) {
case 'create_table':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf;
$dump .= PMA_exportComment($GLOBALS['strTableStructure'] . ' ' . $formatted_table_name)
. PMA_exportComment();
$dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf;
$triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) {
$dump .= $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strTriggers'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf;
$dump .= $crlf
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strTriggers'] . ' ' . $formatted_table_name)
. PMA_exportComment();
$delimiter = '//';
foreach ($triggers as $trigger) {
$dump .= $trigger['drop'] . ';' . $crlf;
@@ -701,8 +707,8 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
}
break;
case 'create_view':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStructureForView'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf;
$dump .= PMA_exportComment($GLOBALS['strStructureForView'] . ' ' . $formatted_table_name)
. PMA_exportComment();
// delete the stand-in table previously created (if any)
if ($export_type != 'table') {
$dump .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table) . ';' . $crlf;
@@ -710,8 +716,8 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
$dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf;
break;
case 'stand_in':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf;
$dump .= PMA_exportComment($GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name)
. PMA_exportComment();
// export a stand-in definition to resolve view dependencies
$dump .= PMA_getTableDefStandIn($db, $table, $crlf);
} // end switch
@@ -757,9 +763,10 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
? PMA_backquote($table)
: '\'' . $table . '\'';
$head = $crlf
. $GLOBALS['comment_marker'] . $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf
. $GLOBALS['comment_marker'] . $crlf .$crlf;
. PMA_exportComment()
. PMA_exportComment($GLOBALS['strDumpingData'] . ' ' . $formatted_table_name)
. PMA_exportComment()
. $crlf;
if (! PMA_exportOutputHandler($head)) {
return FALSE;