From 4330110c9023aacf1bc5cd4dee7f672ca475f96e Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 3 Jan 2015 19:52:30 +0100 Subject: [PATCH 1/3] Revert "Fix #4645 Import of export created with mysqldump" This reverts commit 2dcb1c9b0a9c6603a3bb39fb49f568a2c8d9b5cd. Signed-off-by: Hugues Peccatte --- libraries/plugins/import/ImportSql.class.php | 71 +++++++------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php index 8fa36a9d59..306d75abba 100644 --- a/libraries/plugins/import/ImportSql.class.php +++ b/libraries/plugins/import/ImportSql.class.php @@ -40,11 +40,6 @@ class ImportSql extends ImportPlugin */ private $_delimiterPosition = false; - /** - * @var string Query to execute - */ - private $_query = null; - /** * @var int Query start position */ @@ -217,10 +212,7 @@ class ImportSql extends ImportPlugin { //Search for closing quote $posClosingString = $this->_stringFctToUse['strpos']( - $this->_data, $this->_quote, - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_quote - ) + $this->_data, $this->_quote, $this->_delimiterPosition ); if (false === $posClosingString) { @@ -276,53 +268,49 @@ class ImportSql extends ImportPlugin $posClosingComment = $this->_stringFctToUse['strpos']( $this->_data, "\n", - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_openingComment - ) + $this->_delimiterPosition ); if (false === $posClosingComment) { return false; } //Move after the end of the line. $this->_delimiterPosition = $posClosingComment + 1; + $this->_isInComment = false; + $this->_openingComment = null; } elseif ('/*' === $this->_openingComment) { //Search for closing comment $posClosingComment = $this->_stringFctToUse['strpos']( $this->_data, '*/', - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_openingComment - ) + $this->_delimiterPosition ); if (false === $posClosingComment) { return false; } //Move after closing comment. $this->_delimiterPosition = $posClosingComment + 2; + $this->_isInComment = false; + $this->_openingComment = null; } else { //We shouldn't be able to come here. //throw new Exception('Unknown case.'); break; } - $this->_queryBeginPosition = $this->_delimiterPosition; - $this->_isInComment = false; - $this->_openingComment = null; + if (0 === $this->_firstSearchChar) { + $this->_queryBeginPosition = $this->_delimiterPosition; + } continue; } if ($this->_isInDelimiter) { - $posAfterKeyword = $this->_delimiterPosition - + $this->_stringFctToUse['strlen']( - $this->_delimiterKeyword - ); //Search for new line. if (!preg_match( "/^(.*)\n/", $this->_stringFctToUse['substr']( $this->_data, - $posAfterKeyword + $this->_delimiterPosition ), $matches, PREG_OFFSET_CAPTURE @@ -332,8 +320,8 @@ class ImportSql extends ImportPlugin $this->_setDelimiter($matches[1][0]); //Start after delimiter and new line. - $this->_queryBeginPosition = $posAfterKeyword + $matches[1][1] - + $this->_delimiterLength + 1; + $this->_queryBeginPosition = $this->_delimiterPosition + + $matches[1][1] + $this->_delimiterLength + 1; $this->_delimiterPosition = $this->_queryBeginPosition; $this->_isInDelimiter = false; $firstSqlDelimiter = null; @@ -355,7 +343,6 @@ class ImportSql extends ImportPlugin && $firstSqlDelimiter < $this->_firstSearchChar) ) { $this->_delimiterPosition = $firstSqlDelimiter; - $this->_fillQuery(); return true; } @@ -368,7 +355,7 @@ class ImportSql extends ImportPlugin $this->_isInString = true; $this->_quote = $specialChars; //Move after quote. - $this->_delimiterPosition = $this->_firstSearchChar; + $this->_delimiterPosition = $this->_firstSearchChar + 1; continue; } @@ -377,15 +364,16 @@ class ImportSql extends ImportPlugin $this->_isInComment = true; $this->_openingComment = $specialChars; //Move after comment opening. - $this->_delimiterPosition = $this->_firstSearchChar; - $this->_fillQuery(); + $this->_delimiterPosition = $this->_firstSearchChar + + $this->_stringFctToUse['strlen']($specialChars); continue; } //If DELIMITER is found. if ($specialChars === $this->_delimiterKeyword) { $this->_isInDelimiter = true; - $this->_delimiterPosition = $this->_firstSearchChar; + $this->_delimiterPosition = $this->_firstSearchChar + + $this->_stringFctToUse['strlen']($specialChars); continue; } } @@ -459,7 +447,11 @@ class ImportSql extends ImportPlugin } PMA_importRunQuery( - $this->_query, //Query to execute + $this->_stringFctToUse['substr']( + $this->_data, + $this->_queryBeginPosition, + $this->_delimiterPosition - $this->_queryBeginPosition + ), //Query to execute $this->_stringFctToUse['substr']( $this->_data, 0, @@ -468,7 +460,6 @@ class ImportSql extends ImportPlugin false, $sql_data ); - $this->_query = null; $this->_setData( $this->_stringFctToUse['substr']( @@ -625,20 +616,4 @@ class ImportSql extends ImportPlugin return $this->_dataLength; } - - /** - * Fill current query from indexes - * - * @return string Current query - */ - private function _fillQuery() - { - $this->_query .= $this->_stringFctToUse['substr']( - $this->_data, - $this->_queryBeginPosition, - $this->_delimiterPosition - $this->_queryBeginPosition - ); - - return $this->_query; - } } From 561ec7ea30b6a38ca166c41c0a1adee427d3e253 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 3 Jan 2015 21:39:56 +0100 Subject: [PATCH 2/3] Remove code to ignore commit. Fix comment. Signed-off-by: Hugues Peccatte --- libraries/plugins/import/ImportSql.class.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php index 306d75abba..05727d65a3 100644 --- a/libraries/plugins/import/ImportSql.class.php +++ b/libraries/plugins/import/ImportSql.class.php @@ -297,10 +297,6 @@ class ImportSql extends ImportPlugin break; } - if (0 === $this->_firstSearchChar) { - $this->_queryBeginPosition = $this->_delimiterPosition; - } - continue; } @@ -354,7 +350,7 @@ class ImportSql extends ImportPlugin if (in_array($specialChars, array('\'', '"', '`'))) { $this->_isInString = true; $this->_quote = $specialChars; - //Move after quote. + //Move before quote. $this->_delimiterPosition = $this->_firstSearchChar + 1; continue; } @@ -363,7 +359,7 @@ class ImportSql extends ImportPlugin if (in_array($specialChars, array('#', '-- ', '/*'))) { $this->_isInComment = true; $this->_openingComment = $specialChars; - //Move after comment opening. + //Move before comment opening. $this->_delimiterPosition = $this->_firstSearchChar + $this->_stringFctToUse['strlen']($specialChars); continue; From fc6be4a7bd9e00e05846cc4abf9f864a10d081b7 Mon Sep 17 00:00:00 2001 From: Hugues Peccatte Date: Sat, 3 Jan 2015 21:42:32 +0100 Subject: [PATCH 3/3] Update ChangeLog. Signed-off-by: Hugues Peccatte --- ChangeLog | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog b/ChangeLog index 6f81493127..e55d888582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ phpMyAdmin - ChangeLog - bug #4318 Default connection collation and sorting - bug #4683 Relational data is not properly updated on table rename - bug #4655 Undefined index: collation_connection (second patch) +- bug #4682 4.3.3 & 4.3.4 Import sql created by mysqldump fails on foreign keys --- Older ChangeLogs can be found on our project website --- http://www.phpmyadmin.net/old-stuff/ChangeLogs/