diff -Naurp drupal.org+conf/database/database.pgsql drupal/database/database.pgsql
--- drupal.org+conf/database/database.pgsql	2005-09-29 21:01:39.000000000 +0200
+++ drupal/database/database.pgsql	2005-09-29 21:09:01.000000000 +0200
@@ -165,7 +165,7 @@ CREATE TABLE boxes (
 
 CREATE TABLE cache (
   cid varchar(255) NOT NULL default '',
-  data text default '',
+  data bytea default '',
   expire integer NOT NULL default '0',
   created integer NOT NULL default '0',
   headers text default '',
diff -Naurp drupal.org+conf/includes/bootstrap.inc drupal/includes/bootstrap.inc
--- drupal.org+conf/includes/bootstrap.inc	2005-09-29 21:01:39.000000000 +0200
+++ drupal/includes/bootstrap.inc	2005-09-30 23:12:35.000000000 +0200
@@ -322,9 +322,9 @@ function cache_set($cid, $data, $expire 
   $data = db_encode_blob($data);
 
   db_lock_table('cache');
-  db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid);
+  db_query("UPDATE {cache} SET data = '$data', created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", time(), $expire, $headers, $cid);
   if (!db_affected_rows()) {
-    @db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '%s', %d, %d, '%s')", $cid, $data, time(), $expire, $headers);
+    db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', '$data', %d, %d, '%s')", $cid, time(), $expire, $headers);
   }
   db_unlock_tables();
 }
diff -Naurp drupal.org+conf/includes/database.pgsql.inc drupal/includes/database.pgsql.inc
--- drupal.org+conf/includes/database.pgsql.inc	2005-09-29 21:01:39.000000000 +0200
+++ drupal/includes/database.pgsql.inc	2005-09-30 23:00:35.000000000 +0200
@@ -232,7 +232,7 @@ function db_query_range($query) {
  *  Encoded data.
  */
 function db_encode_blob($data) {
-  return addcslashes($data, "\0..\37\\");
+   return pg_escape_bytea( strtr($data, array("{" => "!1", "}" => "!2", "%" => "!3", "!" => "!0")) );
 }
 
 /**
@@ -244,7 +244,7 @@ function db_encode_blob($data) {
  *  Decoded data.
  */
 function db_decode_blob($data) {
-  return stripcslashes($data);
+  return strtr(pg_unescape_bytea($data), array("!1" => "{", "!2" => "}", "!3" => "%", "!0" => "!"));
 }
 
 /**
