Merge pull request #1356 from Tithugues/b4528_master
Fix #4528 Can't import dump via SQL field
This commit is contained in:
commit
6a038d5f90
@ -30,7 +30,7 @@ phpMyAdmin - ChangeLog
|
||||
- bug #4439 Table list in left panel doesn't expand
|
||||
+ rfe Improved validation when inserting data
|
||||
+ rfe #1491 Support InnoDB for database Query by example
|
||||
+ rfe #345 Normalize a table
|
||||
+ rfe #345 Normalize a table
|
||||
+ rfe #1123 Zeroconf PMA tables support
|
||||
+ rfe #1492 Remove the distinct query window / Add SQL log+history panel
|
||||
+ rfe #919 Multiple-column foreign key relation
|
||||
@ -41,6 +41,7 @@ phpMyAdmin - ChangeLog
|
||||
+ MariaDB 10+ multi-master replication support
|
||||
+ rfe #1544 MySQL 5.7.5 compatibility
|
||||
+ rfe #1529 Avoid session timeout when user is active
|
||||
- bug #4528 Can't import dump via SQL field
|
||||
|
||||
4.2.9.0 (not yet released)
|
||||
- bug ajax.js responseHandler: cannot read property of null
|
||||
|
||||
@ -270,6 +270,22 @@ class PMA_String implements PMA_StringByte, PMA_StringType
|
||||
return $this->_byte->strtoupper($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns position of $needle in $haystack from a regular expression match
|
||||
*
|
||||
* @param string $pattern Pattern to search for
|
||||
* @param string $subject Input string
|
||||
* @param int $offset Start from search
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*
|
||||
* @todo add unit tests
|
||||
*/
|
||||
public function pregStrpos($pattern, $subject, $offset = 0)
|
||||
{
|
||||
return $this->_byte->pregStrpos($pattern, $subject, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ordinal value of a string
|
||||
*
|
||||
|
||||
@ -141,6 +141,17 @@ interface PMA_StringByte
|
||||
*/
|
||||
public function strtoupper($string);
|
||||
|
||||
/**
|
||||
* Returns position of $needle in $haystack from a regular expression match
|
||||
*
|
||||
* @param string $pattern Pattern to search for
|
||||
* @param string $subject Input string
|
||||
* @param int $offset Start from search
|
||||
*
|
||||
* @return integer position of $needle in $haystack or false
|
||||
*/
|
||||
public function pregStrpos($pattern, $subject, $offset = 0);
|
||||
|
||||
/**
|
||||
* Get the ordinal value of a string
|
||||
*
|
||||
|
||||
@ -293,5 +293,28 @@ class PMA_StringMB implements PMA_StringByte
|
||||
'UCS-4BE'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a regular expression match
|
||||
*
|
||||
* @param string $pattern Pattern to search for
|
||||
* @param string $subject Input string
|
||||
* @param int $offset Start from search
|
||||
*
|
||||
* @return int 1 if matched, 0 if doesn't, false on failure
|
||||
*/
|
||||
public function pregStrpos($pattern, $subject, $offset = 0)
|
||||
{
|
||||
$matches = array();
|
||||
$bFind = preg_match(
|
||||
$pattern, $subject, $matches, PREG_OFFSET_CAPTURE, $offset
|
||||
);
|
||||
if (1 !== $bFind) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$strFound = $matches[1][0];
|
||||
return $this->strpos($subject, $strFound, $offset);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -197,6 +197,28 @@ class PMA_StringNative implements PMA_StringByte
|
||||
return strtoupper($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a regular expression match
|
||||
*
|
||||
* @param string $pattern Pattern to search for
|
||||
* @param string $subject Input string
|
||||
* @param int $offset Start from search
|
||||
*
|
||||
* @return int 1 if matched, 0 if doesn't, false on failure
|
||||
*/
|
||||
public function pregStrpos($pattern, $subject, $offset = 0)
|
||||
{
|
||||
$matches = array();
|
||||
$bFind = preg_match(
|
||||
$pattern, $subject, $matches, PREG_OFFSET_CAPTURE, $offset
|
||||
);
|
||||
if (1 !== $bFind) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $matches[1][1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ordinal value of a string
|
||||
*
|
||||
|
||||
@ -194,18 +194,16 @@ class ImportSql extends ImportPlugin
|
||||
$old_i = $i;
|
||||
// this is about 7 times faster that looking for each sequence i
|
||||
// one by one with strpos()
|
||||
$match = preg_match(
|
||||
$posPattern = $pmaString->pregStrpos(
|
||||
'/(\'|"|#|-- |\/\*|`|(?i)(?<![A-Z0-9_])'
|
||||
. $delimiter_keyword . ')/',
|
||||
$buffer,
|
||||
$matches,
|
||||
PREG_OFFSET_CAPTURE,
|
||||
$i
|
||||
);
|
||||
if ($match) {
|
||||
if (false !== $posPattern) {
|
||||
// in $matches, index 0 contains the match for the complete
|
||||
// expression but we don't use it
|
||||
$first_position = $matches[1][1];
|
||||
$first_position = $posPattern;
|
||||
} else {
|
||||
$first_position = $big_value;
|
||||
}
|
||||
@ -247,7 +245,8 @@ class ImportSql extends ImportPlugin
|
||||
}
|
||||
|
||||
// Grab current character
|
||||
$ch = $buffer[$i];
|
||||
//$ch = $buffer[$i]; //Don't use this syntax, because of UTF8 strings
|
||||
$ch = $pmaString->substr($buffer, $i, 1);
|
||||
|
||||
// Quotes
|
||||
if ($pmaString->strpos('\'"`', $ch) !== false) {
|
||||
@ -279,7 +278,7 @@ class ImportSql extends ImportPlugin
|
||||
}
|
||||
// Was not the quote escaped?
|
||||
$j = $pos - 1;
|
||||
while ($buffer[$j] == '\\') {
|
||||
while ($pmaString->substr($buffer, $j, 1) == '\\') {
|
||||
$j--;
|
||||
}
|
||||
// Even count means it was not escaped
|
||||
@ -305,8 +304,10 @@ class ImportSql extends ImportPlugin
|
||||
|
||||
// Not enough data to decide
|
||||
if ((($i == ($len - 1) && ($ch == '-' || $ch == '/'))
|
||||
|| ($i == ($len - 2) && (($ch == '-' && $buffer[$i + 1] == '-')
|
||||
|| ($ch == '/' && $buffer[$i + 1] == '*'))))
|
||||
|| ($i == ($len - 2) && (($ch == '-'
|
||||
&& $pmaString->substr($buffer, $i + 1, 1) == '-')
|
||||
|| ($ch == '/'
|
||||
&& $pmaString->substr($buffer, $i + 1, 1) == '*'))))
|
||||
&& ! $GLOBALS['finished']
|
||||
) {
|
||||
break;
|
||||
@ -314,10 +315,13 @@ class ImportSql extends ImportPlugin
|
||||
|
||||
// Comments
|
||||
if ($ch == '#'
|
||||
|| ($i < ($len - 1) && $ch == '-' && $buffer[$i + 1] == '-'
|
||||
&& (($i < ($len - 2) && $buffer[$i + 2] <= ' ')
|
||||
|| ($i == ($len - 1) && $GLOBALS['finished'])))
|
||||
|| ($i < ($len - 1) && $ch == '/' && $buffer[$i + 1] == '*')
|
||||
|| ($i < ($len - 1) && $ch == '-'
|
||||
&& $pmaString->substr($buffer, $i + 1, 1) == '-'
|
||||
&& (($i < ($len - 2)
|
||||
&& $pmaString->substr($buffer, $i + 2, 1) <= ' ')
|
||||
|| ($i == ($len - 1) && $GLOBALS['finished'])))
|
||||
|| ($i < ($len - 1) && $ch == '/'
|
||||
&& $pmaString->substr($buffer, $i + 1, 1) == '*')
|
||||
) {
|
||||
// Copy current string to SQL
|
||||
if ($start_pos != $i) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user