Fix handling of 64 bit numbers in auto_increment

This commit is contained in:
Jakub Vrana 2014-11-24 18:17:43 -08:00
parent 4a4e58179f
commit 8bd53120df
8 changed files with 15 additions and 6 deletions

View file

@ -110,7 +110,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
($row["Comment"] != $table_status["Comment"] ? $row["Comment"] : null), ($row["Comment"] != $table_status["Comment"] ? $row["Comment"] : null),
($row["Engine"] && $row["Engine"] != $table_status["Engine"] ? $row["Engine"] : ""), ($row["Engine"] && $row["Engine"] != $table_status["Engine"] ? $row["Engine"] : ""),
($row["Collation"] && $row["Collation"] != $table_status["Collation"] ? $row["Collation"] : ""), ($row["Collation"] && $row["Collation"] != $table_status["Collation"] ? $row["Collation"] : ""),
($row["Auto_increment"] != "" ? +$row["Auto_increment"] : ""), ($row["Auto_increment"] != "" ? number($row["Auto_increment"]) : ""),
$partitioning $partitioning
)); ));
} }

View file

@ -430,7 +430,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
} }
function auto_increment() { function auto_increment() {
return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . (+$_POST["Auto_increment"]) . ",1)" : "") . " PRIMARY KEY"; return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . number($_POST["Auto_increment"]) . ",1)" : "") . " PRIMARY KEY";
} }
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) { function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {

View file

@ -649,7 +649,7 @@ if (!defined("DRIVER")) {
* @param string * @param string
* @param string * @param string
* @param string * @param string
* @param int * @param string number
* @param string * @param string
* @return bool * @return bool
*/ */

View file

@ -33,6 +33,14 @@ function escape_string($val) {
return substr(q($val), 1, -1); return substr(q($val), 1, -1);
} }
/** Remove non-digits from a string
* @param string
* @return string
*/
function number($val) {
return preg_replace('~[^0-9]+~', '', $val);
}
/** Disable magic_quotes_gpc /** Disable magic_quotes_gpc
* @param array e.g. (&$_GET, &$_POST, &$_COOKIE) * @param array e.g. (&$_GET, &$_POST, &$_COOKIE)
* @param bool whether to leave values as is * @param bool whether to leave values as is

View file

@ -2,7 +2,7 @@
if (support("kill") && $_POST && !$error) { if (support("kill") && $_POST && !$error) {
$killed = 0; $killed = 0;
foreach ((array) $_POST["kill"] as $val) { foreach ((array) $_POST["kill"] as $val) {
if (queries("KILL " . (+$val))) { if (queries("KILL " . number($val))) {
$killed++; $killed++;
} }
} }

View file

@ -33,7 +33,7 @@ if ($_GET["script"] == "db") {
json_row(""); json_row("");
} elseif ($_GET["script"] == "kill") { } elseif ($_GET["script"] == "kill") {
$connection->query("KILL " . (+$_POST["kill"])); $connection->query("KILL " . number($_POST["kill"]));
} else { // connect } else { // connect
foreach (count_tables($adminer->databases()) as $db => $val) { foreach (count_tables($adminer->databases()) as $db => $val) {

View file

@ -9,6 +9,7 @@ Send 403 for auth error
Report offline and other AJAX errors (bug #419) Report offline and other AJAX errors (bug #419)
Don't alter table comment if not changed Don't alter table comment if not changed
Add links to documentation on table status page Add links to documentation on table status page
Fix handling of 64 bit numbers in auto_increment
MySQL: Use utf8mb4 if available MySQL: Use utf8mb4 if available
MySQL: Support foreign keys in NDB storage MySQL: Support foreign keys in NDB storage
PostgreSQL: Materialized views PostgreSQL: Materialized views

View file

@ -1,6 +1,6 @@
<?php <?php
if ($_GET["script"] == "kill") { if ($_GET["script"] == "kill") {
$connection->query("KILL " . (+$_POST["kill"])); $connection->query("KILL " . number($_POST["kill"]));
} elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) { } elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
$limit = 11; $limit = 11;