Index: branches/5.2.x/core/kernel/db/db_connection.php =================================================================== diff -u -N -r16710 -r16758 --- branches/5.2.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 16710) +++ branches/5.2.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 16758) @@ -1,6 +1,6 @@ ChangeQuery($sql); } @@ -837,7 +839,7 @@ // don't use preg here, as it may fail when string is too long $fields_sql = rtrim($fields_sql, ','); - $sql = 'UPDATE `'.$table.'` SET '.$fields_sql.' WHERE '.$key_clause; + $sql = 'UPDATE ' . $table . ' SET ' . $fields_sql . ' WHERE ' . $key_clause; return $this->ChangeQuery($sql); } Index: branches/5.2.x/core/kernel/db/dblist.php =================================================================== diff -u -N -r16717 -r16758 --- branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16717) +++ branches/5.2.x/core/kernel/db/dblist.php (.../dblist.php) (revision 16758) @@ -1,6 +1,6 @@ sql, $regs) ) { - $this->joins = Array (); + $joins_found = preg_match_all( + '/LEFT\s+JOIN\s+(.*?|.*?\s+AS\s+.*?|.*?\s+.*?)\s+ON\s+(.*?\n|.*?$)/si', + $this->sql, + $regs + ); + + if ( !$joins_found ) { + $this->joins = array(); + + return; } - // get all LEFT JOIN clause info from sql (without filters) - foreach ($regs[1] as $index => $match) { - $match_parts = preg_split('/\s+AS\s+|\s+/i', $match, 2); - $table_alias = count($match_parts) == 1 ? $match : $match_parts[1]; + // Get all LEFT JOIN clause info from sql (without filters). + foreach ( $regs[1] as $index => $join_expression ) { + // Format (without quotes): "tbl_name [PARTITION (partition_names)] [[AS] alias] [index_hint_list]". + $join_expression_parsed = preg_match( + '/([\S]+)(\s*PARTITION\s*\([^)]+\))?(\s*(AS\s*)?([\S]+))?((USE|IGNORE|FORCE)\s+.*)?/', + $join_expression, + $match_parts + ); - $this->joins[$table_alias] = Array ( - 'table' => $match_parts[0], + if ( !$join_expression_parsed ) { + throw new RuntimeException('Unable to parse join expression: ' . $join_expression); + } + + $joined_table_name = $match_parts[1]; + $table_alias = isset($match_parts[5]) && $match_parts[5] !== '' ? $match_parts[5] : $joined_table_name; + + $this->joins[$table_alias] = array( + 'table' => $joined_table_name, 'join_clause' => $regs[0][$index], ); }