Try to make some sense of the various CVSdb-related limitation
mechanisms, namely by removing the largely redundant "global" limit and allowing the per-query row limit (which already exist, too) to do its work. While here, remove a poorly conceived (but thankfully unhighlighted) mechanism for overriding the administrative limit on database rows which was accessible via URL CGI params. * lib/viewvc.py (_legal_params): Remove 'limit' as a legal parameter. (view_query): No longer allow an undocumented URL parameter to override the admin-declared SQL row limit. That should have never been allowed! * lib/cvsdb.py (CheckinDatabase.__init__): Remove 'row_limit' parameter and associated self._row_limit member. (CheckinDatabase.CreateSQLQueryString): No longer fuss with self._row_limit. Let the individual query carry the row limit. (ConnectDatabase): Update call to CheckinDatabase(). * lib/query.py (form_to_cvsdb_query): Now accept 'cfg' parameter, and set the query's row limit from the configured defaults. (run_query): Update call to form_to_cvsdb_query(). * docs/url-reference.html Remove reference to the 'limit' parameter. git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@2547 8cb11bc2-c004-0410-86c3-e597b4017df7remotes/property-diff
parent
4818a56012
commit
df71275a13
|
@ -1250,13 +1250,6 @@ th.caption {
|
||||||
commands to back out changes instead showing a normal query result
|
commands to back out changes instead showing a normal query result
|
||||||
page</td>
|
page</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td><code>limit=<var>LIMIT</var></code></td>
|
|
||||||
<td>optional</td>
|
|
||||||
<td>maximum number of file-revisions to process during a
|
|
||||||
query. Default is value of <code>row_limit</code> configuration
|
|
||||||
option</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>limit_changes=<var>LIMIT_CHANGES</var></code></td>
|
<td><code>limit_changes=<var>LIMIT_CHANGES</var></code></td>
|
||||||
<td>optional</td>
|
<td>optional</td>
|
||||||
|
|
15
lib/cvsdb.py
15
lib/cvsdb.py
|
@ -37,13 +37,12 @@ error = "cvsdb error"
|
||||||
## complient database interface
|
## complient database interface
|
||||||
|
|
||||||
class CheckinDatabase:
|
class CheckinDatabase:
|
||||||
def __init__(self, host, port, user, passwd, database, row_limit):
|
def __init__(self, host, port, user, passwd, database):
|
||||||
self._host = host
|
self._host = host
|
||||||
self._port = port
|
self._port = port
|
||||||
self._user = user
|
self._user = user
|
||||||
self._passwd = passwd
|
self._passwd = passwd
|
||||||
self._database = database
|
self._database = database
|
||||||
self._row_limit = row_limit
|
|
||||||
self._version = None
|
self._version = None
|
||||||
|
|
||||||
## database lookup caches
|
## database lookup caches
|
||||||
|
@ -443,13 +442,11 @@ class CheckinDatabase:
|
||||||
conditions = " AND ".join(joinConds + condList)
|
conditions = " AND ".join(joinConds + condList)
|
||||||
conditions = conditions and "WHERE %s" % conditions
|
conditions = conditions and "WHERE %s" % conditions
|
||||||
|
|
||||||
## limit the number of rows requested or we could really slam
|
## apply the query's row limit, if any (so we avoid really
|
||||||
## a server with a large database
|
## slamming a server with a large database)
|
||||||
limit = ""
|
limit = ""
|
||||||
if query.limit:
|
if query.limit:
|
||||||
limit = "LIMIT %s" % (str(query.limit))
|
limit = "LIMIT %s" % (str(query.limit))
|
||||||
elif self._row_limit:
|
|
||||||
limit = "LIMIT %s" % (str(self._row_limit))
|
|
||||||
|
|
||||||
sql = "SELECT %s.* FROM %s %s %s %s" \
|
sql = "SELECT %s.* FROM %s %s %s %s" \
|
||||||
% (commits_table, tables, conditions, order_by, limit)
|
% (commits_table, tables, conditions, order_by, limit)
|
||||||
|
@ -768,8 +765,8 @@ class QueryEntry:
|
||||||
self.data = data
|
self.data = data
|
||||||
self.match = match
|
self.match = match
|
||||||
|
|
||||||
## CheckinDatabaseQueryData is a object which contains the search parameters
|
## CheckinDatabaseQuery is an object which contains the search
|
||||||
## for a query to the CheckinDatabase
|
## parameters for a query to the Checkin Database
|
||||||
class CheckinDatabaseQuery:
|
class CheckinDatabaseQuery:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
## sorting
|
## sorting
|
||||||
|
@ -860,7 +857,7 @@ def ConnectDatabase(cfg, readonly=0):
|
||||||
user = cfg.cvsdb.user
|
user = cfg.cvsdb.user
|
||||||
passwd = cfg.cvsdb.passwd
|
passwd = cfg.cvsdb.passwd
|
||||||
db = CheckinDatabase(cfg.cvsdb.host, cfg.cvsdb.port, user, passwd,
|
db = CheckinDatabase(cfg.cvsdb.host, cfg.cvsdb.port, user, passwd,
|
||||||
cfg.cvsdb.database_name, cfg.cvsdb.row_limit)
|
cfg.cvsdb.database_name)
|
||||||
db.Connect()
|
db.Connect()
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
|
|
@ -217,8 +217,9 @@ def decode_command(cmd):
|
||||||
else:
|
else:
|
||||||
return "exact"
|
return "exact"
|
||||||
|
|
||||||
def form_to_cvsdb_query(form_data):
|
def form_to_cvsdb_query(cfg, form_data):
|
||||||
query = cvsdb.CreateCheckinQuery()
|
query = cvsdb.CreateCheckinQuery()
|
||||||
|
query.SetLimit(cfg.cvsdb.row_limit)
|
||||||
|
|
||||||
if form_data.repository:
|
if form_data.repository:
|
||||||
for cmd, str in listparse_string(form_data.repository):
|
for cmd, str in listparse_string(form_data.repository):
|
||||||
|
@ -377,7 +378,7 @@ def build_commit(server, cfg, desc, files, cvsroots, viewvc_link):
|
||||||
return ob
|
return ob
|
||||||
|
|
||||||
def run_query(server, cfg, form_data, viewvc_link):
|
def run_query(server, cfg, form_data, viewvc_link):
|
||||||
query = form_to_cvsdb_query(form_data)
|
query = form_to_cvsdb_query(cfg, form_data)
|
||||||
db = cvsdb.ConnectDatabaseReadOnly(cfg)
|
db = cvsdb.ConnectDatabaseReadOnly(cfg)
|
||||||
db.RunQuery(query)
|
db.RunQuery(query)
|
||||||
|
|
||||||
|
|
|
@ -709,7 +709,6 @@ _legal_params = {
|
||||||
'mindate' : _re_validate_datetime,
|
'mindate' : _re_validate_datetime,
|
||||||
'maxdate' : _re_validate_datetime,
|
'maxdate' : _re_validate_datetime,
|
||||||
'format' : _re_validate_alpha,
|
'format' : _re_validate_alpha,
|
||||||
'limit' : _re_validate_number,
|
|
||||||
|
|
||||||
# for redirect_pathrev
|
# for redirect_pathrev
|
||||||
'orig_path' : None,
|
'orig_path' : None,
|
||||||
|
@ -4166,7 +4165,6 @@ def view_query(request):
|
||||||
mindate = request.query_dict.get('mindate', '')
|
mindate = request.query_dict.get('mindate', '')
|
||||||
maxdate = request.query_dict.get('maxdate', '')
|
maxdate = request.query_dict.get('maxdate', '')
|
||||||
format = request.query_dict.get('format')
|
format = request.query_dict.get('format')
|
||||||
limit = int(request.query_dict.get('limit', 0))
|
|
||||||
limit_changes = int(request.query_dict.get('limit_changes',
|
limit_changes = int(request.query_dict.get('limit_changes',
|
||||||
cfg.options.limit_changes))
|
cfg.options.limit_changes))
|
||||||
|
|
||||||
|
@ -4236,16 +4234,17 @@ def view_query(request):
|
||||||
query.SetFromDateObject(mindate)
|
query.SetFromDateObject(mindate)
|
||||||
if maxdate is not None:
|
if maxdate is not None:
|
||||||
query.SetToDateObject(maxdate)
|
query.SetToDateObject(maxdate)
|
||||||
if limit:
|
|
||||||
query.SetLimit(limit)
|
# Set the admin-defined (via configuration) row limits. This is to avoid
|
||||||
elif format == 'rss':
|
# slamming the database server with a monster query.
|
||||||
|
if format == 'rss':
|
||||||
query.SetLimit(cfg.cvsdb.rss_row_limit)
|
query.SetLimit(cfg.cvsdb.rss_row_limit)
|
||||||
|
else:
|
||||||
|
query.SetLimit(cfg.cvsdb.row_limit)
|
||||||
|
|
||||||
# run the query
|
# run the query
|
||||||
db.RunQuery(query)
|
db.RunQuery(query)
|
||||||
|
|
||||||
sql = request.server.escape(db.CreateSQLQueryString(query))
|
|
||||||
|
|
||||||
# gather commits
|
# gather commits
|
||||||
commits = []
|
commits = []
|
||||||
plus_count = 0
|
plus_count = 0
|
||||||
|
@ -4327,7 +4326,7 @@ def view_query(request):
|
||||||
|
|
||||||
data = common_template_data(request)
|
data = common_template_data(request)
|
||||||
data.merge(ezt.TemplateData({
|
data.merge(ezt.TemplateData({
|
||||||
'sql': sql,
|
'sql': request.server.escape(db.CreateSQLQueryString(query)),
|
||||||
'english_query': english_query(request),
|
'english_query': english_query(request),
|
||||||
'queryform_href': request.get_url(view_func=view_queryform, escape=1),
|
'queryform_href': request.get_url(view_func=view_queryform, escape=1),
|
||||||
'backout_href': backout_href,
|
'backout_href': backout_href,
|
||||||
|
|
Loading…
Reference in New Issue