The helper function extracts the SQL contents as std::string from a buffer. This should make it easier to log the query in C++ code.