PostgreSQL: Upload binary files to bytea fields

This commit is contained in:
Jakub Vrana 2018-02-06 15:42:14 +01:00
parent b649fb2f3f
commit 17b110f0d5
4 changed files with 24 additions and 3 deletions

View file

@ -37,7 +37,11 @@ if (isset($_GET["pgsql"])) {
}
function quote($string) {
return "'" . pg_escape_string($this->_link, $string) . "'"; //! bytea
return "'" . pg_escape_string($this->_link, $string) . "'";
}
function quoteBinary($string) {
return "'" . pg_escape_bytea($this->_link, $string) . "'";
}
function select_db($database) {
@ -147,6 +151,10 @@ if (isset($_GET["pgsql"])) {
return ($adminer->database() == $database);
}
function quoteBinary($s) {
return q($s);
}
function warnings() {
return ''; // not implemented in PDO_PgSQL as of PHP 7.2.1
}
@ -188,6 +196,10 @@ if (isset($_GET["pgsql"])) {
);
}
function quoteBinary($s) {
return $this->_conn->quoteBinary($s);
}
function warnings() {
return $this->_conn->warnings();
}

View file

@ -123,6 +123,14 @@
return $idf;
}
/** Quote binary string
* @param string
* @return string
*/
function quoteBinary($s) {
return q($s);
}
/** Get warnings about the last command
* @return string HTML
*/

View file

@ -1003,7 +1003,7 @@ function input($field, $value, $function) {
* @return string or false to leave the original value
*/
function process_input($field) {
global $adminer;
global $adminer, $driver;
$idf = bracket_escape($field["field"]);
$function = $_POST["function"][$idf];
$value = $_POST["fields"][$idf];
@ -1041,7 +1041,7 @@ function process_input($field) {
if (!is_string($file)) {
return false; //! report errors
}
return q($file);
return $driver->quoteBinary($file);
}
return $adminer->processInput($field, $value, $function);
}

View file

@ -1,6 +1,7 @@
Adminer 4.6.1-dev:
MySQL: Support non-utf8 charset in search in column
MySQL: Support geometry in MySQL 8 (bug #574)
PostgreSQL: Upload binary files to bytea fields
PostgreSQL: Cast to string when searching using LIKE (bug #325)
PostgreSQL: Don't treat interval type as number (bug #474)
PostgreSQL: Fix condition for selecting no rows