From e9d628150dd7d09062f087cd2f972c425d44d2c9 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Sun, 9 Jul 2006 13:33:45 +0000 Subject: [PATCH] bug #1398748, print view and TIMESTAMP NULL --- ChangeLog | 3 +++ tbl_printview.php | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 636e92e08..7dc3e1a8d 100755 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ $Id$ $Source$ +2006-07-09 Marc Delisle + * tbl_printview.php: bug #1398748, print view and TIMESTAMP NULL + 2006-07-09 Sebastian Mendel * libraries/select_server.lib.php, main.php, libraries/left_header.inc.php: move server selection in main to the 'right' (below 'phpMyAdmin') diff --git a/tbl_printview.php b/tbl_printview.php index 275c4c6cd..b4e913210 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -109,6 +109,17 @@ foreach ($the_tables as $key => $table) { PMA_DBI_QUERY_STORE); $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/bug.php?id=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) if (!empty($cfgRelation['relation'])) { // Find which tables are related with the current one and write it in @@ -204,6 +215,17 @@ foreach ($the_tables as $key => $table) { $row['Default'] = htmlspecialchars($row['Default']); } $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'] = ''; + } ?>