From: Dmitry Lenev Date: January 18 2013 9:53am Subject: Re: detecting select SQL statements that are functions List-Archive: http://lists.mysql.com/internals/38687 Message-Id: <20130118095347.GD12515@jubjub> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hello Zardosht! * Zardosht Kasheff [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