Address outstanding review findings for FFTO on v3.0-ff_inspect and tighten
protocol-state correctness for both engines.
MySQL FFTO
- Restrict on_close() reporting to true in-flight states and always clear query
tracking state after close.
- Add explicit active-query cleanup helpers and invoke them on state transitions
to IDLE.
- Preserve accounting on mid-resultset server ERR packets by reporting current
query in READING_COLUMNS/READING_ROWS before reset.
- Keep prepared-statement lifecycle cleanup robust (pending prepare cleared on
prepare completion paths).
MySQL session integration
- Extract duplicated FAST_FORWARD client FFTO feed logic into
observe_ffto_client_packet() and reuse it from all call sites.
PostgreSQL FFTO
- Replace regex-based CommandComplete parsing with lightweight token parsing,
including NUL/whitespace trimming and strict numeric validation.
- Add queued tracking for pipelined extended-protocol executes so query text and
response attribution stay aligned under Parse/Bind/Execute pipelining.
- Distinguish finalize semantics (execute-finalize on CommandComplete vs
sync-finalize on ReadyForQuery) and centralize finalize/activation helpers.
- Add frontend Close ('C') handling to evict statement/portal mappings.
- Harden client/server message parsing with additional length checks.
- Extend affected-row command tag coverage to COPY and MERGE.
TAP tests
- Stabilize test plans for failure paths by replacing early returns with a
fail-and-skip-remaining flow and shared cleanup labels.
- Ensure both MySQL and PgSQL FFTO tests preserve planned assertion counts under
setup/prepare/execute failures.
Documentation
- Align FFT0 design doc state/response descriptions with current implementation
(ReadyForQuery handling, pipelined queueing, supported PG command tags).
- Fix wording/typo issues in protocol section.
Validation performed
- make -C lib -j4
- make -C test/tap/tests test_ffto_mysql-t test_ffto_pgsql-t -j4
Runtime execution of the two TAP binaries remains environment-dependent (admin
endpoint connectivity required).
- **Extended Query Tracking**: Tracks the association between Portals and Prepared Statements, and queues pipelined executes so responses are attributed to the correct query text.
## 5. Protocol and Security Details
- **Encryption**: FFTO operates on protocol packets that are already decrypted by ProxySQL's session handler. This allows ProxySQL to mix encrypted and unencrypted backend/frontend connections while maintaining consistent monitoring in FF mode.
@ -84,9 +84,10 @@ To verify that FFTO is capturing traffic in Fast Forward mode:
## 8. Protocol Support
- **Text and Binary Protocols**: FFTO supports both standard text-based queries and the binary protocol used by prepared statements.
- **MySQL Binary Protocol**: Corrects captures `COM_STMT_PREPARE` and `COM_STMT_EXECUTE`, tracking statement IDs to their respective SQL text.
- **MySQL Binary Protocol**: Correctly captures `COM_STMT_PREPARE` and `COM_STMT_EXECUTE`, tracking statement IDs to their respective SQL text.
- **PostgreSQL Extended Query**: Supports the multi-phase `Parse` -> `Bind` -> `Execute` sequence by tracking Statement and Portal mappings.
## 9. Limitations
- **Large Payloads**: Packets exceeding the `*-ffto_max_buffer_size` threshold cause FFTO to be bypassed for that session.
- **X-Protocol**: Currently optimized for classic MySQL and PostgreSQL protocols.
- **PostgreSQL Command Tags**: `sum_rows_affected`/`sum_rows_sent` are derived from `CommandComplete` tags and currently cover common commands (`INSERT`, `UPDATE`, `DELETE`, `COPY`, `MERGE`, `SELECT`, `FETCH`, `MOVE`).