Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to detect postgresql RETURNING usage

by bart (Canon)
on Sep 08, 2010 at 13:56 UTC ( [id://859318]=note: print w/replies, xml ) Need Help??


in reply to How to detect postgresql RETURNING usage

I could check the sql query for the existence of the sub-string " RETURNING ", but we can all imaging when this will fail.
You should not test whether the query contains the word "RETURNING", but if it contains the token "RETURNING".

You can test that by properly tokenizing the string and see if one of the tokens is the word "RETURNING".

One practical approach for tokenizing (or "lexing") SQL queries has been described by Ovid in his perl.com article "lexing your data".

To speed it up when repeated often, you might reconsider caching ("memoizing") the results for the tokenization, just like DBIx::Simple does for caching SQL prepared statement handles: basically, you use a hash with the SQL statement string as the hash key.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://859318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-03-28 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found