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 . [transformations]: remove "auto-detect" MIME-type that was never implemented
+ [display] patch #1749705, Allow multibyte characters in number formatting, + [display] patch #1749705, Allow multibyte characters in number formatting,
thanks to garas thanks to garas
- bug #1747215 Export emits blanks at line ends
2.10.3.0 (not yet released) 2.10.3.0 (not yet released)

View File

@@ -121,11 +121,6 @@ if (isset($plugin_list)) {
} }
} else { } else {
/**
* Marker for comments, -- is needed for ANSI SQL.
*/
$GLOBALS['comment_marker'] = '-- ';
/** /**
* Avoids undefined variables, use NULL so isset() returns false * Avoids undefined variables, use NULL so isset() returns false
*/ */
@@ -138,11 +133,12 @@ if (! isset($sql_backquotes)) {
* *
* @param string Text of comment * @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') { if (PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] != 'NONE') {
PMA_DBI_try_query('SET SQL_MODE="' . $GLOBALS['sql_compatibility'] . '"'); PMA_DBI_try_query('SET SQL_MODE="' . $GLOBALS['sql_compatibility'] . '"');
} }
$head = PMA_exportComment('phpMyAdmin SQL Dump')
$head = $GLOBALS['comment_marker'] . 'phpMyAdmin SQL Dump' . $crlf . PMA_exportComment('version ' . PMA_VERSION)
. $GLOBALS['comment_marker'] . 'version ' . PMA_VERSION . $crlf . PMA_exportComment('http://www.phpmyadmin.net')
. $GLOBALS['comment_marker'] . 'http://www.phpmyadmin.net' . $crlf . PMA_exportComment()
. $GLOBALS['comment_marker'] . $crlf . PMA_exportComment($GLOBALS['strHost'] . ': ' . $cfg['Server']['host']);
. $GLOBALS['comment_marker'] . $GLOBALS['strHost'] . ': ' . $cfg['Server']['host'];
if (!empty($cfg['Server']['port'])) { if (!empty($cfg['Server']['port'])) {
$head .= ':' . $cfg['Server']['port']; $head .= ':' . $cfg['Server']['port'];
} }
$head .= $crlf $head .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strGenTime'] . ': ' . PMA_localisedDate() . $crlf . PMA_exportComment($GLOBALS['strGenTime'] . ': ' . PMA_localisedDate())
. $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 . 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))
. $GLOBALS['comment_marker'] . $GLOBALS['strPHPVersion'] . ': ' . phpversion() . $crlf; . PMA_exportComment($GLOBALS['strPHPVersion'] . ': ' . phpversion());
if (isset($GLOBALS['sql_header_comment']) && !empty($GLOBALS['sql_header_comment'])) { 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']); $lines = explode('\n', $GLOBALS['sql_header_comment']);
$head .= $GLOBALS['comment_marker'] . $crlf $head .= PMA_exportComment();
. $GLOBALS['comment_marker'] . implode($crlf . $GLOBALS['comment_marker'], $lines) . $crlf foreach($lines as $one_line) {
. $GLOBALS['comment_marker'] . $crlf; $head .= PMA_exportComment($one_line);
}
$head .= PMA_exportComment();
} }
if (isset($GLOBALS['sql_disable_fk'])) { if (isset($GLOBALS['sql_disable_fk'])) {
@@ -292,10 +291,9 @@ function PMA_exportDBCreate($db)
*/ */
function PMA_exportDBHeader($db) function PMA_exportDBHeader($db)
{ {
global $crlf; $head = PMA_exportComment()
$head = $GLOBALS['comment_marker'] . $crlf . PMA_exportComment($GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''))
. $GLOBALS['comment_marker'] . $GLOBALS['strDatabase'] . ': ' . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : '\'' . $db . '\''). $crlf . PMA_exportComment();
. $GLOBALS['comment_marker'] . $crlf;
return PMA_exportOutputHandler($head); return PMA_exportOutputHandler($head);
} }
@@ -310,7 +308,7 @@ function PMA_exportDBHeader($db)
*/ */
function PMA_exportDBFooter($db) function PMA_exportDBFooter($db)
{ {
global $crlf, $comment_marker; global $crlf;
$result = TRUE; $result = TRUE;
if (isset($GLOBALS['sql_constraints'])) { if (isset($GLOBALS['sql_constraints'])) {
@@ -325,26 +323,26 @@ function PMA_exportDBFooter($db)
if ($procedure_names) { if ($procedure_names) {
$delimiter = '$$'; $delimiter = '$$';
$procs_funcs = $crlf $procs_funcs = $crlf
. $comment_marker . $crlf . PMA_exportComment()
. $comment_marker . $GLOBALS['strProcedures'] . $crlf . PMA_exportComment($GLOBALS['strProcedures'])
. $comment_marker . $crlf . PMA_exportComment()
. 'DELIMITER ' . $delimiter . $crlf . 'DELIMITER ' . $delimiter . $crlf
. $comment_marker . $crlf; . PMA_exportComment();
foreach($procedure_names as $procedure_name) { foreach($procedure_names as $procedure_name) {
$procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'PROCEDURE', $procedure_name) . $delimiter . $crlf . $crlf; $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 . 'DELIMITER ;' . $crlf
. $comment_marker . $crlf; . PMA_exportComment();
} }
$function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION'); $function_names = PMA_DBI_get_procedures_or_functions($db, 'FUNCTION');
if ($function_names) { if ($function_names) {
$procs_funcs .= $comment_marker . $GLOBALS['strFunctions'] . $crlf $procs_funcs .= PMA_exportComment($GLOBALS['strFunctions'])
. $comment_marker . $crlf . $crlf; . PMA_exportComment() . $crlf;
foreach($function_names as $function_name) { foreach($function_names as $function_name) {
$procs_funcs .= PMA_DBI_get_procedure_or_function_def($db, 'FUNCTION', $function_name) . $crlf . $crlf; $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'])) { 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; $schema_create .= PMA_exportComment($GLOBALS['strStatCreateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Create_time'])));
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; $new_crlf = PMA_exportComment() . $crlf;
} }
if ($show_dates && isset($tmpres['Update_time']) && !empty($tmpres['Update_time'])) { 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; $schema_create .= PMA_exportComment($GLOBALS['strStatUpdateTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Update_time'])));
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; $new_crlf = PMA_exportComment() . $crlf;
} }
if ($show_dates && isset($tmpres['Check_time']) && !empty($tmpres['Check_time'])) { 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; $schema_create .= PMA_exportComment($GLOBALS['strStatCheckTime'] . ': ' . PMA_localisedDate(strtotime($tmpres['Check_time'])));
$new_crlf = $GLOBALS['comment_marker'] . $crlf . $crlf; $new_crlf = PMA_exportComment() . $crlf;
} }
} }
PMA_DBI_free_result($result); 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'])) { if (isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints = ''; $sql_constraints = '';
} else { } else {
$sql_constraints = $crlf . $GLOBALS['comment_marker'] . $sql_constraints = $crlf
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForDumped'] . . PMA_exportComment()
$crlf . $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment($GLOBALS['strConstraintsForDumped'])
. PMA_exportComment();
} }
} }
// comments for current table // comments for current table
if (!isset($GLOBALS['no_constraints_comments'])) { if (!isset($GLOBALS['no_constraints_comments'])) {
$sql_constraints .= $crlf . $GLOBALS['comment_marker'] . $sql_constraints .= $crlf
$crlf . $GLOBALS['comment_marker'] . $GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table) . . PMA_exportComment()
$crlf . $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment($GLOBALS['strConstraintsForTable'] . ' ' . PMA_backquote($table))
. PMA_exportComment();
} }
// let's do the work // 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) { if (isset($comments_map) && count($comments_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf $schema_create .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf; . PMA_exportComment()
. PMA_exportComment($GLOBALS['strCommentsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
foreach ($comments_map AS $comment_field => $comment) { foreach ($comments_map AS $comment_field => $comment) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment_field, $sql_backquotes) . $crlf $schema_create .= PMA_exportComment(' ' . PMA_backquote($comment_field, $sql_backquotes))
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($comment, $sql_backquotes) . $crlf; . 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) { if (isset($mime_map) && count($mime_map) > 0) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf $schema_create .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf; . PMA_exportComment()
. PMA_exportComment($GLOBALS['strMIMETypesForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
@reset($mime_map); @reset($mime_map);
foreach ($mime_map AS $mime_field => $mime) { foreach ($mime_map AS $mime_field => $mime) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime_field, $sql_backquotes) . $crlf $schema_create .= PMA_exportComment(' ' . PMA_backquote($mime_field, $sql_backquotes))
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($mime['mimetype'], $sql_backquotes) . $crlf; . PMA_exportComment(' ' . PMA_backquote($mime['mimetype'], $sql_backquotes));
} }
$schema_create .= $GLOBALS['comment_marker'] . $crlf; $schema_create .= PMA_exportComment();
} }
if ($have_rel) { if ($have_rel) {
$schema_create .= $crlf . $GLOBALS['comment_marker'] . $crlf $schema_create .= $crlf
. $GLOBALS['comment_marker'] . $GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':' . $crlf; . PMA_exportComment()
. PMA_exportComment($GLOBALS['strRelationsForTable']. ' ' . PMA_backquote($table, $sql_backquotes) . ':');
foreach ($res_rel AS $rel_field => $rel) { foreach ($res_rel AS $rel_field => $rel) {
$schema_create .= $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel_field, $sql_backquotes) . $crlf $schema_create .= PMA_exportComment(' ' . PMA_backquote($rel_field, $sql_backquotes))
. $GLOBALS['comment_marker'] . ' ' . PMA_backquote($rel['foreign_table'], $sql_backquotes) . PMA_exportComment(' ' . PMA_backquote($rel['foreign_table'], $sql_backquotes)
. ' -> ' . PMA_backquote($rel['foreign_field'], $sql_backquotes) . $crlf; . ' -> ' . PMA_backquote($rel['foreign_field'], $sql_backquotes));
} }
$schema_create .= $GLOBALS['comment_marker'] . $crlf; $schema_create .= PMA_exportComment();
} }
return $schema_create; return $schema_create;
@@ -679,18 +682,21 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
? PMA_backquote($table) ? PMA_backquote($table)
: '\'' . $table . '\''; : '\'' . $table . '\'';
$dump = $crlf $dump = $crlf
. $GLOBALS['comment_marker'] . '--------------------------------------------------------' . $crlf . PMA_exportComment(str_repeat('-', 55))
. $crlf . $GLOBALS['comment_marker'] . $crlf; . $crlf
. PMA_exportComment();
switch($export_mode) { switch($export_mode) {
case 'create_table': case 'create_table':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strTableStructure'] . ' ' . $formatted_table_name . $crlf $dump .= PMA_exportComment($GLOBALS['strTableStructure'] . ' ' . $formatted_table_name)
. $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment();
$dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf; $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf;
$triggers = PMA_DBI_get_triggers($db, $table); $triggers = PMA_DBI_get_triggers($db, $table);
if ($triggers) { if ($triggers) {
$dump .= $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strTriggers'] . ' ' . $formatted_table_name . $crlf $dump .= $crlf
. $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment()
. PMA_exportComment($GLOBALS['strTriggers'] . ' ' . $formatted_table_name)
. PMA_exportComment();
$delimiter = '//'; $delimiter = '//';
foreach ($triggers as $trigger) { foreach ($triggers as $trigger) {
$dump .= $trigger['drop'] . ';' . $crlf; $dump .= $trigger['drop'] . ';' . $crlf;
@@ -701,8 +707,8 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $relation = FALSE,
} }
break; break;
case 'create_view': case 'create_view':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStructureForView'] . ' ' . $formatted_table_name . $crlf $dump .= PMA_exportComment($GLOBALS['strStructureForView'] . ' ' . $formatted_table_name)
. $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment();
// delete the stand-in table previously created (if any) // delete the stand-in table previously created (if any)
if ($export_type != 'table') { if ($export_type != 'table') {
$dump .= 'DROP TABLE IF EXISTS ' . PMA_backquote($table) . ';' . $crlf; $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; $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $dates) . ';' . $crlf;
break; break;
case 'stand_in': case 'stand_in':
$dump .= $GLOBALS['comment_marker'] . $GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name . $crlf $dump .= PMA_exportComment($GLOBALS['strStandInStructureForView'] . ' ' . $formatted_table_name)
. $GLOBALS['comment_marker'] . $crlf; . PMA_exportComment();
// export a stand-in definition to resolve view dependencies // export a stand-in definition to resolve view dependencies
$dump .= PMA_getTableDefStandIn($db, $table, $crlf); $dump .= PMA_getTableDefStandIn($db, $table, $crlf);
} // end switch } // end switch
@@ -757,11 +763,12 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
? PMA_backquote($table) ? PMA_backquote($table)
: '\'' . $table . '\''; : '\'' . $table . '\'';
$head = $crlf $head = $crlf
. $GLOBALS['comment_marker'] . $crlf . PMA_exportComment()
. $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf . PMA_exportComment($GLOBALS['strDumpingData'] . ' ' . $formatted_table_name)
. $GLOBALS['comment_marker'] . $crlf .$crlf; . PMA_exportComment()
. $crlf;
if (!PMA_exportOutputHandler($head)) { if (! PMA_exportOutputHandler($head)) {
return FALSE; return FALSE;
} }