From 617b01499c5aee7f212207b0ca928875df22b175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 14:28:06 +0200 Subject: [PATCH 01/18] Fix typo. --- po/cs.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/cs.po b/po/cs.po index c350a2748..079553c8a 100644 --- a/po/cs.po +++ b/po/cs.po @@ -5384,7 +5384,7 @@ msgstr "MySQL vrátil prázdný výsledek (tj. nulový počet řádků)." #: libraries/import.lib.php:1110 msgid "" "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 msgid "View a structure`s contents by clicking on its name" From 0d1b51576967ecbd1f771e1387e2ba1bd29fb799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 14:29:00 +0200 Subject: [PATCH 02/18] Fixed detection of ods_col_names (bug #3056017). --- libraries/import/ods.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/import/ods.php b/libraries/import/ods.php index 7df7edcbf..c0db7afbf 100644 --- a/libraries/import/ods.php +++ b/libraries/import/ods.php @@ -90,7 +90,7 @@ $rows = array(); /* Iterate over tables */ 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 */ foreach ($sheet as $row) { From aa4536371980e7c8144505f1a74cff658178fc8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 14:38:37 +0200 Subject: [PATCH 03/18] Correct count of words. --- libraries/sqlparser.data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index 8af645874..b0b06c2cc 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -698,7 +698,7 @@ $PMA_SQPdata_reserved_word = array ( * * @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 From 42f04d4a7ece376c57d3c7a717e24bbcc6621425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 14:49:38 +0200 Subject: [PATCH 04/18] Avoid precalculating counts. The count() on array is cheap in PHP and having hardcoded numbers only tends to break. --- libraries/sqlparser.data.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index b0b06c2cc..8f0c140b5 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -338,7 +338,7 @@ $PMA_SQPdata_function_name = array ( * * @global integer MySQL attributes count */ -$PMA_SQPdata_function_name_cnt = 299; +$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name); /* * DEBUG @@ -391,7 +391,7 @@ $PMA_SQPdata_column_attrib = array ( * * @global integer MySQL attributes count */ -$PMA_SQPdata_column_attrib_cnt = 30; +$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib); /** * words that are reserved by MySQL and may not be used as identifiers without quotes @@ -698,7 +698,7 @@ $PMA_SQPdata_reserved_word = array ( * * @global integer MySQL reserved words count */ -$PMA_SQPdata_reserved_word_cnt = 289; +$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word); /** * The previous array must be sorted so that the binary search work. * Sometimes a word is not added in the correct order, so @@ -1213,7 +1213,7 @@ $PMA_SQPdata_forbidden_word = array ( * * @global integer MySQL forbidden words count */ -$PMA_SQPdata_forbidden_word_cnt = 483; +$PMA_SQPdata_forbidden_word_cnt = count($PMA_SQPdata_forbidden_word); /** * the MySQL column/data types @@ -1284,7 +1284,7 @@ $PMA_SQPdata_column_type = array ( * * @global integer MySQL column types count */ -$PMA_SQPdata_column_type_cnt = 54; +$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type); /* * check counts From 7ab207384a6d6bef8fd18b1fca65c3a7ec003eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:18:30 +0200 Subject: [PATCH 05/18] Add testcase for validity of SQL parser data. --- test/AllTests.php | 1 + test/PMA_SQL_parser_data_test.php | 62 +++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 test/PMA_SQL_parser_data_test.php diff --git a/test/AllTests.php b/test/AllTests.php index b77f3ecfc..338f83d58 100644 --- a/test/AllTests.php +++ b/test/AllTests.php @@ -51,6 +51,7 @@ require_once './test/PMA_foreignKeySupported_test.php'; require_once './test/PMA_headerLocation_test.php'; require_once './test/PMA_Message_test.php'; require_once './test/PMA_whichCrlf_test.php'; +require_once './test/PMA_SQL_parser_data_test.php'; class AllTests { diff --git a/test/PMA_SQL_parser_data_test.php b/test/PMA_SQL_parser_data_test.php new file mode 100644 index 000000000..e8271639c --- /dev/null +++ b/test/PMA_SQL_parser_data_test.php @@ -0,0 +1,62 @@ +assertEquals($difference, array()); + } + + public function testPMA_SQPdata_function_name() + { + $this->assertSorted($GLOBALS['PMA_SQPdata_function_name']); + } + + public function testPMA_SQPdata_column_attrib() + { + $this->assertSorted($GLOBALS['PMA_SQPdata_column_attrib']); + } + + public function testPMA_SQPdata_reserved_word() + { + $this->assertSorted($GLOBALS['PMA_SQPdata_reserved_word']); + } + + public function testPMA_SQPdata_forbidden_word() + { + $this->assertSorted($GLOBALS['PMA_SQPdata_forbidden_word']); + } + + public function testPMA_SQPdata_column_type() + { + $this->assertSorted($GLOBALS['PMA_SQPdata_column_type']); + } + +} +?> From 7f7bdf12bfd936f130355aab2ee44912f3dfaeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:19:03 +0200 Subject: [PATCH 06/18] Avoid duplicate NOW in keywords. --- libraries/sqlparser.data.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index 8f0c140b5..8a6144834 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -210,7 +210,6 @@ $PMA_SQPdata_function_name = array ( 'MOD', 'MONTH', 'MONTHNAME', - 'NOW', 'MPOINTFROMTEXT', // MPointFromText() 'MPOINTFROMWKB', // MPointFromWKB() 'MPOLYFROMTEXT', // MPolyFromText() From 8860f834665582f71e3b4612825a794fdcc10581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:19:44 +0200 Subject: [PATCH 07/18] READS should be before READ_*. --- libraries/sqlparser.data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index 8a6144834..a9196c5b8 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -1046,9 +1046,9 @@ $PMA_SQPdata_forbidden_word = array ( 'RAID_TYPE', 'RANGE', // 5.1 'READ', + 'READS', 'READ_ONLY', // 5.1 'READ_WRITE', // 5.1 - 'READS', 'REAL', 'RECOVER', 'REDUNDANT', From 20800942f340465c6c4e3abaa69a00ed997224e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:20:09 +0200 Subject: [PATCH 08/18] Revert "Avoid precalculating counts." This reverts commit 42f04d4a7ece376c57d3c7a717e24bbcc6621425. We will stick with precalculated ones and check it in testcase. --- libraries/sqlparser.data.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index a9196c5b8..38b179a7c 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -337,7 +337,7 @@ $PMA_SQPdata_function_name = array ( * * @global integer MySQL attributes count */ -$PMA_SQPdata_function_name_cnt = count($PMA_SQPdata_function_name); +$PMA_SQPdata_function_name_cnt = 299; /* * DEBUG @@ -390,7 +390,7 @@ $PMA_SQPdata_column_attrib = array ( * * @global integer MySQL attributes count */ -$PMA_SQPdata_column_attrib_cnt = count($PMA_SQPdata_column_attrib); +$PMA_SQPdata_column_attrib_cnt = 30; /** * words that are reserved by MySQL and may not be used as identifiers without quotes @@ -697,7 +697,7 @@ $PMA_SQPdata_reserved_word = array ( * * @global integer MySQL reserved words count */ -$PMA_SQPdata_reserved_word_cnt = count($PMA_SQPdata_reserved_word); +$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 @@ -1212,7 +1212,7 @@ $PMA_SQPdata_forbidden_word = array ( * * @global integer MySQL forbidden words count */ -$PMA_SQPdata_forbidden_word_cnt = count($PMA_SQPdata_forbidden_word); +$PMA_SQPdata_forbidden_word_cnt = 483; /** * the MySQL column/data types @@ -1283,7 +1283,7 @@ $PMA_SQPdata_column_type = array ( * * @global integer MySQL column types count */ -$PMA_SQPdata_column_type_cnt = count($PMA_SQPdata_column_type); +$PMA_SQPdata_column_type_cnt = 54; /* * check counts From e6bd28ea880bfa7b3b941efcb6b4bb54f12f9227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:22:49 +0200 Subject: [PATCH 09/18] Test counts as well. --- test/PMA_SQL_parser_data_test.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/PMA_SQL_parser_data_test.php b/test/PMA_SQL_parser_data_test.php index e8271639c..45fa07cb7 100644 --- a/test/PMA_SQL_parser_data_test.php +++ b/test/PMA_SQL_parser_data_test.php @@ -33,29 +33,35 @@ class PMA_SQL_parser_data_test extends PHPUnit_Framework_TestCase $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->assertSorted($GLOBALS['PMA_SQPdata_function_name']); + $this->assertParserData('PMA_SQPdata_function_name'); } public function testPMA_SQPdata_column_attrib() { - $this->assertSorted($GLOBALS['PMA_SQPdata_column_attrib']); + $this->assertParserData('PMA_SQPdata_column_attrib'); } public function testPMA_SQPdata_reserved_word() { - $this->assertSorted($GLOBALS['PMA_SQPdata_reserved_word']); + $this->assertParserData('PMA_SQPdata_reserved_word'); } public function testPMA_SQPdata_forbidden_word() { - $this->assertSorted($GLOBALS['PMA_SQPdata_forbidden_word']); + $this->assertParserData('PMA_SQPdata_forbidden_word'); } public function testPMA_SQPdata_column_type() { - $this->assertSorted($GLOBALS['PMA_SQPdata_column_type']); + $this->assertParserData('PMA_SQPdata_column_type'); } } From b65e19a8b12428948c641672206c54e51a550268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:22:58 +0200 Subject: [PATCH 10/18] Fix another wrong count. --- libraries/sqlparser.data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index 38b179a7c..2277d6a6c 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -337,7 +337,7 @@ $PMA_SQPdata_function_name = array ( * * @global integer MySQL attributes count */ -$PMA_SQPdata_function_name_cnt = 299; +$PMA_SQPdata_function_name_cnt = 298; /* * DEBUG From 388327d642714ff42e3dd7eb3cdc1c9b24efea2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:24:07 +0200 Subject: [PATCH 11/18] Debug code was migrated to testcase. --- libraries/sqlparser.data.php | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/libraries/sqlparser.data.php b/libraries/sqlparser.data.php index 2277d6a6c..dffd6b166 100644 --- a/libraries/sqlparser.data.php +++ b/libraries/sqlparser.data.php @@ -17,7 +17,7 @@ * (It's slower to have PHP do the count). * * 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 */ @@ -339,17 +339,6 @@ $PMA_SQPdata_function_name = array ( */ $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
';
-    print_r($PMA_SQPdata_function_name);
-    echo '
'; -} - */ - /** * @global array MySQL attributes */ @@ -698,23 +687,6 @@ $PMA_SQPdata_reserved_word = array ( * @global integer MySQL reserved words count */ $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 '
';
-print_r($difference);
-echo '
'; -echo '
';
-print_r($PMA_SQPdata_reserved_word);
-echo '
'; -*/ /** * words forbidden to be used as column or table name wihtout quotes @@ -1285,10 +1257,4 @@ $PMA_SQPdata_column_type = array ( */ $PMA_SQPdata_column_type_cnt = 54; -/* - * check counts -foreach ($GLOBALS as $n => $a) { - echo is_array($a) ? $n . ': ' . count($a) . '
' : ''; -} - */ ?> From a6ba9845042698610bb7071b8d127b7fb37dfd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:53:00 +0200 Subject: [PATCH 12/18] Start testcase for SQL parser. --- libraries/sqlparser.lib.php | 8 +++-- test/PMA_SQL_parser_test.php | 64 ++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 test/PMA_SQL_parser_test.php diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index d8967d9ce..b8b2bbafa 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -43,7 +43,9 @@ if (! defined('PMA_MINIMUM_COMMON')) { * Include data for the SQL Parser */ 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)) { $mysql_charsets = array(); $mysql_charsets_count = 0; @@ -2091,8 +2093,8 @@ if (! defined('PMA_MINIMUM_COMMON')) { $docu = TRUE; break; } // end switch - // inner_sql is a span that exists for all cases - // of $cfg['SQP']['fmtType'] to make possible a replacement + // inner_sql is a span that exists for all cases + // of $cfg['SQP']['fmtType'] to make possible a replacement // for inline editing $str .= ''; $close_docu_link = false; diff --git a/test/PMA_SQL_parser_test.php b/test/PMA_SQL_parser_test.php new file mode 100644 index 000000000..3eb6849a4 --- /dev/null +++ b/test/PMA_SQL_parser_test.php @@ -0,0 +1,64 @@ +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, + )); + } + +} +?> From 24b83423cea3d00d6d0f2e8a6fb52b5cf47b82f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:54:30 +0200 Subject: [PATCH 13/18] Add testcase for simple SELECT. --- test/PMA_SQL_parser_test.php | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/PMA_SQL_parser_test.php b/test/PMA_SQL_parser_test.php index 3eb6849a4..4f956609e 100644 --- a/test/PMA_SQL_parser_test.php +++ b/test/PMA_SQL_parser_test.php @@ -60,5 +60,45 @@ class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase )); } + 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, + )); + } } ?> From 4afbb5958819a61d52c45bd2f262f8720fa0bb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 15:55:52 +0200 Subject: [PATCH 14/18] Add testcase for backticked table. --- test/PMA_SQL_parser_test.php | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/PMA_SQL_parser_test.php b/test/PMA_SQL_parser_test.php index 4f956609e..0c26bb4c0 100644 --- a/test/PMA_SQL_parser_test.php +++ b/test/PMA_SQL_parser_test.php @@ -100,5 +100,45 @@ class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase '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, + )); + } } ?> From e781f7f9b96fa2ca8970cefba5d628eb7481692d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 16:00:33 +0200 Subject: [PATCH 15/18] Add testcase for failed parsing. --- test/PMA_SQL_parser_test.php | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/test/PMA_SQL_parser_test.php b/test/PMA_SQL_parser_test.php index 0c26bb4c0..2774ba10d 100644 --- a/test/PMA_SQL_parser_test.php +++ b/test/PMA_SQL_parser_test.php @@ -15,6 +15,10 @@ define('PHPMYADMIN', 1); define('TESTSUITE', 1); $GLOBALS['charset'] = 'utf-8'; +function __($s) { + return $s; +} + /** * Include to test. */ @@ -27,9 +31,10 @@ require_once './libraries/sqlparser.lib.php'; */ class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase { - private function assertParser($sql, $expected) + private function assertParser($sql, $expected, $error = '') { $parsed_sql = PMA_SQP_parse($sql); + $this->assertEquals(PMA_SQP_getErrorString(), $error); $this->assertEquals($parsed_sql, $expected); } @@ -140,5 +145,37 @@ class PMA_SQL_parser_test extends PHPUnit_Framework_TestCase '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, + ), + ), +'

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

+
+ERROR: Unclosed quote @ 14
+STR: `
+SQL: SELECT * from `aaa;
+
+'); + } } ?> From 61fe92976f290467b10443f679d7ed882ebb5d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 16:10:51 +0200 Subject: [PATCH 16/18] This variable does not seem to be used. --- libraries/display_tbl.lib.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 16ac8c9d9..d236b7fda 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -717,10 +717,6 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ $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. // Uses SQL-Parser results. $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 $class = ''; - + if (stristr($field_flags, 'BINARY')) { if (!isset($row[$i]) || is_null($row[$i])) { $vertical_display['data'][$row_no][$i] = ' NULL' . "\n"; @@ -2352,7 +2348,7 @@ function PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed } // continue the 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' : '') . ($transform_function != $default_function ? ' transformed' : '') . (isset($map[$meta->name]) ? ' relation' : '') From 1d67babd5286f9f5198b40ee3a4be21f9643ad8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Mon, 30 Aug 2010 16:11:46 +0200 Subject: [PATCH 17/18] Do not fail on non analyzed query (eg. because of parser failure). --- libraries/common.lib.php | 7 +++++-- libraries/display_tbl.lib.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 665298b49..6f7064a6b 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1039,6 +1039,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view } else { // Parse SQL if needed $parsed_sql = PMA_SQP_parse($query_base); + if (PMA_SQP_isError()) { + unset($parsed_sql); + } } // Analyze it @@ -1242,8 +1245,8 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view } echo '
' . "\n"; - // If we are in an Ajax request, we have most probably been called in - // PMA_ajaxResponse(). Hence, collect the buffer contents and return it + // If we are in an Ajax request, we have most probably been called in + // PMA_ajaxResponse(). Hence, collect the buffer contents and return it // to PMA_ajaxResponse(), which will encode it for JSON. if( $GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['buffer_message']) ) { $buffer_contents = ob_get_contents(); diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index d236b7fda..bb16bbf7f 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -2090,7 +2090,7 @@ function PMA_displayTable(&$dt_result, &$the_disp_mode, $analyzed_sql) 'submit_mult_change', __('Change'), 'b_edit.png'); PMA_buttonOrImage('submit_mult', 'mult_submit', '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', 'submit_mult_export', __('Export'), 'b_tblexport.png'); From b9609f086d55251482419fdfd22bd00915870bd4 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Mon, 30 Aug 2010 10:18:02 -0400 Subject: [PATCH 18/18] move outer variables inside function --- libraries/schema/User_Schema.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 8636d0285..54ef5d490 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -216,9 +216,6 @@ class PMA_User_Schema . ' AND pdf_page_number = \'' . PMA_sqlAddslashes($this->choosenPage) . '\''; $page_rs = PMA_query_as_controluser($page_query, FALSE, $query_default_option); $array_sh_page = array(); - $draginit = ''; - $reset_draginit = ''; - $i = 0; while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) { $array_sh_page[] = $temp_sh_page; } @@ -229,7 +226,7 @@ class PMA_User_Schema if (!isset($_POST['with_field_names']) && !isset($_POST['showwysiwyg'])) { $with_field_names = TRUE; } - $this->_displayScratchboardTables($array_sh_page,$draginit,$reset_draginit); + $this->_displayScratchboardTables($array_sh_page); ?>
@@ -464,7 +461,7 @@ class PMA_User_Schema * @return void * @access private */ - private function _displayScratchboardTables($array_sh_page,$draginit,$reset_draginit) + private function _displayScratchboardTables($array_sh_page) { global $with_field_names,$cfg,$db; ?> @@ -475,12 +472,15 @@ class PMA_User_Schema