Repository navigation
fix: apply the Filter and date range to single-threaded reports - #349
TheWitness wants to merge 1 commit into
Conversation
With Max Concurrent Threads at 1, run_flow_query() built the WHERE of a partition only for reports with two map queries, and there it appended the date range to an empty string: with a Filter field set the query began ' AND (end_time ...)' and failed, and the Filter itself was lost. Reports with one map query had no WHERE at all, so the Filter and the date range were ignored. Build the WHERE once per partition for both report shapes, as the parallel path does. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
There was a problem hiding this comment.
🟡 Changes recommended
One-map reports fail with an SQL syntax error when Listener is All and a specific Stream is selected because the Stream clause lacks WHERE; the fix and a regression test are needed.
1 open issue
What changed in this PR
Corrects FlowView’s single-threaded report queries so partition reads apply saved Filters and the requested date range.
Changes:
- Builds partition predicates before branching between one-map and two-map reports.
- Adds regression coverage for both report shapes and parameter counts.
- Documents the fix in the changelog.
| File | Description |
|---|---|
tests/Unit/ParallelQueryPathTest.php |
Tests Filter and date predicates in single-threaded queries. |
includes/functions.php |
Shares partition predicate construction across report shapes. |
CHANGELOG.md |
Records the single-threaded reporting fix. |
Review effort: Balanced
| $fsql_params = $sql_params; | ||
| } | ||
| if (!$full_scan) { | ||
| $fsql_where = $sql_where . ($sql_where != '' ? ' AND ':'WHERE ') . $sql_range; |
somethingwithproof
left a comment
There was a problem hiding this comment.
Approving. Reproduced on develop: with Max Concurrent Threads disabled, a one-map report read every row (filter and range ignored) and a two-map report failed with a SQL syntax error. On this head the serial and parallel paths build the same WHERE clause and parameters per partition and return identical results on MariaDB 10.11 and MySQL 8.4; filter values are parameterized. The new test fails on develop and passes here on PHP 8.2 and 8.6.
Nit: the serial path still uses its own full-scan test without the live-partition guard flowview_is_full_scan() applies on the parallel path (includes/functions.php:3989). Results are correct; it's a consistency point for later.
This should merge before #297, whose Applications filter has the same single-thread gap.




Problem
With Max Concurrent Threads (
flowview_parallel_threads) set to 1,run_flow_query()builds the per-partition WHERE incorrectly:$fsql_where. Every partition the time span touched was read in full, and the Filter's fields and the date range were ignored.FROM plugin_flowview_raw_? AND (end_time ?)and failed with an SQL error. Without one, it producedWHERE (range)and worked only by accident.The parallel path (
threads > 1) was already correct.Fix
Build the WHERE once per partition, before branching on the report shape, the same way the parallel path does:
$sql_where, thenAND/WHERE, then$sql_range. Full scans keep only$sql_where.Tests
tests/Unit/ParallelQueryPathTest.phpcovering a one-map and a two-map report with a protocol Filter over a partial range. It asserts that everyFROMpartition carries the Filter and the date range, and that the bound parameters match the placeholders. It fails ondevelopand passes with the fix.Found while reworking the NBAR support for #297.