/** * Method declaration * * * @param statement * @param channel * * @return */ public Result execute(string statement, Channel channel) { if (Trace.TRACE) { Trace.trace(statement); } Tokenizer c = new Tokenizer(statement); Parser p = new Parser(this, c, channel); Result rResult = new Result(); try { if (lLog != null && lLog.cCache != null) { lLog.cCache.cleanUp(); } if (Trace.ASSERT) { Trace.assert(!channel.isNestedTransaction()); } Trace.check(channel != null, Trace.ACCESS_IS_DENIED); Trace.check(!bShutdown, Trace.DATABASE_IS_SHUTDOWN); while (true) { int begin = c.getPosition(); bool script = false; string sToken = c.getstring(); if (sToken.Equals("")) { break; } else if (sToken.Equals("SELECT")) { rResult = p.processSelect(); } else if (sToken.Equals("INSERT")) { rResult = p.processInsert(); } else if (sToken.Equals("UPDATE")) { rResult = p.processUpdate(); } else if (sToken.Equals("DELETE")) { rResult = p.processDelete(); } else if (sToken.Equals("ALTER")) { rResult = p.processAlter(); } else if (sToken.Equals("CREATE")) { rResult = processCreate(c, channel); script = true; } else if (sToken.Equals("DROP")) { rResult = processDrop(c, channel); script = true; } else if (sToken.Equals("GRANT")) { rResult = processGrantOrRevoke(c, channel, true); script = true; } else if (sToken.Equals("REVOKE")) { rResult = processGrantOrRevoke(c, channel, false); script = true; } else if (sToken.Equals("CONNECT")) { rResult = processConnect(c, channel); } else if (sToken.Equals("DISCONNECT")) { rResult = processDisconnect(c, channel); } else if (sToken.Equals("SET")) { rResult = processSet(c, channel); script = true; } else if (sToken.Equals("SCRIPT")) { rResult = processScript(c, channel); } else if (sToken.Equals("COMMIT")) { rResult = processCommit(c, channel); script = true; } else if (sToken.Equals("ROLLBACK")) { rResult = processRollback(c, channel); script = true; } else if (sToken.Equals("SHUTDOWN")) { rResult = processShutdown(c, channel); } else if (sToken.Equals("CHECKPOINT")) { rResult = processCheckpoint(channel); } else if (sToken.Equals("CALL")) { rResult = p.processCall(); } else if (sToken.Equals(";")) { // ignore } else { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } if (script && lLog != null) { int end = c.getPosition(); lLog.write(channel, c.getPart(begin, end)); } } } catch (Exception e) { rResult = new Result(Trace.getMessage(e) + " in statement [" + statement + "]"); } return(rResult); }