multi-query statements

This commit is contained in:
Garvin Hicking
2003-07-29 09:58:59 +00:00
parent a8e98ef3bc
commit 914ad7ae12
8 changed files with 143 additions and 22 deletions

View File

@@ -5,6 +5,18 @@ phpMyAdmin - Changelog
$Id$
$Source$
2003-07-29 Garvin Hicking <me@supergarv.de>
* Documentation.html, config.inc.php3, read_dump.php3,
css/phpmyadmin.css.php3, libraries/common.lib.php3,
libraries/config_import.lib.php3, libraries/sqlparser.lib.php3
o Introduced $cfg['IgnoreMultiSubmitErrors'] to let PMA continue
execution of a multi-query statement even though single queries
may fail
o Introduced $cfg['VerboseMultiSubmit'] to let PMA show the result
of each query of a multi-query statement (taking some maximum
line/pieces amounts into account)
o changed formatting of syntax_comment to include some space
2003-07-29 Marc Delisle <lem9@users.sourceforge.net>
* serbian: big update,
thanks to Branislav Jovanovi<76> <branej@users.sourceforge.net> and

View File

@@ -1066,6 +1066,20 @@ $cfg['PmaAbsoluteUri'] = (!empty($_SERVER['HTTPS']) ? 'https' : 'http') . '://'
<br /><br />
</dd>
<dt><b>$cfg['IgnoreMultiSubmitErrors'] </b>boolean</dt>
<dd>
Define whether phpMyAdmin will continue executing a multi-query statement if one of the
queries fails. Default is to abort execution.
<br /><br />
</dd>
<dt><b>$cfg['VerboseMultiSubmit'] </b>boolean</dt>
<dd>
Define whether phpMyAdmin will output the results of each query of a multi-query statement
embedded into the SQL output as inline comments. Defaults to TRUE.
<br /><br />
</dd>
<dt><b>$cfg['LeftFrameLight']</b> boolean</dt>
<dd>
Defines whether to use select-based menu and display only the current

View File

@@ -188,17 +188,22 @@ unset($cfg['Servers'][0]);
/**
* Other core phpMyAdmin settings
*/
$cfg['OBGzip'] = 'auto'; // use GZIP output buffering if possible (TRUE|FALSE|'auto')
$cfg['PersistentConnections'] = FALSE; // use persistent connections to MySQL database
$cfg['ExecTimeLimit'] = 300; // maximum execution time in seconds (0 for no limit)
$cfg['SkipLockedTables'] = FALSE; // mark used tables, make possible to show
// locked tables (since MySQL 3.23.30)
$cfg['ShowSQL'] = TRUE; // show SQL queries as run
$cfg['AllowUserDropDatabase'] = FALSE; // show a 'Drop database' link to normal users
$cfg['Confirm'] = TRUE; // confirm 'DROP TABLE' & 'DROP DATABASE'
$cfg['LoginCookieRecall'] = TRUE; // recall previous login in cookie auth. mode or not
$cfg['UseDbSearch'] = TRUE; // whether to enable the "database search" feature
// or not
$cfg['OBGzip'] = 'auto'; // use GZIP output buffering if possible (TRUE|FALSE|'auto')
$cfg['PersistentConnections'] = FALSE; // use persistent connections to MySQL database
$cfg['ExecTimeLimit'] = 300; // maximum execution time in seconds (0 for no limit)
$cfg['SkipLockedTables'] = FALSE; // mark used tables, make possible to show
// locked tables (since MySQL 3.23.30)
$cfg['ShowSQL'] = TRUE; // show SQL queries as run
$cfg['AllowUserDropDatabase'] = FALSE; // show a 'Drop database' link to normal users
$cfg['Confirm'] = TRUE; // confirm 'DROP TABLE' & 'DROP DATABASE'
$cfg['LoginCookieRecall'] = TRUE; // recall previous login in cookie auth. mode or not
$cfg['UseDbSearch'] = TRUE; // whether to enable the "database search" feature
// or not
$cfg['IgnoreMultiSubmitErrors'] = FALSE; // if set to true, PMA continues computing multiple-statement queries
// even if one of the queries failed
$cfg['VerboseMultiSubmit'] = TRUE; // if set to true, PMA will show the affected rows of EACH statement on
// multiple-statement queries. See the read_dump.php3 file for hardcoded
// defaults on how many queries a statement may contain!
// Left frame setup
$cfg['LeftFrameLight'] = TRUE; // use a select-based menu and display only the

View File

@@ -221,7 +221,7 @@ button.mult_submit {
.print{font-family:arial;font-size:8pt;}
.syntax {font-family: sans-serif; font-size: <?php echo $font_smaller; ?>;}
.syntax_comment {}
.syntax_comment { padding-left: 4pt; padding-right: 4pt;}
.syntax_digit {}
.syntax_digit_hex {}
.syntax_digit_integer {}

View File

@@ -135,7 +135,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
* Includes compatibility code for older config.inc.php3 revisions
* if necessary
*/
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 195) {
if (!isset($cfg['FileRevision']) || (int) substr($cfg['FileRevision'], 13, 3) < 197) {
include('./libraries/config_import.lib.php3');
}

View File

@@ -277,6 +277,14 @@ if (!defined('PMA_CONFIG_IMPORT_LIB_INCLUDED')) {
$cfg['UseDbSearch'] = TRUE;
}
if (!isset($cfg['IgnoreMultiSubmitErrors'])) {
$cfg['IgnoreMultiSubmitErrors'] = FALSE;
}
if (!isset($cfg['VerboseMultiSubmit'])) {
$cfg['VerboseMultiSubmit'] = TRUE;
}
if (!isset($cfg['LeftFrameLight'])) {
if (isset($cfgLeftFrameLight)) {
$cfg['LeftFrameLight'] = $cfgLeftFrameLight;

View File

@@ -1660,7 +1660,7 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) {
}
break;
case 'punct_queryend':
if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi')) {
if (($typearr[3] != 'comment_mysql') && ($typearr[3] != 'comment_ansi') && $typearr[3] != 'comment_c') {
$after .= $html_line_break;
$after .= $html_line_break;
}

View File

@@ -176,15 +176,46 @@ if ($sql_query != '') {
// Copy of the cleaned sql statement for display purpose only (see near the
// beginning of "db_details.php3" & "tbl_properties.php3")
if ($sql_file != 'none' && $pieces_count > 10) {
// Be nice with bandwidth...
$sql_query_cpy = $sql_query = '';
// You can either
// * specify the amount of maximum pieces per query (having max_*_length set to 0!) or
// * specify the amount of maximum chars per query (having max_*_pieces set to 0!)
// - max_nofile_* is used for any queries submitted via copy&paste in the textarea
// - max_file_* is used for any file-submitted query
if (!$cfg['VerboseMultiSubmit']) {
// Here be the values if the Verbose-Mode (see config.inc.php3) is NOT activated
$max_nofile_length = 500;
$max_nofile_pieces = 0;
$max_file_length = 0;
$max_file_pieces = 10;
} else {
// Values for verbose-mode
$max_nofile_length = 0;
$max_nofile_pieces = 50;
$max_file_length = 0;
$max_file_pieces = 50;
}
if ($sql_file != 'none' &&
($max_file_length == 0 && ($pieces_count > $max_file_pieces))
||
($max_file_pieces == 0 && (strlen($sql_query) > $max_file_length))) {
// Be nice with bandwidth...
$sql_query_cpy = $sql_query = '';
$save_bandwidth = TRUE;
$save_bandwidth_length = $max_file_length;
$save_bandwidth_pieces = $max_file_pieces;
} else {
$sql_query_cpy = implode(";\n", $pieces) . ';';
// Be nice with bandwidth... for now, an arbitrary limit of 500,
// could be made configurable but probably not necessary
if (strlen($sql_query_cpy) > 500) {
if (($max_nofile_pieces == 0 && (strlen($sql_query_cpy) > $max_nofile_length))
|| ($max_nofile_length == 0 && $pieces_count > $max_nofile_pieces)) {
$sql_query_cpy = $sql_query = '';
$save_bandwidth = TRUE;
$save_bandwidth_length = $max_nofile_length;
$save_bandwidth_pieces = $max_nofile_pieces;
}
}
@@ -203,6 +234,9 @@ if ($sql_query != '') {
// Runs multiple queries
else if (PMA_mysql_select_db($db)) {
$mult = TRUE;
$info_msg = '';
$info_count = 0;
for ($i = 0; $i < $pieces_count; $i++) {
$a_sql_query = $pieces[$i];
if ($i == $pieces_count - 1 && eregi('^SELECT', $a_sql_query)) {
@@ -211,15 +245,56 @@ if ($sql_query != '') {
include('./sql.php3');
exit();
}
$result = PMA_mysql_query($a_sql_query);
if ($result == FALSE) { // readdump failed
$my_die = $a_sql_query;
break;
if (isset($my_die) && $cfg['IgnoreMultiSubmitErrors']) {
$my_die[] = "\n\n" . $a_sql_query;
} elseif ($cfg['IgnoreMultiSubmitErrors']) {
$my_die = array();
$my_die[] = $a_sql_query;
} else {
$my_die = $a_sql_query;
}
if ($cfg['VerboseMultiSubmit']) {
$info_msg .= $a_sql_query . '; # ' . $strError . "\n";
$info_count++;
}
if (!$cfg['IgnoreMultiSubmitErrors']) {
break;
}
} else if ($cfg['VerboseMultiSubmit']) {
$a_num_rows = (int)@mysql_num_rows($result);
$a_aff_rows = (int)@mysql_affected_rows();
if ($a_num_rows > 0) {
$a_rows = $a_num_rows;
$a_switch = $strRows . ': ';
} elseif ($a_aff_rows > 0) {
$a_rows = $a_aff_rows;
$a_switch = $strAffectedRows;;
} else {
$a_rows = '';
$a_switch = $strEmptyResultSet;
}
$info_msg .= $a_sql_query . "; # " . $a_switch . $a_rows . "\n";
$info_count++;
}
if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
$reload = 1;
}
} // end for
if ($cfg['VerboseMultiSubmit'] && strlen($info_msg) > 0 &&
((!isset($save_bandwidth) || $save_bandwidth == FALSE) ||
($save_bandwidth_pieces == 0 && strlen($sql_query) < $save_bandwidth_length) ||
($save_bandwidth_length == 0 && $info_count < $save_bandwidth_pieces))) {
$sql_query = $info_msg;
}
} // end else if
} // end if (really run the query)
unset($pieces);
@@ -233,7 +308,14 @@ if ($sql_query != '') {
if (isset($my_die)) {
$js_to_run = 'functions.js';
include('./header.inc.php3');
PMA_mysqlDie('', $my_die, '', $err_url . '&TEST');
if (is_array($my_die)) {
while(list($key, $die_string) = each($my_die)) {
PMA_mysqlDie('', $die_string, '', $err_url, FALSE);
echo '<hr />';
}
} else {
PMA_mysqlDie('', $my_die, '', $err_url, TRUE);
}
}