Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 758ec7b

Browse files
committed
Performance improvements: Avoid expensive PMA_Table::analyzeStructure() call
Signed-off-by: Madhura Jayaratne <[email protected]>
1 parent 739b142 commit 758ec7b

3 files changed

Lines changed: 9 additions & 17 deletions

File tree

libraries/Util.class.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,7 +3839,7 @@ public static function getDefaultFunctionForField($field, $insert_mode)
38393839
* @todo Except for $cfg, no longer use globals but pass as parameters
38403840
* from higher levels
38413841
*/
3842-
global $cfg, $analyzed_sql, $data;
3842+
global $cfg, $data;
38433843

38443844
$default_function = '';
38453845

@@ -3852,8 +3852,6 @@ public static function getDefaultFunctionForField($field, $insert_mode)
38523852
}
38533853
}
38543854

3855-
$analyzed_sql_field_array = $analyzed_sql[0]['create_table_fields']
3856-
[$field['Field']];
38573855
// what function defined as default?
38583856
// for the first timestamp we don't set the default function
38593857
// if there is a default value for the timestamp
@@ -3864,9 +3862,8 @@ public static function getDefaultFunctionForField($field, $insert_mode)
38643862
&& $field['first_timestamp']
38653863
&& empty($field['Default'])
38663864
&& empty($data)
3867-
&& ! isset($analyzed_sql_field_array['on_update_current_timestamp'])
3868-
&& ! (isset($analyzed_sql_field_array['default_value'])
3869-
&& $analyzed_sql_field_array['default_value'] == 'NULL')
3865+
&& $field['Extra'] != 'on update CURRENT_TIMESTAMP'
3866+
&& $field['Null'] == 'NO'
38703867
) {
38713868
$default_function = $cfg['DefaultFunctions']['first_timestamp'];
38723869
}

libraries/insert_edit.lib.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,6 @@ function PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload)
26322632
*
26332633
* @param array $table_columns table columns
26342634
* @param int $i row counter
2635-
* @param array $column column
26362635
* @param array $comments_map comments map
26372636
* @param bool $timestamp_seen whether timestamp seen
26382637
* @param array $current_result current result
@@ -2664,16 +2663,16 @@ function PMA_getHtmlForInsertEditFormHeader($has_blob_field, $is_upload)
26642663
*
26652664
* @return string
26662665
*/
2667-
function PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column,
2666+
function PMA_getHtmlForInsertEditFormColumn($table_columns, $i,
26682667
$comments_map, $timestamp_seen, $current_result, $chg_evt_handler,
26692668
$jsvkey, $vkey, $insert_mode, $current_row, $odd_row, &$o_rows,
26702669
&$tabindex, $columns_cnt, $is_upload, $tabindex_for_function,
26712670
$foreigners, $tabindex_for_null, $tabindex_for_value, $table, $db,
26722671
$row_id, $titles, $biggest_max_file_size, $default_char_editing,
26732672
$text_dir, $repopulate, $column_mime, $where_clause
26742673
) {
2675-
if (! isset($table_columns[$i]['processed'])) {
2676-
$column = $table_columns[$i];
2674+
$column = $table_columns[$i];
2675+
if (! isset($column['processed'])) {
26772676
$column = PMA_analyzeTableColumnsArray(
26782677
$column, $comments_map, $timestamp_seen
26792678
);
@@ -2860,7 +2859,6 @@ function PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column,
28602859
*
28612860
* @param array $url_params url parameters
28622861
* @param array $table_columns table columns
2863-
* @param array $column column
28642862
* @param array $comments_map comments map
28652863
* @param bool $timestamp_seen whether timestamp seen
28662864
* @param array $current_result current result
@@ -2889,7 +2887,7 @@ function PMA_getHtmlForInsertEditFormColumn($table_columns, $i, $column,
28892887
* @return string
28902888
*/
28912889
function PMA_getHtmlForInsertEditRow($url_params, $table_columns,
2892-
$column, $comments_map, $timestamp_seen, $current_result, $chg_evt_handler,
2890+
$comments_map, $timestamp_seen, $current_result, $chg_evt_handler,
28932891
$jsvkey, $vkey, $insert_mode, $current_row, &$o_rows, &$tabindex, $columns_cnt,
28942892
$is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,
28952893
$tabindex_for_value, $table, $db, $row_id, $titles,
@@ -2912,7 +2910,7 @@ function PMA_getHtmlForInsertEditRow($url_params, $table_columns,
29122910
$column_mime = $mime_map[$table_columns[$i]['Field']];
29132911
}
29142912
$html_output .= PMA_getHtmlForInsertEditFormColumn(
2915-
$table_columns, $i, $column, $comments_map, $timestamp_seen,
2913+
$table_columns, $i, $comments_map, $timestamp_seen,
29162914
$current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
29172915
$current_row, $odd_row, $o_rows, $tabindex, $columns_cnt, $is_upload,
29182916
$tabindex_for_function, $foreigners, $tabindex_for_null,

tbl_change.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,6 @@
9393
$response->addHTML(PMA_Util::getMessage($disp_message, null));
9494
}
9595

96-
// used as a global by PMA_Util::getDefaultFunctionForField()
97-
$analyzed_sql = PMA_Table::analyzeStructure($db, $table);
98-
9996
$table_columns = PMA_getTableColumns($db, $table);
10097

10198
// retrieve keys into foreign fields, if any
@@ -194,7 +191,7 @@
194191
}
195192

196193
$html_output .= PMA_getHtmlForInsertEditRow(
197-
$url_params, $table_columns, $column, $comments_map, $timestamp_seen,
194+
$url_params, $table_columns, $comments_map, $timestamp_seen,
198195
$current_result, $chg_evt_handler, $jsvkey, $vkey, $insert_mode,
199196
$current_row, $o_rows, $tabindex, $columns_cnt,
200197
$is_upload, $tabindex_for_function, $foreigners, $tabindex_for_null,

0 commit comments

Comments
 (0)