Skip to content

Commit

Permalink
Use PMA_DBI_get_table_indexes_sql() only when really needed, in all o…
Browse files Browse the repository at this point in the history
…ther cases use PMA_DBI_get_table_indexes()
  • Loading branch information
piotrp committed Aug 23, 2011
1 parent a31b30b commit 57bea06
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 34 deletions.
8 changes: 2 additions & 6 deletions db_datadict.php
Expand Up @@ -76,15 +76,15 @@
*/

PMA_DBI_select_db($db);
$result = PMA_DBI_query(PMA_DBI_get_table_indexes_sql($db, $table));
$indexes = PMA_DBI_get_table_indexes($db, $table);
$primary = '';
$indexes = array();
$lastIndex = '';
$indexes_info = array();
$indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table
// view
while ($row = PMA_DBI_fetch_assoc($result)) {
foreach ($indexes as $row) {
// Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', ';
Expand All @@ -111,10 +111,6 @@
}

} // end while
if ($result) {
PMA_DBI_free_result($result);
}


/**
* Gets columns properties
Expand Down
4 changes: 2 additions & 2 deletions db_qbe.php
Expand Up @@ -755,8 +755,8 @@ function showColumnSelectCell($columns, $column_number, $selected = '')
PMA_DBI_select_db($db);

foreach ($tab_all as $tab) {
$ind_rs = PMA_DBI_query(PMA_DBI_get_table_indexes_sql($db, $tab));
while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
$indexes = PMA_DBI_get_table_indexes($db, $tab);
foreach ($indexes as $ind) {
$col1 = $tab . '.' . $ind['Column_name'];
if (isset($col_all[$col1])) {
if ($ind['Non_unique'] == 0) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/Index.class.php
Expand Up @@ -157,7 +157,7 @@ static protected function _loadIndexes($table, $schema)
return true;
}

$_raw_indexes = PMA_DBI_fetch_result(PMA_DBI_get_table_indexes_sql($schema, $table));
$_raw_indexes = PMA_DBI_get_table_indexes($schema, $table);
foreach ($_raw_indexes as $_each_index) {
$_each_index['Schema'] = $schema;
if (! isset(PMA_Index::$_registry[$schema][$table][$_each_index['Key_name']])) {
Expand Down
3 changes: 0 additions & 3 deletions libraries/Tracker.class.php
Expand Up @@ -259,9 +259,6 @@ static public function createVersion($dbname, $tablename, $version, $tracking_se
}

$indexes = PMA_DBI_get_table_indexes($dbname, $tablename);
if (!$indexes) {
$indexes = array();
}

$snapshot = array('COLUMNS' => $columns, 'INDEXES' => $indexes);
$snapshot = serialize($snapshot);
Expand Down
4 changes: 2 additions & 2 deletions libraries/database_interface.lib.php
Expand Up @@ -1104,7 +1104,7 @@ function PMA_DBI_get_table_indexes_sql($database, $table, $where = null)
}

/**
* array PMA_DBI_get_table_indexes($database, $table, $link = null)
* Returns indexes od a table
*
* @param string $database name of database
* @param string $table name of the table whose indexes are to be retreived
Expand All @@ -1117,7 +1117,7 @@ function PMA_DBI_get_table_indexes($database, $table, $link = null)
$indexes = PMA_DBI_fetch_result($sql, null, null, $link);

if (! is_array($indexes) || count($indexes) < 1) {
return false;
return array();
}
return $indexes;
}
Expand Down
8 changes: 3 additions & 5 deletions libraries/export/htmlword.php
Expand Up @@ -199,15 +199,13 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/**
* Get the unique keys in the table
*/
$keys_query = PMA_DBI_get_table_indexes_sql($db, $table);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);

/**
* Gets fields properties
Expand Down
8 changes: 3 additions & 5 deletions libraries/export/latex.php
Expand Up @@ -302,15 +302,13 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/**
* Get the unique keys in the table
*/
$keys_query = PMA_DBI_get_table_indexes_sql($db, $table);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);

/**
* Gets fields properties
Expand Down
8 changes: 3 additions & 5 deletions libraries/export/odt.php
Expand Up @@ -237,15 +237,13 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/**
* Get the unique keys in the table
*/
$keys_query = PMA_DBI_get_table_indexes_sql($db, $table);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);

/**
* Gets fields properties
Expand Down
8 changes: 3 additions & 5 deletions libraries/export/texytext.php
Expand Up @@ -181,15 +181,13 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/**
* Get the unique keys in the table
*/
$keys_query = PMA_DBI_get_table_indexes_sql($db, $table);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);

/**
* Gets fields properties
Expand Down

0 comments on commit 57bea06

Please sign in to comment.