diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 1ee22deb..4e8b6c38 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -828,11 +828,16 @@ if (!defined("DRIVER")) { /** Get SQL command to create table * @param string + * @param bool * @return string */ - function create_sql($table) { + function create_sql($table, $auto_increment) { global $connection; - return $connection->result("SHOW CREATE TABLE " . table($table), 1); + $return = $connection->result("SHOW CREATE TABLE " . table($table), 1); + if (!$auto_increment) { + $return = preg_replace('~ AUTO_INCREMENT=[0-9]+~', '', $return); //! skip comments + } + return $return; } /** Get SQL command to truncate table diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index f6849576..86a6fa1f 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -521,9 +521,12 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { return true; } - function create_sql($table) { + function create_sql($table, $auto_increment) { global $connection; - return $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table)); + return ($auto_increment || $table != "sqlite_sequence" //! remove also INSERT + ? $connection->result("SELECT sql FROM sqlite_master WHERE type = 'table' AND name = " . $connection->quote($table)) + : "" + ); } function truncate_sql($table) { diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index 75c094b7..53acc091 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -175,6 +175,7 @@ echo ($jush == "sqlite" ? "" : "" . lang('Database') . "" . html_sel . (support("event") ? checkbox("events", 1, $checked, lang('Events')) : "") ); echo "" . lang('Tables') . "" . html_select('table_style', $table_style, $row["table_style"]) + . checkbox("auto_increment", 1, $row["table_style"], lang('Auto Increment')) . (support("trigger") ? checkbox("triggers", 1, $row["table_style"], lang('Triggers')) : "") ; echo "" . lang('Data') . "" . html_select('data_style', $data_style, $row["data_style"]); diff --git a/adminer/include/export.inc.php b/adminer/include/export.inc.php index 7c449529..74d6c8b4 100644 --- a/adminer/include/export.inc.php +++ b/adminer/include/export.inc.php @@ -17,7 +17,7 @@ function dump_table($table, $style, $is_view = false) { dump_csv(array_keys(fields($table))); } } elseif ($style) { - $create = create_sql($table); + $create = create_sql($table, $_POST["auto_increment"]); if ($create) { if ($style == "DROP+CREATE") { echo "DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . table($table) . ";\n"; diff --git a/changes.txt b/changes.txt index 97d4c43d..68d45259 100644 --- a/changes.txt +++ b/changes.txt @@ -12,6 +12,7 @@ Schemas, sequences and types support (PostgreSQL) Autofocus username in login form Disable spellchecking in SQL textareas Display auto_increment value of inserted item +Allow disabling auto_increment value export Link table names in SQL queries Japanese translation Defer table information in database overview to JavaScript (performance)