sql.php3, libraries/common.lib.php3, libraries/sqlparser.lib.php3: Revert line 88 of sql.php3, and fix it a different way...

This commit is contained in:
Robin Johnson
2003-01-13 23:19:53 +00:00
parent 19923ff837
commit e545478659
4 changed files with 70 additions and 14 deletions

View File

@@ -9,6 +9,8 @@ $Source$
* libraries/sqlvalidator.class.php3:
- Removed dependency on overload extension
- Started to fix bug #644709
* sql.php3, libraries/common.lib.php3, libraries/sqlparser.lib.php3:
- Revert line 88 of sql.php3, and fix it a different way...
2002-01-12 Robin Johnson <robbat2@users.sourceforge.net>
* read_dump.php3, sql.php3, libraries/common.lib.php3,

View File

@@ -277,6 +277,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// Check that we actually have a valid set of parsed data
// well, not quite
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return $parsed_sql;
}
// then check for an array
if (!is_array($parsed_sql)) {
// We don't so just return the input directly
// This is intended to be used for when the SQL Parser is turned off
@@ -323,8 +328,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
$is_modify_link = TRUE, $back_url = '')
{
global $cfg;
global $SQP_errorString;
if (empty($GLOBALS['is_header_sent'])) {
include('./header.inc.php3');
}
@@ -338,7 +342,8 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
if (isset($SQP_errorString) && !empty($SQP_errorString)) {
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (PMA_SQP_isError()) {
$parsed_sql = $the_query;
} else {
$parsed_sql = PMA_SQP_parse($the_query);
@@ -352,9 +357,9 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
if (isset($SQP_errorString) && !empty($SQP_errorString)) {
flush();
echo $SQP_errorString;
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
if (PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
echo '<p>' . "\n";

View File

@@ -72,23 +72,62 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
/**
* Do display an error message
* Reset the error variable for the SQL parser
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_resetError() {
global $SQP_errorString;
$SQP_errorString = '';
unset($SQP_errorString);
}
/**
* Get the contents of the error variable for the SQL parser
*
* @return string Error string from SQL parser
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_getErrorString() {
global $SQP_errorString;
return isset($SQP_errorString) ? $SQP_errorString : '';
}
/**
* Check if the SQL parser hit an error
*
* @return boolean error state
*
* @access public
*/
// Added, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_isError() {
global $SQP_errorString;
return isset($SQP_errorString) && !empty($SQP_errorString);
}
/**
* Set an error message for the system
*
* @param string The error message
* @param string The failing SQL query
*
* @access public
* @access private
* @scope SQL Parser internal
*/
// Revised, Robbat2 - 13 Janurary 2003, 2:59PM
function PMA_SQP_throwError($message, $sql)
{
$debugstr = 'ERROR: ' . $message . "\n";
$debugstr .= 'SQL: ' . $sql;
global $SQP_errorString;
$SQP_errorString = '<p>'.$GLOBALS['strSQLParserUserError'] . '</p>' . "\n"
. '<pre>' . "\n"
. $debugstr . "\n"
. '</pre>' . "\n";
. '<pre>' . "\n"
. 'ERROR: ' . $message . "\n"
. 'SQL: ' . $sql . "\n"
. '</pre>' . "\n";
/*
// Removed to solve bug #641765 - Robbat2 - 12 January 2003, 9:46PM
@@ -1119,6 +1158,15 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
*/
function PMA_SQP_formatHtml($arr, $mode='color')
{
// first check for the SQL parser having hit an error
if (PMA_SQP_isError()) {
return $arr;
}
// then check for an array
if (!is_array($arr)) {
return $arr;
}
// else do it properly
switch ($mode) {
case 'color':
$str = '<span class="syntax">';

View File

@@ -86,7 +86,8 @@ if (isset($btnDrop) || isset($navig)) {
$parsed_sql = PMA_SQP_parse((get_magic_quotes_gpc() ? stripslashes($sql_query) : $sql_query));
$analyzed_sql = PMA_SQP_analyze($parsed_sql);
// Bug #641765 - Robbat2 - 12 January 2003, 10:49PM
//$sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// Reverted - Robbat2 - 13 January 2003, 2:40PM
$sql_query = PMA_SQP_formatHtml($parsed_sql, 'query_only');
// here we are sure that SELECT is uppercase
$is_select = eregi('^SELECT[[:space:]]+', $sql_query);