bug #1163595, NULL detection for TIMESTAMP

This commit is contained in:
Marc Delisle
2005-05-22 12:43:46 +00:00
parent fa0ff4acd5
commit fe8cd66697
4 changed files with 31 additions and 2 deletions

View File

@@ -8,6 +8,8 @@ $Source$
2005-05-22 Marc Delisle <lem9@users.sourceforge.net> 2005-05-22 Marc Delisle <lem9@users.sourceforge.net>
* libraries/charset_conversion.lib.php: diacritics wrongly converted * libraries/charset_conversion.lib.php: diacritics wrongly converted
in Browse mode under MySQL 4.1.x if AllowAnywhereRecoding set to TRUE in Browse mode under MySQL 4.1.x if AllowAnywhereRecoding set to TRUE
* tbl_properties_structure.php, tbl_properties.inc.php,
libraries/sqlparser.lib.php: bug #1163595, NULL detection of TIMESTAMP
2005-05-19 Marc Delisle <lem9@users.sourceforge.net> 2005-05-19 Marc Delisle <lem9@users.sourceforge.net>
* tbl_select.php: bug #1204235, searching on a VARBINARY field * tbl_select.php: bug #1204235, searching on a VARBINARY field

View File

@@ -802,10 +802,14 @@ if ($is_minimum_common == FALSE) {
* For now, mostly used to detect the DEFAULT CURRENT_TIMESTAMP and * For now, mostly used to detect the DEFAULT CURRENT_TIMESTAMP and
* ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query. * ON UPDATE CURRENT_TIMESTAMP clauses of the CREATE TABLE query.
* An array, each element is the identifier name. * An array, each element is the identifier name.
* Note that for now, the timestamp_not_null element is created
* even for non-TIMESTAMP fields.
*
* Sub-elements: ['type'] which contains the column type * Sub-elements: ['type'] which contains the column type
* optional (currently they are never false but can be absent): * optional (currently they are never false but can be absent):
* ['default_current_timestamp'] boolean * ['default_current_timestamp'] boolean
* ['on_update_current_timestamp'] boolean * ['on_update_current_timestamp'] boolean
* ['timestamp_not_null'] boolean
* *
* section_before_limit, section_after_limit * section_before_limit, section_after_limit
* ----------------------------------------- * -----------------------------------------
@@ -1560,6 +1564,11 @@ if ($is_minimum_common == FALSE) {
if ($arr[$i]['type'] == 'alpha_reservedWord') { if ($arr[$i]['type'] == 'alpha_reservedWord') {
$upper_data = strtoupper($arr[$i]['data']); $upper_data = strtoupper($arr[$i]['data']);
if ($upper_data == 'NOT' && $in_timestamp_options) {
$create_table_fields[$current_identifier]['timestamp_not_null'] = TRUE;
}
if ($upper_data == 'CREATE') { if ($upper_data == 'CREATE') {
$seen_create = TRUE; $seen_create = TRUE;
} }
@@ -1707,6 +1716,8 @@ if ($is_minimum_common == FALSE) {
if ($seen_create_table && $in_create_table_fields) { if ($seen_create_table && $in_create_table_fields) {
$current_identifier = $identifier; $current_identifier = $identifier;
// warning: we set this one even for non TIMESTAMP type
$create_table_fields[$current_identifier]['timestamp_not_null'] = FALSE;
} }
if ($seen_constraint) { if ($seen_constraint) {

View File

@@ -2,7 +2,7 @@
/* $Id$ */ /* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
// Check parameters // Check parameters
error_reporting(E_ALL);
require_once('./libraries/common.lib.php'); require_once('./libraries/common.lib.php');
PMA_checkParameters(array('db','table','action','num_fields')); PMA_checkParameters(array('db','table','action','num_fields'));
@@ -342,6 +342,14 @@ for ($i = 0 ; $i < $num_fields; $i++) {
$attribute = $submit_attribute; $attribute = $submit_attribute;
} }
// 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.
if ($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == TRUE) {
$row['Null'] = '';
}
// MySQL 4.1.2+ TIMESTAMP options // MySQL 4.1.2+ TIMESTAMP options
// (if on_update_current_timestamp is set, then it's TRUE) // (if on_update_current_timestamp is set, then it's TRUE)
if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) { if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {

View File

@@ -198,7 +198,7 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$zerofill = stristr($row['Type'], 'zerofill'); $zerofill = stristr($row['Type'], 'zerofill');
} }
// rabus: Devide charset from the rest of the type definition (MySQL >= 4.1) // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
unset($field_charset); unset($field_charset);
if (PMA_MYSQL_INT_VERSION >= 40100) { if (PMA_MYSQL_INT_VERSION >= 40100) {
if ((substr($type, 0, 4) == 'char' if ((substr($type, 0, 4) == 'char'
@@ -247,6 +247,14 @@ while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$attribute = 'ON UPDATE CURRENT_TIMESTAMP'; $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
} }
// 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.
if ($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
$row['Null'] = '';
}
if (!isset($row['Default'])) { if (!isset($row['Default'])) {
if ($row['Null'] == 'YES') { if ($row['Null'] == 'YES') {
$row['Default'] = '<i>NULL</i>'; $row['Default'] = '<i>NULL</i>';