Index: database/updates.inc =================================================================== RCS file: /cvs/drupal/drupal/database/updates.inc,v retrieving revision 1.55 diff -u -r1.55 updates.inc --- database/updates.inc 9 Sep 2004 05:51:07 -0000 1.55 +++ database/updates.inc 9 Sep 2004 20:23:43 -0000 @@ -80,7 +80,8 @@ "2004-08-11" => "update_101", "2004-08-12" => "update_102", "2004-08-17" => "update_103", - "2004-08-19" => "update_104" + "2004-08-19" => "update_104", + "2004-09-09" => "update_105" ); function update_32() { @@ -1711,6 +1712,24 @@ return $ret; } +function update_105() { + /** + * PostgreSQL only update + */ + $ret = array(); + if ($GLOBALS['db_type'] == 'pgsql') { + $ret[] = update_sql("DROP TABLE {cache}"); + $ret[] = update_sql("CREATE TABLE {cache} ( + cid varchar(255) NOT NULL default '', + data bytea default '', + expire integer NOT NULL default '0', + created integer NOT NULL default '0', + headers text default '', + PRIMARY KEY (cid) + )"); + } + return $ret; +} function update_sql($sql) { $edit = $_POST["edit"]; Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.26 diff -u -r1.26 bootstrap.inc --- includes/bootstrap.inc 9 Sep 2004 05:51:08 -0000 1.26 +++ includes/bootstrap.inc 9 Sep 2004 20:23:44 -0000 @@ -134,10 +134,11 @@ function cache_set($cid, $data, $expire = 0, $headers = NULL) { $data = db_encode_blob($data); - 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); + } } /** Index: includes/database.mysql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v retrieving revision 1.25 diff -u -r1.25 database.mysql.inc --- includes/database.mysql.inc 9 Sep 2004 05:51:08 -0000 1.25 +++ includes/database.mysql.inc 9 Sep 2004 20:23:44 -0000 @@ -270,7 +270,8 @@ * Encoded data. */ function db_encode_blob($data) { - return $data; + // Uses str_replace to make the string sprintf friendly. + return str_replace('%', '%%', check_query($data)); } /** Index: includes/database.pgsql.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/database.pgsql.inc,v retrieving revision 1.2 diff -u -r1.2 database.pgsql.inc --- includes/database.pgsql.inc 9 Sep 2004 05:51:08 -0000 1.2 +++ includes/database.pgsql.inc 9 Sep 2004 20:23:45 -0000 @@ -23,7 +23,9 @@ function db_connect($url) { $url = parse_url($url); - $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) .' password='. $url['pass']; + $conn_string = ' user='. $url['user'] .' dbname='. substr($url['path'], 1) .' password='. $url['pass'] . ' host=' . $url['host']; + $conn_string .= ($url['port']) ? ' port=' . $url['port'] : ''; + $connection = pg_connect($conn_string) or die(pg_last_error()); return $connection; @@ -263,7 +265,8 @@ * Encoded data. */ function db_encode_blob($data) { - return pg_escape_bytea($data); + // Uses str_replace to make the string sprintf friendly. + return str_replace('%', '%%', pg_escape_bytea($data)); } /**