--- admin/xmldb/actions/check_bigints/check_bigints.class.php +++ admin/xmldb/actions/check_bigints/check_bigints.class.php @@ -31,6 +31,36 @@ class check_bigints extends XMLDBAction { + function correct_type($length) { + global $CFG; + + static $cache; + + if (isset($cache[$length])) + return $cache[$length]; + + switch ($CFG->dbfamily) { + case 'mysql': + if (10 == $length) + return ($cache[$length] = 'bigint'); + + break; + case 'postgres': + if (1 <= $length && $length <= 4) + return ($cache[$length] = 'int2'); + + if (5 <= $length && $length <= 8) + return ($cache[$length] = 'int4'); + + if (10 <= $length && $length <= 20) + return ($cache[$length] = 'int8'); + + break; + } + + return NULL; + } + /** * Init method, every subclass will have its own */ @@ -84,18 +114,6 @@ /// Here we'll acummulate all the wrong fields found $wrong_fields = array(); - /// Correct fields must be type bigint for MySQL and int8 for PostgreSQL - switch ($CFG->dbfamily) { - case 'mysql': - $correct_type = 'bigint'; - break; - case 'postgres': - $correct_type = 'int8'; - break; - default: - $correct_type = NULL; - } - /// Do the job, setting $result as needed /// Get the confirmed to decide what to do @@ -181,7 +199,7 @@ $o.='