Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improve export of binary data types (bug #3526494)

  • Loading branch information...
commit 7541ceb1ca9d4b3b70a6931281c2954ad918d157 1 parent 2afd915
Jakub Vrána authored
3  adminer/dump.inc.php
View
@@ -76,7 +76,8 @@
}
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""));
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"]))) {
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
6 adminer/include/adminer.inc.php
View
@@ -638,7 +638,8 @@ function dumpData($table, $style, $query) {
$buffer = "";
$keys = array();
$suffix = "";
- while ($row = $result->fetch_row()) {
+ $fetch_function = ($table != '' ? 'fetch_assoc' : 'fetch_row');
+ while ($row = $result->$fetch_function()) {
if (!$keys) {
$values = array();
foreach ($row as $val) {
@@ -660,8 +661,9 @@ function dumpData($table, $style, $query) {
$insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES";
}
foreach ($row as $key => $val) {
+ $field = $fields[$key];
$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"
);
}
20 adminer/include/functions.inc.php
View
@@ -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);
}
+/** 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
* @param string
* @param string
16 adminer/select.inc.php
View
@@ -30,19 +30,9 @@
$where = $adminer->selectSearchProcess($fields, $indexes);
$order = $adminer->selectOrderProcess($fields, $indexes);
$limit = $adminer->selectLimitProcess();
-$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", $oid" : ""));
-if ($jush == "sql" && !$_POST["export"]) {
- foreach ($columns as $key => $val) {
- 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);
+$from = ($select ? implode(", ", $select) : "*" . ($oid ? ", $oid" : ""))
+ . convert_fields($columns, $fields, $select)
+ . "\nFROM " . table($TABLE);
$group_by = ($group && $is_group ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : "");
if ($_GET["val"] && is_ajax()) {
1  changes.txt
View
@@ -4,6 +4,7 @@ Print run time next to executed queries
Disable SQL export when applying functions in select
MySQL: Optimize create table page and Editor navigation
MySQL: Display bit type as binary number
+MySQL: Improve export of binary data types
MySQL: Fix handling of POINT data type (bug #3582578)
MySQL: Don't export binary and geometry columns twice in select
Please sign in to comment.
Something went wrong with that request. Please try again.