Skip to content

Commit

Permalink
Shorten varchar fields
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed Sep 22, 2012
1 parent 996bfc3 commit b684569
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions adminer/include/functions.inc.php
Expand Up @@ -902,6 +902,14 @@ function is_url($string) {
return (preg_match("~^(https?)://($domain?\\.)+$domain(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string, $match) ? strtolower($match[1]) : ""); //! restrict path, query and fragment characters return (preg_match("~^(https?)://($domain?\\.)+$domain(:\\d+)?(/.*)?(\\?.*)?(#.*)?\$~i", $string, $match) ? strtolower($match[1]) : ""); //! restrict path, query and fragment characters
} }


/** Check if field should be shortened
* @param array
* @return bool
*/
function is_shortable($field) {
return ereg('char|text|lob|geometry|point|linestring|polygon', $field["type"]);
}

/** Run query which can be killed by AJAX call after timing out /** Run query which can be killed by AJAX call after timing out
* @param string * @param string
* @return Min_Result * @return Min_Result
Expand Down
4 changes: 2 additions & 2 deletions adminer/select.inc.php
Expand Up @@ -18,7 +18,7 @@
$name = $adminer->fieldName($field); $name = $adminer->fieldName($field);
if (isset($field["privileges"]["select"]) && $name != "") { if (isset($field["privileges"]["select"]) && $name != "") {
$columns[$key] = html_entity_decode(strip_tags($name)); $columns[$key] = html_entity_decode(strip_tags($name));
if (ereg('text|lob|geometry|point|linestring|polygon', $field["type"])) { if (is_shortable($field)) {
$text_length = $adminer->selectLengthProcess(); $text_length = $adminer->selectLengthProcess();
} }
} }
Expand Down Expand Up @@ -350,7 +350,7 @@
if ($val === "") { // === - may be int if ($val === "") { // === - may be int
$val = " "; $val = " ";
} elseif (is_utf8($val)) { } elseif (is_utf8($val)) {
if ($text_length != "" && ereg('text|lob|geometry|point|linestring|polygon', $field["type"])) { if ($text_length != "" && is_shortable($field)) {
$val = shorten_utf8($val, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network $val = shorten_utf8($val, max(0, +$text_length)); // usage of LEFT() would reduce traffic but complicate query - expected average speedup: .001 s VS .01 s on local network
} else { } else {
$val = h($val); $val = h($val);
Expand Down
1 change: 1 addition & 0 deletions changes.txt
@@ -1,4 +1,5 @@
Adminer 3.6.2-dev: Adminer 3.6.2-dev:
Shorten varchar fields
Fix switching language on first load Fix switching language on first load


Adminer 3.6.1 (released 2012-09-17): Adminer 3.6.1 (released 2012-09-17):
Expand Down

0 comments on commit b684569

Please sign in to comment.