// Copyright (c) 1999-2001 David Muse // See the file COPYING for more information #include #include bool sqlrcursor_svr::queryIsNotSelect() { // scan the query, bypassing whitespace and comments. char *ptr=skipWhitespaceAndComments(querybuffer); // if the query is a select but not a select into then return false, // otherwise return true if (!charstring::compareIgnoringCase(ptr,"select",6) && charstring::compareIgnoringCase(ptr,"select into ",12)) { return false; } return true; } bool sqlrcursor_svr::queryIsCommitOrRollback() { // scan the query, bypassing whitespace and comments. char *ptr=skipWhitespaceAndComments(querybuffer); // if the query is a commit or rollback, return true // otherwise return false return (!charstring::compareIgnoringCase(ptr,"commit",6) || !charstring::compareIgnoringCase(ptr,"rollback",8)); } char *sqlrcursor_svr::skipWhitespaceAndComments(const char *querybuffer) { // scan the query, bypassing whitespace and comments. char *ptr=(char *)querybuffer; while (*ptr && (*ptr==' ' || *ptr=='\n' || *ptr==' ' || *ptr=='-')) { // skip any comments if (*ptr=='-') { while (*ptr && *ptr!='\n') { ptr++; } } ptr++; } return ptr; } void sqlrcursor_svr::checkForTempTable(const char *query, uint32_t length) { char *ptr=(char *)query; char *endptr=(char *)query+length; // skip any leading comments if (!skipWhitespace(&ptr,endptr) || !skipComment(&ptr,endptr) || !skipWhitespace(&ptr,endptr)) { return; } // see if the query matches the pattern for a temporary query that // creates a temporary table if (createtemp.match(ptr)) { ptr=createtemp.getSubstringEnd(0); } else { return; } // get the table name stringbuffer tablename; while (ptr && *ptr && *ptr!=' ' && *ptr!='\n' && *ptr!=' ' && ptraddSessionTempTableForDrop(tablename.getString()); } bool sqlrcursor_svr::skipComment(char **ptr, const char *endptr) { while (*ptr