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.