Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2013-05-26 15:59:46 +02:00
commit aa762fce8e
3 changed files with 49 additions and 3 deletions

View File

@ -20,7 +20,8 @@ phpMyAdmin - ChangeLog
- bug #3941 Recent tables list always empty
- bug #3933 Do not translate "Open Document" in export settings
- bug #3927 List of tables is missing after expanding in the navigation frame
- bug #3942 Warnings about reserved word for many non reserved words
- bug #3942 Warnings about reserved word for many non reserved words
- bug #3912 Exporting row selection, resulted by ORDER BY query
4.0.2.0 (2013-05-24)
- bug #3902 Cannot browse when table name contains keyword "call"

View File

@ -2099,4 +2099,36 @@ function PMA_isSystemSchema($schema_name, $test_for_mysql_schema = false)
|| (PMA_DRIZZLE && strtolower($schema_name) == 'data_dictionary')
|| ($test_for_mysql_schema && !PMA_DRIZZLE && $schema_name == 'mysql');
}
/**
* Get regular expression which occur first inside the given sql query.
*
* @param Array $regex_array Comparing regular expressions.
* @param String $query SQL query to be checked.
*
* @return String Matching regular expression.
*/
function PMA_getFirstOccurringRegularExpression($regex_array, $query)
{
$minimum_first_occurence_index = null;
$regex = null;
for ($i = 0; $i < count($regex_array); $i++) {
if (preg_match($regex_array[$i], $query, $matches, PREG_OFFSET_CAPTURE)) {
if (is_null($minimum_first_occurence_index)
|| ($matches[0][1] < $minimum_first_occurence_index)
) {
$regex = $regex_array[$i];
$minimum_first_occurence_index = $matches[0][1];
}
}
}
return $regex;
}
?>

View File

@ -37,14 +37,27 @@ if (! empty($sql_query)) {
// Need to generate WHERE clause?
if (isset($where_clause)) {
$temp_sql_array = preg_split("/\bwhere\b/i", $sql_query);
// Regular expressions which can appear in sql query,
// before the sql segment which remains as it is.
$regex_array = array(
'/\bwhere\b/i', '/\bgroup by\b/i', '/\bhaving\b/i', '/\border by\b/i'
);
$first_occurring_regex = PMA_getFirstOccurringRegularExpression(
$regex_array, $sql_query
);
unset($regex_array);
// The part "SELECT `id`, `name` FROM `customers`"
// is not modified by the next code segment, when exporting
// the result set from a query such as
// "SELECT `id`, `name` FROM `customers` WHERE id NOT IN
// ( SELECT id FROM companies WHERE name LIKE '%u%')"
$sql_query = $temp_sql_array[0];
if (! is_null($first_occurring_regex)) {
$temp_sql_array = preg_split($first_occurring_regex, $sql_query);
$sql_query = $temp_sql_array[0];
}
unset($first_occurring_regex, $temp_sql_array);
// Append the where clause using the primary key of each row
if (is_array($where_clause) && (count($where_clause) > 0)) {