Revert "Fix #4645 Import of export created with mysqldump"

This reverts commit 2dcb1c9b0a.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2015-01-03 19:52:30 +01:00
parent a29ee3897a
commit 4330110c90

View File

@ -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;
}
}