Author: ramiro Date: 2011-08-21 10:19:35 -0700 (Sun, 21 Aug 2011) New Revision: 16635
Modified: django/trunk/django/core/cache/backends/db.py Log: Fixed #16481 -- Adapted one raw SQL query in cull immplementation of the database-based cache backend so it works with Oracle. Thanks Aymeric Augustin for the report and patch. Modified: django/trunk/django/core/cache/backends/db.py =================================================================== --- django/trunk/django/core/cache/backends/db.py 2011-08-21 15:45:09 UTC (rev 16634) +++ django/trunk/django/core/cache/backends/db.py 2011-08-21 17:19:35 UTC (rev 16635) @@ -135,7 +135,13 @@ 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): -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.