Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/DB/PostgresDialect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ public static function prepareFullText(array $words, $logic)

public function quoteBinary($data)
{
return "E'".pg_escape_bytea($data)."'";
$esc = pg_escape_bytea($data);
if (mb_strpos($esc, '\\x') === 0) {
// http://www.postgresql.org/docs/9.1/static/datatype-binary.html
// if pg_escape_bytea use postgres 9.1+ it's return value like '\x00aabb' (new bytea hex format),
// but must return '\\x00aabb'. So we use this fix:'
return "E'\\".$esc."'";
} else {
//if function escape value like '\\000\\123' - all ok
return "E'".$esc."'";
}
}

public function unquoteBinary($data)
Expand Down
5 changes: 5 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2012-08-10 Alexey S. Denisov

* core/DB/PostgresDialect.class.php:
fix incorrect bytea escaping for Postgres 9.1+

2012-08-10 Alexey S. Denisov

* core/Form/Primitives/PrimitiveHstore.class.php:
Expand Down