Repository :
http://git.fedorahosted.org/cgit/
On branch : v1.4
---------------------------------------------------------------
commit e99567756ff1573c2f8413cd41d69ea7ad29d835
Author: Matt Domsch <Matt_Domsch(a)dell.com>
Date: Mon Feb 4 22:33:18 2013 -0600
model.py: fix RLIKE usage
The previous attempt to make RLIKE vs ~ database agnostic made the
mistake of using the stock RLIKE sqlrepr implementation. This was
causing the database table.column referred to in the RLIKE statement
to instead be treated as the explicit constant string 'table.column'
which is not what the pattern should be testing against - it will
always fail.
This patch extends the stock RLIKE implementation, to not turn the
table.column reference into a constant string.
This routine is still really slow, on the order of 15 seconds per
product + regexp (version + architecture) pair. For 18+ versions * 11
architectures, this is _really_ slow. This routine alone could take
30-45 minutes against the Fedora tree.
---------------------------------------------------------------
server/mirrormanager/model.py | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/server/mirrormanager/model.py b/server/mirrormanager/model.py
index 32c3502..ec413d6 100644
--- a/server/mirrormanager/model.py
+++ b/server/mirrormanager/model.py
@@ -1,4 +1,5 @@
from sqlobject import *
+from sqlobject.converters import sqlrepr
from sqlobject.sqlbuilder import RLIKE
from turbogears import identity, config
from datetime import datetime
@@ -537,15 +538,20 @@ def _publiclist_hosts(product=None, re=None):
sql2_join = 'AND category_directory.directory_id = directory.id '
sql2_join += 'AND category_directory.category_id = category.id '
+ class MY_RLIKE(RLIKE):
+ def __sqlrepr__(self, db):
+ return "(%s %s (%s))" % (
+ sqlrepr(self.expr, db), self._get_op(db), self.string)
+
def _rlike(pattern, string):
# there's probably a beter way to get this, but this works...
_dburi = config.get('sqlobject.dburi', 'sqlite://')
dbtype = _dburi.strip('notrans_').split(':')[0]
- return RLIKE('pattern', 'bar').__sqlrepr__(dbtype) + "
"
+ return MY_RLIKE(pattern, string).__sqlrepr__(dbtype) + " "
if re is not None:
- sql1_filter = "AND " + _rlike('host_category_dir.path', re)
- sql2_filter = "AND " + _rlike('directory.name', re)
+ sql1_filter = "AND " + _rlike(re, 'host_category_dir.path')
+ sql2_filter = "AND " + _rlike(re, 'directory.name')
sql1_up2date = 'AND host_category_dir.up2date '
sql2_up2date = 'AND host_category.always_up2date '