[1.6.x] Fixed #18592 -- Prevented crash when accessing MySQL _last_executed

Thanks reames at asymmetricventures.com for the report.
Backport of 59b0c48ce from master.