MySQL: Support geometry data types
This commit is contained in:
parent
31a608e398
commit
d5400234f0
|
@ -591,6 +591,13 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
|||
return array();
|
||||
}
|
||||
|
||||
function convert_field($field) {
|
||||
}
|
||||
|
||||
function unconvert_field($field, $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function support($feature) {
|
||||
return ereg('^(scheme|trigger|view|drop_col)$', $feature); //! routine|
|
||||
}
|
||||
|
|
|
@ -946,6 +946,34 @@ if (!defined("DRIVER")) {
|
|||
return get_key_vals("SHOW STATUS");
|
||||
}
|
||||
|
||||
/** Convert field in select and edit
|
||||
* @param array one element from fields()
|
||||
* @return string
|
||||
*/
|
||||
function convert_field($field) {
|
||||
if (ereg("binary", $field["type"])) {
|
||||
return "HEX(" . idf_escape($field["field"]) . ")";
|
||||
}
|
||||
if (ereg("geometry|point|linestring|polygon", $field["type"])) {
|
||||
return "AsWKT(" . idf_escape($field["field"]) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert value in edit after applying functions back
|
||||
* @param array one element from fields()
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function unconvert_field($field, $return) {
|
||||
if (ereg("binary", $field["type"])) {
|
||||
$return = "unhex($return)";
|
||||
}
|
||||
if (ereg("geometry|point|linestring|polygon", $field["type"])) {
|
||||
$return = "GeomFromText($return)";
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Check whether a feature is supported
|
||||
* @param string "comment", "copy", "drop_col", "dump", "event", "kill", "partitioning", "privileges", "procedure", "processlist", "routine", "scheme", "sequence", "status", "trigger", "type", "variables", "view"
|
||||
* @return bool
|
||||
|
@ -962,8 +990,9 @@ if (!defined("DRIVER")) {
|
|||
lang('Numbers') => array("tinyint" => 3, "smallint" => 5, "mediumint" => 8, "int" => 10, "bigint" => 20, "decimal" => 66, "float" => 12, "double" => 21),
|
||||
lang('Date and time') => array("date" => 10, "datetime" => 19, "timestamp" => 19, "time" => 10, "year" => 4),
|
||||
lang('Strings') => array("char" => 255, "varchar" => 65535, "tinytext" => 255, "text" => 65535, "mediumtext" => 16777215, "longtext" => 4294967295),
|
||||
lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),
|
||||
lang('Lists') => array("enum" => 65535, "set" => 64),
|
||||
lang('Binary') => array("bit" => 20, "binary" => 255, "varbinary" => 65535, "tinyblob" => 255, "blob" => 65535, "mediumblob" => 16777215, "longblob" => 4294967295),
|
||||
lang('Geometry') => array("geometry" => 0, "point" => 0, "linestring" => 0, "polygon" => 0, "multipoint" => 0, "multilinestring" => 0, "multipolygon" => 0, "geometrycollection" => 0),
|
||||
) as $key => $val) {
|
||||
$types += $val;
|
||||
$structured_types[$key] = array_keys($val);
|
||||
|
@ -978,7 +1007,7 @@ if (!defined("DRIVER")) {
|
|||
"binary" => "md5/sha1",
|
||||
"date|time" => "now",
|
||||
), array(
|
||||
"int|float|double|decimal" => "+/-",
|
||||
"(^|[^o])int|float|double|decimal" => "+/-", // not point
|
||||
"date" => "+ interval/- interval",
|
||||
"time" => "addtime/subtime",
|
||||
"char|text" => "concat",
|
||||
|
|
|
@ -361,6 +361,13 @@ ORDER BY PROCESS
|
|||
return reset($rows);
|
||||
}
|
||||
|
||||
function convert_field($field) {
|
||||
}
|
||||
|
||||
function unconvert_field($field, $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function support($feature) {
|
||||
return ereg("view|scheme|processlist|drop_col|variables|status", $feature); //!
|
||||
}
|
||||
|
|
|
@ -580,6 +580,13 @@ AND typelem = 0"
|
|||
function show_status() {
|
||||
}
|
||||
|
||||
function convert_field($field) {
|
||||
}
|
||||
|
||||
function unconvert_field($field, $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function support($feature) {
|
||||
return ereg('^(comment|view|scheme|processlist|sequence|trigger|type|variables|drop_col)$', $feature); //! routine|
|
||||
}
|
||||
|
|
|
@ -643,6 +643,13 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function convert_field($field) {
|
||||
}
|
||||
|
||||
function unconvert_field($field, $return) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
function support($feature) {
|
||||
return ereg('^(view|trigger|variables|status|dump|move_col|drop_col)$', $feature);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,14 @@ if ($_POST["save"]) {
|
|||
$select = array();
|
||||
foreach ($fields as $name => $field) {
|
||||
if (isset($field["privileges"]["select"])) {
|
||||
$select[] = ($_POST["clone"] && $field["auto_increment"] ? "'' AS " : ($jush == "sql" && ereg("enum|set", $field["type"]) ? "1*" . idf_escape($name) . " AS " : "")) . idf_escape($name);
|
||||
$as = convert_field($field);
|
||||
if ($_POST["clone"] && $field["auto_increment"]) {
|
||||
$as = "''";
|
||||
}
|
||||
if ($jush == "sql" && ereg("enum|set", $field["type"])) {
|
||||
$as = "1*" . idf_escape($name);
|
||||
}
|
||||
$select[] = ($as ? "$as AS " : "") . idf_escape($name);
|
||||
}
|
||||
}
|
||||
$row = array();
|
||||
|
|
|
@ -205,7 +205,7 @@ username.form['auth[driver]'].onchange();
|
|||
* @return string
|
||||
*/
|
||||
function editVal($val, $field) {
|
||||
return (ereg("binary", $field["type"]) ? reset(unpack("H*", $val)) : $val);
|
||||
return $val;
|
||||
}
|
||||
|
||||
/** Print columns box in select
|
||||
|
@ -546,10 +546,7 @@ username.form['auth[driver]'].onchange();
|
|||
} elseif (ereg('^(md5|sha1|password|encrypt)$', $function)) {
|
||||
$return = "$function($return)";
|
||||
}
|
||||
if (ereg("binary", $field["type"])) {
|
||||
$return = "unhex($return)";
|
||||
}
|
||||
return $return;
|
||||
return unconvert_field($field, $return);
|
||||
}
|
||||
|
||||
/** Returns export output options
|
||||
|
|
|
@ -30,7 +30,16 @@ $is_group = count($group) < count($select);
|
|||
$where = $adminer->selectSearchProcess($fields, $indexes);
|
||||
$order = $adminer->selectOrderProcess($fields, $indexes);
|
||||
$limit = $adminer->selectLimitProcess();
|
||||
$from = ($select ? implode(", ", $select) : ($oid ? "$oid, " : "") . "*") . "\nFROM " . table($TABLE);
|
||||
$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", $oid" : ""));
|
||||
if ($jush == "sql") {
|
||||
foreach ($columns as $key => $val) {
|
||||
$as = convert_field($fields[$key]);
|
||||
if ($as) {
|
||||
$from .= ", $as AS " . idf_escape($key);
|
||||
}
|
||||
}
|
||||
}
|
||||
$from .= "\nFROM " . table($TABLE);
|
||||
$group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
|
||||
|
||||
if ($_GET["val"] && is_ajax()) {
|
||||
|
|
|
@ -6,6 +6,7 @@ Use VALUES() in INSERT+UPDATE export
|
|||
Style logout button as link
|
||||
Store selected database to permanent login
|
||||
Ctrl+click and Shift+click on button opens form to a blank window
|
||||
MySQL: Support geometry data types
|
||||
Switch language by POST
|
||||
Compress translations
|
||||
selectQueryBuild() method (customization)
|
||||
|
|
|
@ -188,7 +188,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
|||
if (ereg('date|timestamp', $field["type"]) && $val !== null) {
|
||||
return preg_replace('~^(\\d{2}(\\d+))-(0?(\\d+))-(0?(\\d+))~', lang('$1-$3-$5'), $val);
|
||||
}
|
||||
return (ereg("binary", $field["type"]) ? reset(unpack("H*", $val)) : $val);
|
||||
return $val;
|
||||
}
|
||||
|
||||
function selectColumnsPrint($select, $columns) {
|
||||
|
@ -483,10 +483,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
|||
} elseif (ereg('^(md5|sha1)$', $function)) {
|
||||
$return = "$function($return)";
|
||||
}
|
||||
if (ereg("binary", $field["type"])) {
|
||||
$return = "unhex($return)";
|
||||
}
|
||||
return $return;
|
||||
return unconvert_field($field, $return);
|
||||
}
|
||||
|
||||
function dumpOutput() {
|
||||
|
|
2
externals/jush
vendored
2
externals/jush
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1dbb89b3d1f1aa27a067b017af44f4ef498bbaab
|
||||
Subproject commit d5d52b19fb783b9ffe138496d14c7fe776b11eb4
|
Loading…
Reference in a new issue