TIMESTAMP and NULL bugs

This commit is contained in:
Marc Delisle
2006-07-09 23:24:45 +00:00
parent 2ac5021009
commit 99576593f7
2 changed files with 25 additions and 1 deletions

View File

@@ -10,7 +10,8 @@ $Source$
* Documentation.html: Readd accidentally removed quotes. * Documentation.html: Readd accidentally removed quotes.
2006-07-09 Marc Delisle <lem9@users.sourceforge.net> 2006-07-09 Marc Delisle <lem9@users.sourceforge.net>
* tbl_printview.php: bug #1398748, print view and TIMESTAMP NULL * tbl_printview.php, db_datadict.php:
bug #1398748, print view and TIMESTAMP NULL
2006-07-09 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2006-07-09 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries/select_server.lib.php, main.php, libraries/left_header.inc.php: * libraries/select_server.lib.php, main.php, libraries/left_header.inc.php:

View File

@@ -130,6 +130,18 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
*/ */
$result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE); $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
// We need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
// and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
$show_create_table = PMA_DBI_fetch_value(
'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
// Check if we can use Relations (Mike Beck) // Check if we can use Relations (Mike Beck)
if (!empty($cfgRelation['relation'])) { if (!empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in // Find which tables are related with the current one and write it in
@@ -222,6 +234,17 @@ while ($row = PMA_DBI_fetch_assoc($rowset)) {
$row['Default'] = htmlspecialchars($row['Default']); $row['Default'] = htmlspecialchars($row['Default']);
} }
$field_name = htmlspecialchars($row['Field']); $field_name = htmlspecialchars($row['Field']);
// here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
// NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
// the latter.
// TODO: merge this logic with the one in tbl_properties_structure.php
// or move it in a function similar to PMA_DBI_get_columns_full()
// but based on SHOW CREATE TABLE because information_schema
// cannot be trusted in this case (MySQL bug)
if (!empty($analyzed_sql[0]['create_table_fields'][$field_name]['type']) && $analyzed_sql[0]['create_table_fields'][$field_name]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$field_name]['timestamp_not_null']) {
$row['Null'] = '';
}
?> ?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>"> <tr class="<?php echo $odd_row ? 'odd' : 'even'; $odd_row = ! $odd_row; ?>">
<td nowrap="nowrap"> <td nowrap="nowrap">