Improve export of binary data types (bug #3526494)
This commit is contained in:
parent
2afd915f00
commit
7541ceb1ca
|
@ -76,7 +76,8 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
}
|
}
|
||||||
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""));
|
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""));
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$adminer->dumpData($name, $_POST["data_style"], "SELECT * FROM " . table($name));
|
$fields = fields($name);
|
||||||
|
$adminer->dumpData($name, $_POST["data_style"], "SELECT *" . convert_fields($fields, $fields) . " FROM " . table($name));
|
||||||
}
|
}
|
||||||
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
||||||
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
||||||
|
|
|
@ -638,7 +638,8 @@ username.form['auth[driver]'].onchange();
|
||||||
$buffer = "";
|
$buffer = "";
|
||||||
$keys = array();
|
$keys = array();
|
||||||
$suffix = "";
|
$suffix = "";
|
||||||
while ($row = $result->fetch_row()) {
|
$fetch_function = ($table != '' ? 'fetch_assoc' : 'fetch_row');
|
||||||
|
while ($row = $result->$fetch_function()) {
|
||||||
if (!$keys) {
|
if (!$keys) {
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($row as $val) {
|
foreach ($row as $val) {
|
||||||
|
@ -660,8 +661,9 @@ username.form['auth[driver]'].onchange();
|
||||||
$insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES";
|
$insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES";
|
||||||
}
|
}
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
|
$field = $fields[$key];
|
||||||
$row[$key] = ($val !== null
|
$row[$key] = ($val !== null
|
||||||
? (ereg('(^|[^o])int|float|double|decimal|bit', $fields[$keys[$key]]["type"]) && $val != '' ? $val : q($val)) //! columns looking like functions
|
? unconvert_field($field, ereg('(^|[^o])int|float|double|decimal', $field["type"]) && $val != '' ? $val : q($val))
|
||||||
: "NULL"
|
: "NULL"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,6 +370,26 @@ function where_link($i, $column, $value, $operator = "=") {
|
||||||
return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=" . urlencode(($value !== null ? $operator : "IS NULL")) . "&where%5B$i%5D%5Bval%5D=" . urlencode($value);
|
return "&where%5B$i%5D%5Bcol%5D=" . urlencode($column) . "&where%5B$i%5D%5Bop%5D=" . urlencode(($value !== null ? $operator : "IS NULL")) . "&where%5B$i%5D%5Bval%5D=" . urlencode($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get select clause for convertible fields
|
||||||
|
* @param array
|
||||||
|
* @param array
|
||||||
|
* @param array
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function convert_fields($columns, $fields, $select = array()) {
|
||||||
|
$return = "";
|
||||||
|
foreach ($columns as $key => $val) {
|
||||||
|
if ($select && !in_array(idf_escape($key), $select)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$as = convert_field($fields[$key]);
|
||||||
|
if ($as) {
|
||||||
|
$return .= ", $as AS " . idf_escape($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/** Set cookie valid for 1 month
|
/** Set cookie valid for 1 month
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
|
|
|
@ -30,19 +30,9 @@ $is_group = count($group) < count($select);
|
||||||
$where = $adminer->selectSearchProcess($fields, $indexes);
|
$where = $adminer->selectSearchProcess($fields, $indexes);
|
||||||
$order = $adminer->selectOrderProcess($fields, $indexes);
|
$order = $adminer->selectOrderProcess($fields, $indexes);
|
||||||
$limit = $adminer->selectLimitProcess();
|
$limit = $adminer->selectLimitProcess();
|
||||||
$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", $oid" : ""));
|
$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", $oid" : ""))
|
||||||
if ($jush == "sql" && !$_POST["export"]) {
|
. convert_fields($columns, $fields, $select)
|
||||||
foreach ($columns as $key => $val) {
|
. "\nFROM " . table($TABLE);
|
||||||
if ($select && !in_array(idf_escape($key), $select)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$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) : "");
|
$group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
|
||||||
|
|
||||||
if ($_GET["val"] && is_ajax()) {
|
if ($_GET["val"] && is_ajax()) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ Print run time next to executed queries
|
||||||
Disable SQL export when applying functions in select
|
Disable SQL export when applying functions in select
|
||||||
MySQL: Optimize create table page and Editor navigation
|
MySQL: Optimize create table page and Editor navigation
|
||||||
MySQL: Display bit type as binary number
|
MySQL: Display bit type as binary number
|
||||||
|
MySQL: Improve export of binary data types
|
||||||
MySQL: Fix handling of POINT data type (bug #3582578)
|
MySQL: Fix handling of POINT data type (bug #3582578)
|
||||||
MySQL: Don't export binary and geometry columns twice in select
|
MySQL: Don't export binary and geometry columns twice in select
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue