List:Internals« Previous MessageNext Message »
From:Dmitry Lenev Date:January 18 2013 9:53am
Subject:Re: detecting select SQL statements that are functions
View as plain text  
Hello Zardosht!

* Zardosht Kasheff <zardosht@stripped> [13/01/18 08:52]:
> 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,
> "read-only".
> 
> In MySQL 5.6, InnoDB seems to do this with the function thd_trx_is_auto_commit.
> 
> 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
> function?

You can try using thd->lex->uses_stored_routines() method.
Unfortunately, it is not exposed to SEs at the moment in the way similar
to thd->lex->sql_command, so you will have to add wrapper function for
uses_stored_routines() similar to thd_sql_command() to server code yourself.

Best regards,
Dmitry

-- 
Dmitry Lenev, Software Developer
Oracle Development SPB/MySQL, www.mysql.com

Are you MySQL certified?  http://www.mysql.com/certification
Thread
detecting select SQL statements that are functionsZardosht Kasheff18 Jan
  • Re: detecting select SQL statements that are functionsDmitry Lenev18 Jan
  • Re: detecting select SQL statements that are functionsSergei Golubchik18 Jan
    • Re: detecting select SQL statements that are functionsDmitry Lenev18 Jan
      • Re: detecting select SQL statements that are functionsSergei Golubchik18 Jan
        • Re: detecting select SQL statements that are functionsDmitry Lenev18 Jan
Re: detecting select SQL statements that are functionsZardosht Kasheff18 Jan