diff --git a/ChangeLog b/ChangeLog index ff5e933a98..995bb49cc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,7 @@ phpMyAdmin - ChangeLog - issue #11546 "Visualize GIS data" seems to be broken - issue #11548 Confirm box on "Reset slave" option - issue Fix cookies clearing on version change +- issue #11558 Cannot execute SQL with subquery (fix for part 1) 4.5.0.2 (2015-09-25) - issue #11497 Incorrect indexes when exporting diff --git a/libraries/sql-parser/src/Components/Condition.php b/libraries/sql-parser/src/Components/Condition.php index b33b0c3b4a..d7262c5978 100644 --- a/libraries/sql-parser/src/Components/Condition.php +++ b/libraries/sql-parser/src/Components/Condition.php @@ -40,6 +40,7 @@ class Condition extends Component public static $OPERATORS = array( 'AND' => 1, 'BETWEEN' => 1, + 'EXISTS' => 1, 'IN' => 1, 'IS' => 1, 'LIKE' => 1, diff --git a/libraries/sql-parser/src/Components/PartitionDefinition.php b/libraries/sql-parser/src/Components/PartitionDefinition.php index bc30f61f02..8c54e22f83 100644 --- a/libraries/sql-parser/src/Components/PartitionDefinition.php +++ b/libraries/sql-parser/src/Components/PartitionDefinition.php @@ -10,7 +10,6 @@ */ namespace SqlParser\Components; -use SqlParser\Context; use SqlParser\Component; use SqlParser\Parser; use SqlParser\Token; diff --git a/libraries/sql-parser/src/Context.php b/libraries/sql-parser/src/Context.php index 5cbf6a1abb..40cd93470b 100644 --- a/libraries/sql-parser/src/Context.php +++ b/libraries/sql-parser/src/Context.php @@ -524,5 +524,5 @@ abstract class Context } } -// Initialing the default context. +// Initializing the default context. Context::load(); diff --git a/libraries/sql-parser/src/Lexer.php b/libraries/sql-parser/src/Lexer.php index 9e99b60c86..8c609db08f 100644 --- a/libraries/sql-parser/src/Lexer.php +++ b/libraries/sql-parser/src/Lexer.php @@ -171,7 +171,7 @@ class Lexer */ public static function getTokens($str, $strict = false, $delimiter = null) { - $lexer = new Lexer($str); + $lexer = new Lexer($str, $strict, $delimiter); return $lexer->list; } diff --git a/libraries/sql-parser/src/Statement.php b/libraries/sql-parser/src/Statement.php index 3fe3f42c1d..b15dc3dac9 100644 --- a/libraries/sql-parser/src/Statement.php +++ b/libraries/sql-parser/src/Statement.php @@ -108,6 +108,20 @@ abstract class Statement */ $query = ''; + /** + * Clauses which were built already. + * + * It is required to keep track of built clauses because some fields, + * for example `join` is used by multiple clauses (`JOIN`, `LEFT JOIN`, + * `LEFT OUTER JOIN`, etc.). The same happens for `VALUE` and `VALUES`. + * + * A clause is considered built just after fields' value + * (`$this->field`) was used in building. + * + * @var array + */ + $built = array(); + foreach (static::$CLAUSES as $clause) { /** * The name of the clause. @@ -144,6 +158,15 @@ abstract class Statement continue; } + // Checking if this field was already built. + if ($type & 1) { + if (!empty($built[$field])) { + continue; + } + + $built[$field] = true; + } + // Checking if the name of the clause should be added. if ($type & 2) { $query .= $name . ' ';