diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index 8cca2c7d..868deb78 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -233,23 +233,22 @@ username.form['auth[driver]'].onchange();
foreach ($indexes as $i => $index) {
if ($index["type"] == "FULLTEXT") {
echo "(" . implode(", ", array_map('h', $index["columns"])) . ") AGAINST";
- echo " ";
+ echo " ";
echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL");
echo "
\n";
}
}
- $i = 0;
- foreach ((array) $_GET["where"] as $val) {
- if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) {
- echo "
";
- echo html_select("where[$i][op]", $this->operators, $val["op"]);
- echo "
\n";
- $i++;
+ $_GET["where"] = (array) $_GET["where"];
+ reset($_GET["where"]);
+ $change_next = "this.nextSibling.onchange();";
+ for ($i = 0; $i <= count($_GET["where"]); $i++) {
+ list(, $val) = each($_GET["where"]);
+ if (!$val || ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators))) {
+ echo "";
+ echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next);
+ echo "
\n";
}
}
- echo "";
- echo html_select("where[$i][op]", $this->operators, "=");
- echo "
\n";
echo "\n";
}
@@ -264,7 +263,7 @@ username.form['auth[driver]'].onchange();
$i = 0;
foreach ((array) $_GET["order"] as $key => $val) {
if (isset($columns[$val])) {
- echo "";
+ echo "
";
echo checkbox("desc[$i]", 1, isset($_GET["desc"][$key]), lang('descending')) . "
\n";
$i++;
}
@@ -297,11 +296,28 @@ username.form['auth[driver]'].onchange();
}
/** Print action box in select
+ * @param array
* @return null
*/
- function selectActionPrint() {
+ function selectActionPrint($indexes) {
echo "
\n";
}
diff --git a/adminer/lang/cs.inc.php b/adminer/lang/cs.inc.php
index b9f6e956..26f73d57 100644
--- a/adminer/lang/cs.inc.php
+++ b/adminer/lang/cs.inc.php
@@ -227,6 +227,7 @@ $translations = array(
'Limit' => 'Limit',
'Text length' => 'Délka textů',
'Action' => 'Akce',
+ 'Full table scan' => 'Průchod celé tabulky',
'Unable to select the table' => 'Nepodařilo se vypsat tabulku',
'No rows.' => 'Žádné řádky.',
'%d row(s)' => array('%d řádek', '%d řádky', '%d řádků'),
diff --git a/adminer/lang/xx.inc.php b/adminer/lang/xx.inc.php
index 15b795a7..eefb9991 100644
--- a/adminer/lang/xx.inc.php
+++ b/adminer/lang/xx.inc.php
@@ -227,6 +227,7 @@ $translations = array(
'Limit' => 'xx',
'Text length' => 'xx',
'Action' => 'xx',
+ 'Full table scan' => 'xx',
'Unable to select the table' => 'xx',
'No rows.' => 'xx',
'%d row(s)' => array('xx', 'xx'),
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index c98fc2de..1e239faf 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -209,7 +209,7 @@ if (!$columns) {
$adminer->selectOrderPrint($order, $columns, $indexes);
$adminer->selectLimitPrint($limit);
$adminer->selectLengthPrint($text_length);
- $adminer->selectActionPrint();
+ $adminer->selectActionPrint($indexes);
echo "\n";
$page = $_GET["page"];
diff --git a/adminer/static/functions.js b/adminer/static/functions.js
index 455b4989..6933bd52 100644
--- a/adminer/static/functions.js
+++ b/adminer/static/functions.js
@@ -167,7 +167,10 @@ function pageClick(href, page, event) {
* @param HTMLSelectElement
*/
function selectAddRow(field) {
- field.onchange = function () { };
+ field.onchange = function () {
+ selectFieldChange(field.form);
+ };
+ field.onchange();
var row = field.parentNode.cloneNode(true);
var selects = row.getElementsByTagName('select');
for (var i=0; i < selects.length; i++) {
@@ -183,7 +186,44 @@ function selectAddRow(field) {
field.parentNode.parentNode.appendChild(row);
}
-
+/** Check whether the query will be executed with index
+* @param HTMLFormElement
+*/
+function selectFieldChange(form) {
+ var ok = (function () {
+ var inputs = form.getElementsByTagName('input');
+ for (var i=0; i < inputs.length; i++) {
+ var input = inputs[i];
+ if (/^fulltext/.test(input.name) && input.value) {
+ return true;
+ }
+ }
+ var ok = true;
+ var selects = form.getElementsByTagName('select');
+ for (var i=0; i < selects.length; i++) {
+ var select = selects[i];
+ var col = selectValue(select);
+ var match = /^(where.+)col\]/.exec(select.name);
+ if (match) {
+ var op = selectValue(form[match[1] + 'op]']);
+ var val = form[match[1] + 'val]'].value;
+ if (col in indexColumns && (!/LIKE|REGEXP/.test(op) || (op == 'LIKE' && val.charAt(0) != '%'))) {
+ return true;
+ } else if (col || val) {
+ ok = false;
+ }
+ }
+ if (col && /^order/.test(select.name)) {
+ if (!(col in indexColumns)) {
+ ok = false;
+ }
+ break;
+ }
+ }
+ return ok;
+ })();
+ setHtml('noindex', (ok ? '' : '!'));
+}
diff --git a/changes.txt b/changes.txt
index bff4c4b8..9dd4d3c8 100644
--- a/changes.txt
+++ b/changes.txt
@@ -2,6 +2,7 @@ Adminer 3.4.0-dev:
Print current time next to executed SQL queries
Highlight code in SQL command by CodeMirror
Link to descending order
+Warn about selecting data without index
Allow specifying database in login form
Link to original table in EXPLAIN of SELECT * FROM table t
MySQL: inform about disabled event_scheduler
diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php
index 4e886177..1fc41574 100644
--- a/editor/include/adminer.inc.php
+++ b/editor/include/adminer.inc.php
@@ -271,7 +271,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
function selectLengthPrint($text_length) {
}
- function selectActionPrint() {
+ function selectActionPrint($indexes) {
echo "
\n";