DEV Community

Mads Hansen
Mads Hansen

Posted on

Your MySQL connection may answer the same AI question differently

A MySQL connection can succeed while the answer depends on whichever session the pool handed to the AI.

One connection uses UTC and strict SQL mode.

Another inherited a local time zone, permissive grouping rules, or a different collation.

The SQL executes in both sessions. The meaning is no longer the same.

Treat the session as a versioned runtime contract:

  • approved database and authenticated role
  • time zone and reporting cutoff
  • SQL mode
  • character set and collation
  • transaction isolation and read-only state
  • row, time, and result-size limits

Initialize those values outside model control, verify the effective session before use, and attach a normalized contract fingerprint to the operation trace.

For pooled connections, rollback open transactions, clear workflow-owned state, reapply the baseline, and reject the checkout when verification fails.

Then test pairs that should agree: new versus reused connections, changed server defaults, strict versus missing SQL modes, international text comparisons, and a prior request that deliberately dirties the session.

β€œThe query ran” is not the acceptance criterion. The same governed question should preserve the same execution semantics.

Full guide: How to connect MySQL to ChatGPT with a session contract

Top comments (0)