diff --git a/ChangeLog b/ChangeLog index 657d4fb54..274660843 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,17 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-04-10 Marcel Tschopp + db_datadict.php, db_details_db_info.php, db_details_qbe.php, + db_details_structure.php, db_printview.php, left.php, main.php, + pdf_pages.php, read_dump.php, server_privileges.php, sql.php, + tbl_change.php, tbl_indexes.php, tbl_properties_structure.php, + tbl_relation.php, tbl_select.php, libraries/database_interface.lib.php, + libraries/db_table_exists.lib.php, libraries/mysql_charsets.lib.php, + libraries/relation.lib.php, libraries/dbi/mysqli.dbi.lib.php: + Changed some queries to use MYSQLI_STORE_RESULT. phpMyAdmin now works + with MYSQLI_USE_RESULT as default. + 2004-04-07 Marc Delisle * tbl_select.php, lang/*: feature 788608: new features for Search: DISTINCT, IS NULL, IS NOT NULL, NOT LIKE, multiple select for ENUM, diff --git a/db_datadict.php b/db_datadict.php index 3498b3938..b845fd60f 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -53,7 +53,7 @@ if ($cfgRelation['commwork']) { * Selects the database and gets tables names */ PMA_DBI_select_db($db); -$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); +$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $count = 0; while ($row = PMA_DBI_fetch_assoc($rowset)) { diff --git a/db_details_db_info.php b/db_details_db_info.php index 21a6ecdd6..afa7c892d 100644 --- a/db_details_db_info.php +++ b/db_details_db_info.php @@ -30,7 +30,7 @@ if ($cfg['SkipLockedTables'] == TRUE) { PMA_DBI_free_result($db_info_result); if (isset($sot_cache)) { - $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); + $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) { if (!isset($sot_cache[$tmp[0]])) { @@ -48,14 +48,14 @@ if ($cfg['SkipLockedTables'] == TRUE) { } } if (!isset($sot_ready)) { - $db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';'); + $db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) { $tables[] = $sts_tmp; } - PMA_DBI_free_result($db_info_result); - unset($db_info_result); } + @PMA_DBI_free_result($db_info_result); + unset($db_info_result); } $num_tables = (isset($tables) ? count($tables) : 0); diff --git a/db_details_qbe.php b/db_details_qbe.php index 8b2f3a718..12ab10b01 100644 --- a/db_details_qbe.php +++ b/db_details_qbe.php @@ -114,7 +114,7 @@ if ($row < 0) { /** * Prepares the form */ -$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); +$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $tbl_result_cnt = PMA_DBI_num_rows($tbl_result); $i = 0; $k = 0; diff --git a/db_details_structure.php b/db_details_structure.php index fe4c1c215..7d60b766e 100644 --- a/db_details_structure.php +++ b/db_details_structure.php @@ -76,7 +76,6 @@ if (isset($db) && isset($db_rename) && $db_rename == 'true') { $db = $newname; } } - /** * Prepares the tables list if the user where not redirected to this script * because there is no table in the database ($is_info is TRUE) @@ -243,6 +242,8 @@ else { } } // end while + PMA_DBI_free_result($result); + unset($result); } // end if if ($cfgRelation['commwork']) { diff --git a/db_printview.php b/db_printview.php index cb4679417..a94cd4e4b 100644 --- a/db_printview.php +++ b/db_printview.php @@ -45,7 +45,7 @@ if ($cfg['SkipLockedTables'] == TRUE) { unset($result); if (isset($sot_cache)) { - $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); + $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { while ($tmp = PMA_DBI_fetch_row($result)) { if (!isset($sot_cache[$tmp[0]])) { diff --git a/left.php b/left.php index 521164e9c..5d54c2d69 100644 --- a/left.php +++ b/left.php @@ -417,7 +417,7 @@ if ($num_dbs > 1) { if (!empty($db_start) && $db == $db_start) { $selected_db = $j; } - $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); + $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $common_url_query = PMA_generate_common_url($db); if ($num_tables) { @@ -641,7 +641,7 @@ if ($num_dbs > 1) { // Case where only one database has to be displayed else if ($num_dbs == 1) { $db = $dblist[0]; - $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); + $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $common_url_query = PMA_generate_common_url($db); if ($num_tables) { diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index b0a78e7e2..a6fba6eaf 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -52,7 +52,7 @@ function PMA_DBI_get_dblist($link = NULL) { } function PMA_DBI_get_tables($database, $link = NULL) { - $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';'); + $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';', NULL, PMA_DBI_QUERY_STORE); $tables = array(); while (list($current) = PMA_DBI_fetch_row($result)) { $tables[] = $current; diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index 751805e85..044091eea 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -22,7 +22,7 @@ if (!isset($is_db) || !$is_db) { if (!isset($is_table) || !$is_table) { // Not a valid table name -> back to the db_details.php if (!empty($table)) { - $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); + $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); } if (empty($table) || !($is_table && @PMA_DBI_num_rows($is_table))) { diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index f29cb9c96..47ea3dfa1 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -97,7 +97,7 @@ function PMA_DBI_try_query($query, $link = NULL, $options = 0) { } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) { $method = MYSQLI_USE_RESULT; } else { - $method = MYSQLI_STORE_RESULT; + $method = MYSQLI_USE_RESULT; } if (empty($link)) { diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index 1d5d28942..433ef654a 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -226,11 +226,9 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ function PMA_getDbCollation($db) { global $userlink; - if (PMA_MYSQL_INT_VERSION >= 40101) { // MySQL 4.1.0 does not support seperate charset settings // for databases. - $res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $row = PMA_DBI_fetch_row($res); PMA_DBI_free_result($res); diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php index 2ed64a10a..d78696924 100644 --- a/libraries/relation.lib.php +++ b/libraries/relation.lib.php @@ -104,7 +104,7 @@ function PMA_getRelationsParam($verbose = FALSE) // PMA_DBI_select_db($cfgRelation['db']); $tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']); - $tab_rs = PMA_query_as_cu($tab_query, FALSE); + $tab_rs = PMA_query_as_cu($tab_query, NULL, PMA_DBI_QUERY_STORE); while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) { if ($curr_table[0] == $cfg['Server']['bookmarktable']) { diff --git a/main.php b/main.php index 52439cf65..2ea590697 100644 --- a/main.php +++ b/main.php @@ -180,7 +180,7 @@ if ($server > 0) { // We were checking privileges with 'USE mysql' but users with the global // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql' // (even if they cannot see the tables) - $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $userlink); + $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $userlink, PMA_DBI_QUERY_STORE); if ($dbh) { $local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\''; $rs_usr = PMA_DBI_try_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); @@ -201,7 +201,7 @@ if ($server > 0) { // the first inexistant db name that we find, in most cases it's probably // the one he just dropped :) if (!$is_create_priv) { - $rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh); + $rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh, PMA_DBI_QUERY_STORE); if ($rs_usr) { $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards $re1 = '(^|[^\])(\\\)+'; // escaped wildcards @@ -221,11 +221,11 @@ if ($server > 0) { // Finally, let's try to get the user's privileges by using SHOW // GRANTS... // Maybe we'll find a little CREATE priv there :) - $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh); + $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh, PMA_DBI_QUERY_STORE); if (!$rs_usr) { // OK, now we'd have to guess the user's hostname, but we // only try out the 'username'@'%' case. - $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh); + $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh, PMA_DBI_QUERY_STORE); } unset($local_query); if ($rs_usr) { diff --git a/pdf_pages.php b/pdf_pages.php index 8bda7724e..e78c59d8d 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -221,7 +221,7 @@ if ($cfgRelation['pdfwork']) { // We will need an array of all tables in this db $selectboxall = array('--'); - $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); + $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); while ($val = @PMA_DBI_fetch_row($alltab_rs)) { $selectboxall[] = $val[0]; } diff --git a/read_dump.php b/read_dump.php index 08267ac4e..c2af81eba 100644 --- a/read_dump.php +++ b/read_dump.php @@ -346,7 +346,7 @@ if ($goto == 'tbl_properties.php') { $goto = 'db_details.php'; } else { PMA_DBI_select_db($db); - $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); + $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); if (!($is_table && @PMA_DBI_num_rows($is_table))) { $goto = 'db_details.php'; unset($table); diff --git a/server_privileges.php b/server_privileges.php index bf6968f47..70934448b 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -1175,7 +1175,7 @@ if (empty($adduser) && empty($checkprivs)) { } else { echo ' ' . "\n" . ' ' . "\n"; - if ($res = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';')) { + if ($res = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', NULL, PMA_DBI_QUERY_STORE)) { $pred_tbl_array = array(); while ($row = PMA_DBI_fetch_row($res)) { if (!isset($found_rows) || !in_array($row[0], $found_rows)) { diff --git a/sql.php b/sql.php index d9fec500a..d04d54dd2 100644 --- a/sql.php +++ b/sql.php @@ -319,7 +319,7 @@ else { list($usec, $sec) = explode(' ',microtime()); $querytime_before = ((float)$usec + (float)$sec); - $result = @PMA_DBI_try_query($full_sql_query); + $result = @PMA_DBI_try_query($full_sql_query, NULL, true); list($usec, $sec) = explode(' ',microtime()); $querytime_after = ((float)$usec + (float)$sec); @@ -563,7 +563,7 @@ else { if (!isset($table)) { $goto = 'db_details.php'; } else { - $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); + $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE); if (!($is_table && @PMA_DBI_num_rows($is_table))) { $goto = 'db_details.php'; unset($table); diff --git a/tbl_change.php b/tbl_change.php index 815d1e0f1..9a1493528 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -74,12 +74,11 @@ $url_query = PMA_generate_common_url($db, $table) require('./tbl_properties_table_info.php'); echo '
'; - /** * Get the list of the fields of the current table */ PMA_DBI_select_db($db); -$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';'); +$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE); if (isset($primary_key)) { if (is_array($primary_key)) { $primary_key_array = $primary_key; @@ -91,8 +90,9 @@ if (isset($primary_key)) { $result = array(); foreach($primary_key_array AS $rowcount => $primary_key) { $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';'; - $result[$rowcount] = PMA_DBI_query($local_query); + $result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE); $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]); + //PMA_DBI_free_result($result[$rowcount]); $primary_keys[$rowcount] = $primary_key; // No row returned diff --git a/tbl_indexes.php b/tbl_indexes.php index f4c3f84cf..f77c71373 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -37,7 +37,7 @@ if (!defined('PMA_IDX_INCLUDED')) { } // Not a valid table name -> back to the default db_details sub-page if (!empty($table)) { - $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); + $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE); } if (empty($table) || !($is_table && PMA_DBI_num_rows($is_table))) { diff --git a/tbl_properties_structure.php b/tbl_properties_structure.php index 4a8b3cc34..ba2bd4c59 100644 --- a/tbl_properties_structure.php +++ b/tbl_properties_structure.php @@ -34,7 +34,7 @@ $url_query .= '&goto=tbl_properties_structure.php&back=tbl_properties_st /** * Prepares the table structure display */ -// 1. Get table information/display tabs +// 1. Get table information/display tabs; require('./tbl_properties_table_info.php'); /** diff --git a/tbl_relation.php b/tbl_relation.php index 7c832be2d..401644f0a 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -269,7 +269,7 @@ if ($cfgRelation['relwork']) { } // [0] of the row is the name - $tab_rs = PMA_DBI_query($tab_query); + $tab_rs = PMA_DBI_query($tab_query, NULL, PMA_DBI_QUERY_STORE); $selectboxall['nix'] = '--'; $selectboxall_innodb['nix'] = '--'; diff --git a/tbl_select.php b/tbl_select.php index b60055cb6..d1181389c 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -61,7 +61,7 @@ if (!isset($param) || $param[0] == '') { $err_url = $goto . '?' . PMA_generate_common_url($db, $table); // Gets the list and number of fields - $result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';'); + $result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $fields_cnt = PMA_DBI_num_rows($result); while ($row = PMA_DBI_fetch_assoc($result)) { $fields_list[] = $row['Field'];