On Jan 17, Zardosht Kasheff wrote:
> Hello all,
> In our storage engine's handler, we would like to be able to detect
> when a statement is just a simple select statement, that is,
> In MySQL 5.6, InnoDB seems to do this with the function
I don't think so. thd_trx_is_auto_commit() (judging from the name, not
looking at the source) will check if the transaction will auto-commit.
An INSERT or UPDATE in the auto-commit mode will auto-commit too.
To detect read-only statements reliably, you should look at the table
locks. in external_lock or in the store_lock method.
If no table was locked for writing (yes, you downgrade locks to
TL_WRITE_ALLOW_WRITE, but I mean the original lock level here), then no
table will be modified by this statement. No TokuDB table, at least.
This works for all statements, selects, multi-table deletes/updates,
insert...select, invoked stored functions, triggers, everything.
> We have tried to do something similar in MySQL 5.5.
> The problem we run into is when the select statement is a function,
> and the function performs a write. With the thd, is there a way to
> detect that the statement is not a simple select, but rather calling a