>>>>> "Eric" == Eric <esquid2@stripped> writes:
Eric> Hi All-
Eric> AFAICT, query comments are used as part of the hash key for query cache (at
Eric> least in 5.0). Is this intentional? Still the case in newer versions of
Yes; It's mainly for speed but also because comments can affect the
way queries are executed (if you use optimizer hints)
Eric> I have a patch (attached) to strip comments before checking and storing the
Eric> query into the query cache but wanted to see if this was a reasonable way to
Eric> do it. Also, I couldn't find a very reasonable function to strip comments.
Eric> (The one in innobase/hash/hash0hash.c seemed the best, but I imagine it is
Eric> not fit to include so I copied it just to get my proof-of-concept working
Eric> until/if something better is decided.)
Don't know of any other function to do that.
Eric> If this seems useful and reasonable, is there a better way to get the
Eric> comments stripped? Should I implement my own? (Should be able to be done
Eric> in the existing char* without allocating any new memory, right?)
If you *only* strip safe comments (not using the /*!...*/ syntax you
can strip it in the original memory.
Eric> InnoDB (what we use) or any other engine depend on the comments in any way
Eric> (I know oracle puts query hints in there)? How should this behavior be
Eric> enabled since I imagine not everyone will want the runtime v. cache hit
Eric> tradeoff. ./configure option? my.cnf? a dynamic variable?
You should have this either as a dynamic variable or a connection
option. This is to not cause an extra parsing overhead in the case
where comments are static for the query.