summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-08-06 10:32:37 +0200
committerAleksander Machniak <alec@alec.pl>2012-08-06 10:32:37 +0200
commit83121ece3348bfe09bb1026eace79a74a5ccf2c9 (patch)
tree9f64f143b8a859db3930a649a404cdcc46434660
parenta025cddbc5643d1e8c9d2bf733a101417213d91b (diff)
- Removed redundant cache.cache_id column (#1488528)
-rw-r--r--CHANGELOG1
-rw-r--r--SQL/mssql.initial.sql8
-rw-r--r--SQL/mysql.initial.sql4
-rw-r--r--SQL/mysql.update.sql4
-rw-r--r--SQL/postgres.initial.sql12
-rw-r--r--SQL/postgres.update.sql5
-rw-r--r--SQL/sqlite.initial.sql1
-rw-r--r--SQL/sqlite.update.sql13
-rw-r--r--program/include/rcube_cache.php12
9 files changed, 29 insertions, 31 deletions
diff --git a/CHANGELOG b/CHANGELOG
index d4eebef5a..9988d55b2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail
===========================
+- Removed redundant cache.cache_id column (#1488528)
- Fix order of attachments in sent mail (#1488423)
- Don't show product version on login screen (can be enabled by config)
- Renamed old default skin to 'classic'. Larry is the new default skin.
diff --git a/SQL/mssql.initial.sql b/SQL/mssql.initial.sql
index 2ac6aa63e..9aa6e6321 100644
--- a/SQL/mssql.initial.sql
+++ b/SQL/mssql.initial.sql
@@ -1,5 +1,4 @@
CREATE TABLE [dbo].[cache] (
- [cache_id] [int] IDENTITY (1, 1) NOT NULL ,
[user_id] [int] NOT NULL ,
[cache_key] [varchar] (128) COLLATE Latin1_General_CI_AI NOT NULL ,
[created] [datetime] NOT NULL ,
@@ -117,13 +116,6 @@ CREATE TABLE [dbo].[searches] (
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
-ALTER TABLE [dbo].[cache] WITH NOCHECK ADD
- PRIMARY KEY CLUSTERED
- (
- [cache_id]
- ) ON [PRIMARY]
-GO
-
ALTER TABLE [dbo].[cache_index] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
diff --git a/SQL/mysql.initial.sql b/SQL/mysql.initial.sql
index b0a7ee7a9..46fa2c3cf 100644
--- a/SQL/mysql.initial.sql
+++ b/SQL/mysql.initial.sql
@@ -36,12 +36,10 @@ CREATE TABLE `users` (
-- Table structure for table `cache`
CREATE TABLE `cache` (
- `cache_id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+ `user_id` int(10) UNSIGNED NOT NULL,
`cache_key` varchar(128) /*!40101 CHARACTER SET ascii COLLATE ascii_general_ci */ NOT NULL ,
`created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`data` longtext NOT NULL,
- `user_id` int(10) UNSIGNED NOT NULL,
- PRIMARY KEY(`cache_id`),
CONSTRAINT `user_id_fk_cache` FOREIGN KEY (`user_id`)
REFERENCES `users`(`user_id`) ON DELETE CASCADE ON UPDATE CASCADE,
INDEX `created_index` (`created`),
diff --git a/SQL/mysql.update.sql b/SQL/mysql.update.sql
index 300ceb59d..3be65897d 100644
--- a/SQL/mysql.update.sql
+++ b/SQL/mysql.update.sql
@@ -239,3 +239,7 @@ ALTER TABLE `identities` ALTER `user_id` DROP DEFAULT;
ALTER TABLE `searches` ALTER `user_id` DROP DEFAULT;
/*!40014 SET FOREIGN_KEY_CHECKS=1 */;
+
+-- Updates from version 0.8
+
+ALTER TABLE cache DROP COLUMN cache_id;
diff --git a/SQL/postgres.initial.sql b/SQL/postgres.initial.sql
index e12a9978a..a47bec2ca 100644
--- a/SQL/postgres.initial.sql
+++ b/SQL/postgres.initial.sql
@@ -160,23 +160,11 @@ CREATE TABLE contactgroupmembers (
CREATE INDEX contactgroupmembers_contact_id_idx ON contactgroupmembers (contact_id);
--
--- Sequence "cache_ids"
--- Name: cache_ids; Type: SEQUENCE; Schema: public; Owner: postgres
---
-
-CREATE SEQUENCE cache_ids
- INCREMENT BY 1
- NO MAXVALUE
- NO MINVALUE
- CACHE 1;
-
---
-- Table "cache"
-- Name: cache; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE "cache" (
- cache_id integer DEFAULT nextval('cache_ids'::text) PRIMARY KEY,
user_id integer NOT NULL
REFERENCES users (user_id) ON DELETE CASCADE ON UPDATE CASCADE,
cache_key varchar(128) DEFAULT '' NOT NULL,
diff --git a/SQL/postgres.update.sql b/SQL/postgres.update.sql
index 7e9d34fa9..a8a9cdda8 100644
--- a/SQL/postgres.update.sql
+++ b/SQL/postgres.update.sql
@@ -175,3 +175,8 @@ ALTER TABLE "session" ALTER sess_id TYPE varchar(128);
DROP INDEX contacts_user_id_idx;
CREATE INDEX contacts_user_id_idx ON contacts USING btree (user_id, del);
ALTER TABLE contacts ALTER email TYPE text;
+
+-- Updates from version 0.8
+
+ALTER TABLE cache DROP COLUMN cache_id;
+DROP SEQUENCE cache_ids;
diff --git a/SQL/sqlite.initial.sql b/SQL/sqlite.initial.sql
index dafb5a15d..a3c38b939 100644
--- a/SQL/sqlite.initial.sql
+++ b/SQL/sqlite.initial.sql
@@ -5,7 +5,6 @@
--
CREATE TABLE cache (
- cache_id integer NOT NULL PRIMARY KEY,
user_id integer NOT NULL default 0,
cache_key varchar(128) NOT NULL default '',
created datetime NOT NULL default '0000-00-00 00:00:00',
diff --git a/SQL/sqlite.update.sql b/SQL/sqlite.update.sql
index 9f410fb13..ddadde3ea 100644
--- a/SQL/sqlite.update.sql
+++ b/SQL/sqlite.update.sql
@@ -333,3 +333,16 @@ INSERT INTO contacts (contact_id, user_id, changed, del, name, email, firstname,
CREATE INDEX ix_contacts_user_id ON contacts(user_id, del);
DROP TABLE contacts_tmp;
+
+-- Updates from version 0.8
+
+DROP TABLE cache;
+CREATE TABLE cache (
+ user_id integer NOT NULL default 0,
+ cache_key varchar(128) NOT NULL default '',
+ created datetime NOT NULL default '0000-00-00 00:00:00',
+ data text NOT NULL
+);
+
+CREATE INDEX ix_cache_user_cache_key ON cache(user_id, cache_key);
+CREATE INDEX ix_cache_created ON cache(created);
diff --git a/program/include/rcube_cache.php b/program/include/rcube_cache.php
index 01f620381..807d20c0e 100644
--- a/program/include/rcube_cache.php
+++ b/program/include/rcube_cache.php
@@ -45,7 +45,6 @@ class rcube_cache
private $packed;
private $index;
private $cache = array();
- private $cache_keys = array();
private $cache_changes = array();
private $cache_sums = array();
@@ -167,7 +166,7 @@ class rcube_cache
$this->cache = array();
$this->cache_changed = false;
$this->cache_changes = array();
- $this->cache_keys = array();
+ $this->cache_sums = array();
}
// Remove keys by name prefix
else if ($prefix_mode) {
@@ -175,7 +174,7 @@ class rcube_cache
if (strpos($k, $key) === 0) {
$this->cache[$k] = null;
$this->cache_changes[$k] = false;
- unset($this->cache_keys[$k]);
+ unset($this->cache_sums[$k]);
}
}
}
@@ -183,7 +182,7 @@ class rcube_cache
else {
$this->cache[$key] = null;
$this->cache_changes[$key] = false;
- unset($this->cache_keys[$key]);
+ unset($this->cache_sums[$key]);
}
// Remove record(s) from the backend
@@ -274,7 +273,7 @@ class rcube_cache
}
else {
$sql_result = $this->db->limitquery(
- "SELECT cache_id, data, cache_key".
+ "SELECT data, cache_key".
" FROM ".$this->db->table_name('cache').
" WHERE user_id = ?".
" AND cache_key = ?".
@@ -296,7 +295,6 @@ class rcube_cache
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
- $this->cache_keys[$key] = $sql_arr['cache_id'];
}
else {
$this->cache[$key] = null;
@@ -325,7 +323,7 @@ class rcube_cache
return $this->add_record($this->ckey($key), $data);
}
- $key_exists = $this->cache_keys[$key];
+ $key_exists = array_key_exists($key, $this->cache_sums);
$key = $this->prefix . '.' . $key;
// Remove NULL rows (here we don't need to check if the record exist)