Modify ↓
#12175 closed defect (fixed)
"OperationalError: at most 32 tables in a join" from trac.ticket.tests.query with SQLite 32-bit
Reported by: | Jun Omae | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.9 |
Component: | query system | Version: | 1.0.8 |
Severity: | normal | Keywords: | |
Cc: | Branch: | ||
Release Notes: |
Fix regression in [14140], at most 32 tables in a join on SQLite 32-bit. |
||
API Changes: | |||
Internal Changes: |
Description
Regression from [14140] (#12113). I didn't test with Python 32-bit.
python setup.py -q test -s trac.ticket.tests.query.suite ...........................................E................... ====================================================================== ERROR: test_query_using_joins (trac.ticket.tests.query.QueryTestCase) ---------------------------------------------------------------------- Traceback (most recent call last): File "/src/trac/edgewall/git/trac/ticket/tests/query.py", line 466, in test_query_using_joins tickets = query.execute(self.req) File "/src/trac/edgewall/git/trac/ticket/query.py", line 301, in execute self.num_items = self._count(sql, args) File "/src/trac/edgewall/git/trac/ticket/query.py", line 282, in _count % sql, args)[0][0] File "/src/trac/edgewall/git/trac/db/api.py", line 124, in execute return db.execute(query, params) File "/src/trac/edgewall/git/trac/db/util.py", line 128, in execute cursor.execute(query, params if params is not None else []) File "/src/trac/edgewall/git/trac/db/util.py", line 61, in execute r = self.cursor.execute(sql_escape_percent(sql), args) File "/src/trac/edgewall/git/trac/db/sqlite_backend.py", line 82, in execute result = PyFormatCursor.execute(self, *args) File "/src/trac/edgewall/git/trac/db/sqlite_backend.py", line 60, in execute args or []) File "/src/trac/edgewall/git/trac/db/sqlite_backend.py", line 52, in _rollback_on_error return function(self, *args, **kwargs) OperationalError: at most 32 tables in a join
-
trac/ticket/query.py
diff --git a/trac/ticket/query.py b/trac/ticket/query.py index 53f2737..94db7b5 100644
a b class Query(object): 449 449 list_fields = [f['name'] for f in self.fields 450 450 if f['type'] == 'text' and 451 451 f.get('format') == 'list'] 452 # 3 2is max of joins in SQLite 32-bit, 3 is for order, group and452 # 31 is max of joins in SQLite 32-bit, 3 is for order, group and 453 453 # "priority" columns 454 use_joins = len(set(cols) & set(custom_fields)) <= 3 2- 3454 use_joins = len(set(cols) & set(custom_fields)) <= 31 - 3 455 455 456 456 sql = [] 457 457 sql.append("SELECT " + ",".join(['t.%s AS %s' % (c, c) for c in cols -
trac/ticket/tests/query.py
diff --git a/trac/ticket/tests/query.py b/trac/ticket/tests/query.py index bb4edfd..9a4a435 100644
a b ORDER BY COALESCE(t.id,0)=0,t.id""") 459 459 query = Query.from_string( 460 460 self.env, 'col_12=12.col_12&' + 461 461 'order=resolution&group=severity&col=id&col=summary' + 462 ''.join('&col=col_%02d' % idx for idx in xrange(2 9)))462 ''.join('&col=col_%02d' % idx for idx in xrange(28))) 463 463 sql, args = query.get_sql() 464 self.assertEqual(['enum'] * 3 + ['ticket_custom'] * 2 9,464 self.assertEqual(['enum'] * 3 + ['ticket_custom'] * 28, 465 465 self._get_join_tables(sql)) 466 466 tickets = query.execute(self.req) 467 467 self.assertEqual(1, len(tickets)) … … ORDER BY COALESCE(t.id,0)=0,t.id""") 469 469 query = Query.from_string( 470 470 self.env, 'col_12=12.col_12&' + 471 471 'order=milestone&group=version&col=id&col=summary' + 472 ''.join('&col=col_%02d' % idx for idx in xrange(2 9)))472 ''.join('&col=col_%02d' % idx for idx in xrange(28))) 473 473 sql, args = query.get_sql() 474 self.assertEqual(['enum', 'milestone'] + ['ticket_custom'] * 2 9+474 self.assertEqual(['enum', 'milestone'] + ['ticket_custom'] * 28 + 475 475 ['version'], 476 476 self._get_join_tables(sql)) 477 477 tickets = query.execute(self.req) … … ORDER BY COALESCE(t.id,0)=0,t.id""") 480 480 query = Query.from_string( 481 481 self.env, 'col_12=12.col_12&' + 482 482 'order=resolution&group=severity&col=id&col=summary' + 483 ''.join('&col=col_%02d' % idx for idx in xrange( 30)))483 ''.join('&col=col_%02d' % idx for idx in xrange(29))) 484 484 sql, args = query.get_sql() 485 485 self.assertEqual(['enum'] * 3, self._get_join_tables(sql)) 486 486 tickets = query.execute(self.req) … … ORDER BY COALESCE(t.id,0)=0,t.id""") 490 490 query = Query.from_string( 491 491 self.env, 'col_12=12.col_12&' + 492 492 'order=milestone&group=version&col=id&col=summary' + 493 ''.join('&col=col_%02d' % idx for idx in xrange( 30)))493 ''.join('&col=col_%02d' % idx for idx in xrange(29))) 494 494 sql, args = query.get_sql() 495 495 self.assertEqual(['enum', 'milestone', 'version'], 496 496 self._get_join_tables(sql))
Attachments (0)
Change History (2)
comment:1 by , 9 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | new → closed |
comment:2 by , 9 years ago
Owner: | set to |
---|
Note:
See TracTickets
for help on using tickets.
Fixed in [14268] and merged to trunk in [14269].