Merge remote branch 'origin/master'

This commit is contained in:
Pootle server
2010-08-30 16:40:09 +02:00
10 changed files with 275 additions and 59 deletions

View File

@@ -1039,6 +1039,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
} else { } else {
// Parse SQL if needed // Parse SQL if needed
$parsed_sql = PMA_SQP_parse($query_base); $parsed_sql = PMA_SQP_parse($query_base);
if (PMA_SQP_isError()) {
unset($parsed_sql);
}
} }
// Analyze it // Analyze it
@@ -1242,8 +1245,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
} }
echo '</div><br />' . "\n"; echo '</div><br />' . "\n";
// If we are in an Ajax request, we have most probably been called in // If we are in an Ajax request, we have most probably been called in
// PMA_ajaxResponse(). Hence, collect the buffer contents and return it // PMA_ajaxResponse(). Hence, collect the buffer contents and return it
// to PMA_ajaxResponse(), which will encode it for JSON. // to PMA_ajaxResponse(), which will encode it for JSON.
if( $GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message']) ) { if( $GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message']) ) {
$buffer_contents = ob_get_contents(); $buffer_contents = ob_get_contents();

View File

@@ -717,10 +717,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
$GLOBALS['mime_map'] = PMA_getMIME($db, $table); $GLOBALS['mime_map'] = PMA_getMIME($db, $table);
} }
if ($is_display['sort_lnk'] == '1') {
$select_expr = $analyzed_sql[0]['select_expr_clause'];
}
// See if we have to highlight any header fields of a WHERE query. // See if we have to highlight any header fields of a WHERE query.
// Uses SQL-Parser results. // Uses SQL-Parser results.
$highlight_columns = array(); $highlight_columns = array();
@@ -1299,7 +1295,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql) {
// reset $class from $data_inline_edit_class to '' as we can't edit binary data // reset $class from $data_inline_edit_class to '' as we can't edit binary data
$class = ''; $class = '';
if (stristr($field_flags, 'BINARY')) { if (stristr($field_flags, 'BINARY')) {
if (!isset($row[$i]) || is_null($row[$i])) { if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n"; $vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
@@ -2094,7 +2090,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql)
'submit_mult_change', __('Change'), 'b_edit.png'); 'submit_mult_change', __('Change'), 'b_edit.png');
PMA_buttonOrImage('submit_mult', 'mult_submit', PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_delete', $delete_text, 'b_drop.png'); 'submit_mult_delete', $delete_text, 'b_drop.png');
if ($analyzed_sql[0]['querytype'] == 'SELECT') { if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == 'SELECT') {
PMA_buttonOrImage('submit_mult', 'mult_submit', PMA_buttonOrImage('submit_mult', 'mult_submit',
'submit_mult_export', __('Export'), 'submit_mult_export', __('Export'),
'b_tblexport.png'); 'b_tblexport.png');
@@ -2352,7 +2348,7 @@ function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed
} }
// continue the <td> tag started before calling this function: // continue the <td> tag started before calling this function:
$result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap $result = $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . $nowrap
. ' ' . ($is_field_truncated ? ' truncated' : '') . ' ' . ($is_field_truncated ? ' truncated' : '')
. ($transform_function != $default_function ? ' transformed' : '') . ($transform_function != $default_function ? ' transformed' : '')
. (isset($map[$meta->name]) ? ' relation' : '') . (isset($map[$meta->name]) ? ' relation' : '')

View File

@@ -90,7 +90,7 @@ $rows = array();
/* Iterate over tables */ /* Iterate over tables */
foreach ($sheets as $sheet) { foreach ($sheets as $sheet) {
$col_names_in_first_row = $_REQUEST['ods_col_names']; $col_names_in_first_row = isset($_REQUEST['ods_col_names']);
/* Iterate over rows */ /* Iterate over rows */
foreach ($sheet as $row) { foreach ($sheet as $row) {

View File

@@ -216,9 +216,6 @@ class PMA_User_Schema
. ' AND pdf_page_number = \'' . PMA_sqlAddslashes($this->choosenPage) . '\''; . ' AND pdf_page_number = \'' . PMA_sqlAddslashes($this->choosenPage) . '\'';
$page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option); $page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option);
$array_sh_page = array(); $array_sh_page = array();
$draginit = '';
$reset_draginit = '';
$i = 0;
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) { while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
$array_sh_page[] = $temp_sh_page; $array_sh_page[] = $temp_sh_page;
} }
@@ -229,7 +226,7 @@ class PMA_User_Schema
if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) { if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) {
$with_field_names = TRUE; $with_field_names = TRUE;
} }
$this->_displayScratchboardTables($array_sh_page,$draginit,$reset_draginit); $this->_displayScratchboardTables($array_sh_page);
?> ?>
<form method="post" action="schema_edit.php" name="edcoord"> <form method="post" action="schema_edit.php" name="edcoord">
@@ -464,7 +461,7 @@ class PMA_User_Schema
* @return void * @return void
* @access private * @access private
*/ */
private function _displayScratchboardTables($array_sh_page,$draginit,$reset_draginit) private function _displayScratchboardTables($array_sh_page)
{ {
global $with_field_names,$cfg,$db; global $with_field_names,$cfg,$db;
?> ?>
@@ -475,12 +472,15 @@ class PMA_User_Schema
</form> </form>
<div id="pdflayout" class="pdflayout" style="visibility: hidden;"> <div id="pdflayout" class="pdflayout" style="visibility: hidden;">
<?php <?php
$draginit = '';
$draginit2 = '';
$reset_draginit = '';
$i = 0; $i = 0;
foreach ($array_sh_page as $key => $temp_sh_page) { foreach ($array_sh_page as $key => $temp_sh_page) {
$drag_x = $temp_sh_page['x']; $drag_x = $temp_sh_page['x'];
$drag_y = $temp_sh_page['y']; $drag_y = $temp_sh_page['y'];
$draginit2 = ' Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n"; $draginit2 .= ' Drag.init(getElement("table_' . $i . '"), null, 0, parseInt(myid.style.width)-2, 0, parseInt(myid.style.height)-5);' . "\n";
$draginit .= ' getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n"; $draginit .= ' getElement("table_' . $i . '").onDrag = function (x, y) { document.edcoord.elements["c_table_' . $i . '[x]"].value = parseInt(x); document.edcoord.elements["c_table_' . $i . '[y]"].value = parseInt(y) }' . "\n";
$draginit .= ' getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n"; $draginit .= ' getElement("table_' . $i . '").style.left = "' . $drag_x . 'px";' . "\n";
$draginit .= ' getElement("table_' . $i . '").style.top = "' . $drag_y . 'px";' . "\n"; $draginit .= ' getElement("table_' . $i . '").style.top = "' . $drag_y . 'px";' . "\n";

View File

@@ -17,7 +17,7 @@
* (It's slower to have PHP do the count). * (It's slower to have PHP do the count).
* *
* It's easier to use only uppercase for proper sorting. In case of * It's easier to use only uppercase for proper sorting. In case of
* doubt, use the DEBUG code after this function's definition. * doubt, use the test case to verify.
* *
* @package phpMyAdmin * @package phpMyAdmin
*/ */
@@ -210,7 +210,6 @@ $PMA_SQPdata_function_name = array (
'MOD', 'MOD',
'MONTH', 'MONTH',
'MONTHNAME', 'MONTHNAME',
'NOW',
'MPOINTFROMTEXT', // MPointFromText() 'MPOINTFROMTEXT', // MPointFromText()
'MPOINTFROMWKB', // MPointFromWKB() 'MPOINTFROMWKB', // MPointFromWKB()
'MPOLYFROMTEXT', // MPolyFromText() 'MPOLYFROMTEXT', // MPolyFromText()
@@ -338,18 +337,7 @@ $PMA_SQPdata_function_name = array (
* *
* @global integer MySQL attributes count * @global integer MySQL attributes count
*/ */
$PMA_SQPdata_function_name_cnt = 299; $PMA_SQPdata_function_name_cnt = 298;
/*
* DEBUG
$test_PMA_SQPdata_function_name = $PMA_SQPdata_function_name;
sort($PMA_SQPdata_function_name);
if ($PMA_SQPdata_function_name != $test_PMA_SQPdata_function_name) {
echo 'sort properly like this<pre>';
print_r($PMA_SQPdata_function_name);
echo '</pre>';
}
*/
/** /**
* @global array MySQL attributes * @global array MySQL attributes
@@ -698,24 +686,7 @@ $PMA_SQPdata_reserved_word = array (
* *
* @global integer MySQL reserved words count * @global integer MySQL reserved words count
*/ */
$PMA_SQPdata_reserved_word_cnt = 291; $PMA_SQPdata_reserved_word_cnt = 289;
/**
* The previous array must be sorted so that the binary search work.
* Sometimes a word is not added in the correct order, so
* this debugging code shows the problem. The same should be
* done for all arrays.
*/
/*
$original = $PMA_SQPdata_reserved_word;
sort($PMA_SQPdata_reserved_word);
$difference = array_diff_assoc($original, $PMA_SQPdata_reserved_word);
echo '<pre>';
print_r($difference);
echo '</pre>';
echo '<pre>';
print_r($PMA_SQPdata_reserved_word);
echo '</pre>';
*/
/** /**
* words forbidden to be used as column or table name wihtout quotes * words forbidden to be used as column or table name wihtout quotes
@@ -1047,9 +1018,9 @@ $PMA_SQPdata_forbidden_word = array (
'RAID_TYPE', 'RAID_TYPE',
'RANGE', // 5.1 'RANGE', // 5.1
'READ', 'READ',
'READS',
'READ_ONLY', // 5.1 'READ_ONLY', // 5.1
'READ_WRITE', // 5.1 'READ_WRITE', // 5.1
'READS',
'REAL', 'REAL',
'RECOVER', 'RECOVER',
'REDUNDANT', 'REDUNDANT',
@@ -1286,10 +1257,4 @@ $PMA_SQPdata_column_type = array (
*/ */
$PMA_SQPdata_column_type_cnt = 54; $PMA_SQPdata_column_type_cnt = 54;
/*
* check counts
foreach ($GLOBALS as $n => $a) {
echo is_array($a) ? $n . ': ' . count($a) . '<br />' : '';
}
*/
?> ?>

View File

@@ -43,7 +43,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* Include data for the SQL Parser * Include data for the SQL Parser
*/ */
require_once './libraries/sqlparser.data.php'; require_once './libraries/sqlparser.data.php';
require_once './libraries/mysql_charsets.lib.php'; if (!defined('TESTSUITE')) {
require_once './libraries/mysql_charsets.lib.php';
}
if (!isset($mysql_charsets)) { if (!isset($mysql_charsets)) {
$mysql_charsets = array(); $mysql_charsets = array();
$mysql_charsets_count = 0; $mysql_charsets_count = 0;
@@ -2091,8 +2093,8 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$docu = TRUE; $docu = TRUE;
break; break;
} // end switch } // end switch
// inner_sql is a span that exists for all cases // inner_sql is a span that exists for all cases
// of $cfg['SQP']['fmtType'] to make possible a replacement // of $cfg['SQP']['fmtType'] to make possible a replacement
// for inline editing // for inline editing
$str .= '<span class="inner_sql">'; $str .= '<span class="inner_sql">';
$close_docu_link = false; $close_docu_link = false;

View File

@@ -5384,7 +5384,7 @@ msgstr "MySQL vrátil prázdný výsledek (tj. nulový počet řádků)."
#: libraries/import.lib.php:1110 #: libraries/import.lib.php:1110
msgid "" msgid ""
"The following structures have either been created or altered. Here you can:" "The following structures have either been created or altered. Here you can:"
msgstr "Následující tabulkybyly vytvořeny nebo změněny. Teď můžete:" msgstr "Následující tabulky byly vytvořeny nebo změněny. Teď můžete:"
#: libraries/import.lib.php:1111 #: libraries/import.lib.php:1111
msgid "View a structure`s contents by clicking on its name" msgid "View a structure`s contents by clicking on its name"

View File

@@ -51,6 +51,7 @@ require_once './test/PMA_foreignKeySupported_test.php';
require_once './test/PMA_headerLocation_test.php'; require_once './test/PMA_headerLocation_test.php';
require_once './test/PMA_Message_test.php'; require_once './test/PMA_Message_test.php';
require_once './test/PMA_whichCrlf_test.php'; require_once './test/PMA_whichCrlf_test.php';
require_once './test/PMA_SQL_parser_data_test.php';
class AllTests class AllTests
{ {

View File

@@ -0,0 +1,68 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for correctness of SQL parser data
*
* @package phpMyAdmin-test
*/
/**
* Tests core.
*/
require_once 'PHPUnit/Framework.php';
define('PHPMYADMIN', 1);
/**
* Include to test.
*/
require_once './libraries/sqlparser.data.php';
/**
* Test for sorting of the arrays
*
* @package phpMyAdmin-test
*/
class PMA_SQL_parser_data_test extends PHPUnit_Framework_TestCase
{
private function assertSorted($array)
{
$copy = $array;
sort($copy);
$difference = array_diff_assoc($array, $copy);
$this->assertEquals($difference, array());
}
private function assertParserData($name)
{
$this->assertSorted($GLOBALS[$name]);
$this->assertEquals(count($GLOBALS[$name]), $GLOBALS[$name . '_cnt']);
}
public function testPMA_SQPdata_function_name()
{
$this->assertParserData('PMA_SQPdata_function_name');
}
public function testPMA_SQPdata_column_attrib()
{
$this->assertParserData('PMA_SQPdata_column_attrib');
}
public function testPMA_SQPdata_reserved_word()
{
$this->assertParserData('PMA_SQPdata_reserved_word');
}
public function testPMA_SQPdata_forbidden_word()
{
$this->assertParserData('PMA_SQPdata_forbidden_word');
}
public function testPMA_SQPdata_column_type()
{
$this->assertParserData('PMA_SQPdata_column_type');
}
}
?>

View File

@@ -0,0 +1,181 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for correctness of SQL parser
*
* @package phpMyAdmin-test
*/
/**
* Tests core.
*/
require_once 'PHPUnit/Framework.php';
define('PHPMYADMIN', 1);
define('TESTSUITE', 1);
$GLOBALS['charset'] = 'utf-8';
function __($s) {
return $s;
}
/**
* Include to test.
*/
require_once './libraries/sqlparser.lib.php';
/**
* Test for SQL parser
*
* @package phpMyAdmin-test
*/
class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase
{
private function assertParser($sql, $expected, $error = '')
{
$parsed_sql = PMA_SQP_parse($sql);
$this->assertEquals(PMA_SQP_getErrorString(), $error);
$this->assertEquals($parsed_sql, $expected);
}
public function testParse_1()
{
$this->assertParser('SELECT 1;', array (
'raw' => 'SELECT 1;',
0 =>
array (
'type' => 'alpha_reservedWord',
'data' => 'SELECT',
'pos' => 6,
'forbidden' => true,
),
1 =>
array (
'type' => 'digit_integer',
'data' => '1',
'pos' => 8,
),
2 =>
array (
'type' => 'punct_queryend',
'data' => ';',
'pos' => 0,
),
'len' => 3,
));
}
public function testParse_2()
{
$this->assertParser('SELECT * from aaa;', array (
'raw' => 'SELECT * from aaa;',
0 =>
array (
'type' => 'alpha_reservedWord',
'data' => 'SELECT',
'pos' => 6,
'forbidden' => true,
),
1 =>
array (
'type' => 'punct',
'data' => '*',
'pos' => 0,
),
2 =>
array (
'type' => 'alpha_reservedWord',
'data' => 'from',
'pos' => 13,
'forbidden' => true,
),
3 =>
array (
'type' => 'alpha_identifier',
'data' => 'aaa',
'pos' => 17,
'forbidden' => false,
),
4 =>
array (
'type' => 'punct_queryend',
'data' => ';',
'pos' => 0,
),
'len' => 5,
));
}
public function testParse_3()
{
$this->assertParser('SELECT * from `aaa`;', array (
'raw' => 'SELECT * from `aaa`;',
0 =>
array (
'type' => 'alpha_reservedWord',
'data' => 'SELECT',
'pos' => 6,
'forbidden' => true,
),
1 =>
array (
'type' => 'punct',
'data' => '*',
'pos' => 0,
),
2 =>
array (
'type' => 'alpha_reservedWord',
'data' => 'from',
'pos' => 13,
'forbidden' => true,
),
3 =>
array (
'type' => 'quote_backtick',
'data' => '`aaa`',
'pos' => 0,
),
4 =>
array (
'type' => 'punct_queryend',
'data' => ';',
'pos' => 0,
),
'len' => 5,
));
}
public function testParse_4()
{
$this->assertParser('SELECT * from `aaa;', array (
'raw' => 'SELECT * from `aaa;',
0 =>
array (
'type' => 'alpha',
'data' => 'SELECT',
'pos' => 6,
),
1 =>
array (
'type' => 'punct',
'data' => '*',
'pos' => 0,
),
2 =>
array (
'type' => 'alpha',
'data' => 'from',
'pos' => 13,
),
),
'<p>There seems to be an error in your SQL query. The MySQL server error output below, if there is any, may also help you in diagnosing the problem</p>
<pre>
ERROR: Unclosed quote @ 14
STR: `
SQL: SELECT * from `aaa;
</pre>
');
}
}
?>