PREPARSE_execute @brief @param status @param ptrAtt @param stmt_length @param stmt @param stmt_eaten @param dialect **/
| 156 | |
| 157 | **/ |
| 158 | bool PREPARSE_execute(CheckStatusWrapper* status, Why::YAttachment** ptrAtt, |
| 159 | string& stmt, bool* stmt_eaten, USHORT dialect) |
| 160 | { |
| 161 | // no use creating separate pool for a couple of strings |
| 162 | ContextPoolHolder context(getDefaultMemoryPool()); |
| 163 | |
| 164 | try |
| 165 | { |
| 166 | if (stmt.isEmpty()) |
| 167 | { |
| 168 | return false; // let others care |
| 169 | } |
| 170 | |
| 171 | bool hasUser = true; |
| 172 | status->init(); |
| 173 | for (int qStrip = 0; qStrip < 2; ++qStrip) |
| 174 | { |
| 175 | hasUser = false; |
| 176 | |
| 177 | Tokens tks; |
| 178 | tks.quotes(quotes); |
| 179 | tks.parse(stmt.length(), stmt.c_str()); |
| 180 | |
| 181 | for (int tokenPos = tks.getCount() - 1; tokenPos >= 0; --tokenPos) |
| 182 | { |
| 183 | const Tokens::Tok& token = tks[tokenPos]; |
| 184 | |
| 185 | if (token.length > 0 && token.text[0] == '"') |
| 186 | { |
| 187 | string newToken = "'"; |
| 188 | |
| 189 | for (unsigned i = 1; i < token.length - 1; ++i) |
| 190 | { |
| 191 | switch (token.text[i]) |
| 192 | { |
| 193 | case '\'': |
| 194 | newToken += "''"; |
| 195 | break; |
| 196 | |
| 197 | case '"': |
| 198 | ++i; |
| 199 | newToken += '"'; |
| 200 | break; |
| 201 | |
| 202 | default: |
| 203 | newToken += token.text[i]; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | newToken += "'"; |
| 208 | stmt.replace(token.origin, token.length, newToken); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | unsigned pos = 0; |
| 213 | |
| 214 | if (getToken(pos, tks) != pp_symbols[PP_CREATE].symbol) |
| 215 | { |
no test coverage detected