diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-03-24 12:26:46 +0000 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-03-24 12:26:46 +0000 |
| commit | 8e73302070d69b49c65390d7a8c3c3a367c0b3d9 (patch) | |
| tree | b5491cdd33a9e877ada6a67e2cf86759eb7e99df /django | |
| parent | fd2efb35fbb4c031fb52d4b969b0d8118df6a8e2 (diff) | |
[1.3.x] Fixed #16481 -- Adapted one raw SQL query in cull implementation of the database-based cache backend so it works with Oracle. Backport of r16635 from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.3.X@17805 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/cache/backends/db.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py index 495812a48d..4007de6ecd 100644 --- a/django/core/cache/backends/db.py +++ b/django/core/cache/backends/db.py @@ -132,7 +132,13 @@ class DatabaseCache(BaseDatabaseCache): cursor.execute("SELECT COUNT(*) FROM %s" % table) num = cursor.fetchone()[0] if num > self._max_entries: - cursor.execute("SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" % table, [num / self._cull_frequency]) + cull_num = num / self._cull_frequency + if connections[db].vendor == 'oracle': + # Special case for Oracle because it doesn't support LIMIT + OFFSET + cursor.execute("SELECT cache_key FROM (SELECT ROW_NUMBER() OVER (ORDER BY cache_key) AS counter, cache_key FROM %s) WHERE counter > %%s AND COUNTER <= %%s" % table, [cull_num, cull_num + 1]) + else: + # This isn't standard SQL, it's likely to break with some non officially supported databases + cursor.execute("SELECT cache_key FROM %s ORDER BY cache_key LIMIT 1 OFFSET %%s" % table, [cull_num]) cursor.execute("DELETE FROM %s WHERE cache_key < %%s" % table, [cursor.fetchone()[0]]) def clear(self): |
