kanboard: SQLSTATE[HY000]: General error: 1 too many SQL variables
I have problems displaying closed tasks.
Actual behaviour
When I use show closed tasks filter I get the following error message (blank screen with error message)
SQLSTATE[HY000]: General error: 1 too many SQL variables
Also I see the following in debug log:
[2017-05-22 08:22:11] [debug] SQL: SELECT (SELECT COUNT(*) FROM comments WHERE task_id=tasks.id) AS nb_comments, (SELECT COUNT(*) FROM task_has_files WHERE task_id=tasks.id) AS nb_files, (SELECT COUNT(*) FROM subtasks WHERE subtasks.task_id=tasks.id) AS nb_subtasks, (SELECT COUNT(*) FROM subtasks WHERE subtasks.task_id=tasks.id AND status=2) AS nb_completed_subtasks, (SELECT COUNT(*) FROM task_has_links WHERE task_has_links.task_id = tasks.id) AS nb_links, (SELECT COUNT(*) FROM task_has_external_links WHERE task_has_external_links.task_id = tasks.id) AS nb_external_links, (SELECT DISTINCT 1 FROM task_has_links WHERE task_has_links.task_id = tasks.id AND task_has_links.link_id = 9) AS is_milestone, tasks.id, tasks.reference, tasks.title, tasks.description, tasks.date_creation, tasks.date_modification, tasks.date_completed, tasks.date_started, tasks.date_due, tasks.color_id, tasks.project_id, tasks.column_id, tasks.swimlane_id, tasks.owner_id, tasks.creator_id, tasks.position, tasks.is_active, tasks.score, tasks.category_id, tasks.priority, tasks.date_moved, tasks.recurrence_status, tasks.recurrence_trigger, tasks.recurrence_factor, tasks.recurrence_timeframe, tasks.recurrence_basedate, tasks.recurrence_parent, tasks.recurrence_child, tasks.time_estimated, tasks.time_spent, users.username AS assignee_username, users.name AS assignee_name, users.email AS assignee_email, users.avatar_path AS assignee_avatar_path, project_has_categories.name AS category_name, project_has_categories.description AS category_description, columns.title AS column_name, columns.position AS column_position, swimlanes.name AS swimlane_name, projects.name AS project_name FROM "tasks" LEFT JOIN "users" ON "users"."id"="tasks"."owner_id" LEFT JOIN "users" AS "uc" ON "uc"."id"="tasks"."creator_id" LEFT JOIN "project_has_categories" ON "project_has_categories"."id"="tasks"."category_id" LEFT JOIN "columns" ON "columns"."id"="tasks"."column_id" LEFT JOIN "swimlanes" ON "swimlanes"."id"="tasks"."swimlane_id" LEFT JOIN "projects" ON "projects"."id"="tasks"."project_id" WHERE tasks.is_active = ? AND tasks.date_board <= ? AND tasks.project_id = ? ORDER BY tasks.position ASC [2017-05-22 08:22:11] [debug] SQL: query_duration=0.17643594741821 [2017-05-22 08:22:11] [debug] SQL: total_execution_time=0.17871809005737 [2017-05-22 08:22:11] [debug] SQL: SELECT tags.id, tags.name, task_has_tags.task_id FROM "tags" LEFT JOIN "task_has_tags" ON "task_has_tags"."tag_id"="tags"."id" WHERE task_has_tags.task_id IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?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, ?, ?, ?, ?, ?) ORDER BY tags.name ASC [2017-05-22 08:22:11] [debug] SQL: SQLSTATE[HY000]: General error: 1 too many SQL variables [2017-05-22 08:22:11] [debug] APP: nb_queries=11 [2017-05-22 08:22:11] [debug] APP: rendering_time=0.32471704483032 [2017-05-22 08:22:11] [debug] APP: memory_usage=5.64M [2017-05-22 08:22:11] [debug] APP: uri=/?controller=BoardViewController&action=show&plugin=&project_id=3&search=status%3Aclosed
Expected behaviour
Closed task displayed
Steps to reproduce
- Select Closed Task from filters list
Configuration
Application version: 1.0.43 ◾ PHP version: 5.6.28 ◾ PHP SAPI: cgi-fcgi ◾ OS version: Windows NT 6.3 ◾ Database driver: sqlite ◾ Database version: 3.8.10.2 ◾ Browser: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; WOW64; Trident/7.0; .NET4.0E; .NET4.0C)
Please advise.
M
I have just discovered that the issue is there only in board view. I can see the closed tasks in list view.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 20 (19 by maintainers)
Commits related to this issue
- Changes filters from in array to in subqueries Fixes #3280 — committed to rafacamargo123/kanboard by rafacamargo123 5 years ago
- Changes filters from in array to in subqueries Fixes #3280 — committed to rafacamargo123/kanboard by rafacamargo123 5 years ago
- Changes filters from in array to in subqueries Fixes #3280 — committed to rafacamargo123/kanboard by rafacamargo123 5 years ago
- Changes filters from in array to in subqueries Fixes #3280 — committed to kanboard/kanboard by rafacamargo123 5 years ago
- Changes filters from in array to in subqueries Fixes #3280 — committed to psy-q/kanboard by rafacamargo123 5 years ago
If I understand correctly, the issue is that whoever is emitting the SQL statement is trying to flatten all task IDs at the application level for the SELECT statement to pick the correct tasks, instead of using the SQL engine to determine the set of IDs. I’m assuming that the actual set of IDs is so that there exists an SQL query that would return all those IDs.
If this is indeed the problem, I can think of two similar solutions, both apparently supported by sqlite:
SELECT bla FROM ble WHERE somthing IN (SELECT id FROM tasks WHERE condition)instead of using the list of IDs explicitly.Does any of this make sense, or am I reading the problem all wrong? If so, I could try to explore the alternatives.
I finally got around to trying out @rafacamargo123’s plugin, and it works, with my 1300+ sample tasks in 10 columns at 117-153 tasks per column. In fact, it works so well, and there are no user-visible side-effects (no visible paging) as far as I can tell, that I’m wondering why you’re making this a plugin instead of making it the default in core, beyond theoretical concerns? Isn’t your implementation a reasonable fix? If you want perfection, maybe it could autodetect SQLite’s reported max limit and paginate its requests to respect that?
P.s.: according to my testing (which your workaround allowed me to do), SQLite doesn’t seem to be a noticeable performance bottleneck (the board “view” is; I made a forum thread about this to avoid sidetracking this bug report), so now I don’t see the problem with continuing to use SQLite in the long run… hence why I’ve been thinking your fix could be worth promoting to be part of the core.