/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processDrop(Tokenizer c, Channel channel) { channel.checkReadWrite(); channel.checkAdmin(); string sToken = c.getstring(); if (sToken.Equals("TABLE")) { sToken = c.getstring(); if (sToken.Equals("IF")) { sToken = c.getstring(); // EXISTS sToken = c.getstring(); // <table> dropTable(sToken, true); } else { dropTable(sToken, false); } channel.commit(); } else if (sToken.Equals("USER")) { aAccess.dropUser(c.getstringToken()); } else if (sToken.Equals("INDEX")) { sToken = c.getstring(); if (!c.wasLongName()) { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } string table = c.getLongNameFirst(); string index = c.getLongNameLast(); Table t = getTable(table, channel); t.checkDropIndex(index); Table tn = t.moveDefinition(index); tn.moveData(t); dropTable(table); linkTable(tn); channel.commit(); } else { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } return(new Result()); }
/** * Method declaration * * * @param c * @param channel * @param grant * * @return * * @throws Exception */ private Result processGrantOrRevoke(Tokenizer c, Channel channel, bool grant) { channel.checkReadWrite(); channel.checkAdmin(); int right = 0; string sToken; do { string sRight = c.getstring(); right |= Access.getRight(sRight); sToken = c.getstring(); } while (sToken.Equals(",")); if (!sToken.Equals("ON")) { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } string table = c.getstring(); if (table.Equals("CLASS")) { // object is saved as 'CLASS "java.lang.Math"' // tables like 'CLASS "xy"' should not be created table += " \"" + c.getstring() + "\""; } else { getTable(table, channel); // to make sure the table exists } c.getThis("TO"); string user = c.getstringToken(); // string command; if (grant) { aAccess.grant(user, table, right); // command = "GRANT"; } else { aAccess.revoke(user, table, right); // command = "REVOKE"; } return(new Result()); }
/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processCreate(Tokenizer c, Channel channel) { channel.checkReadWrite(); channel.checkAdmin(); string sToken = c.getstring(); if (sToken.Equals("TABLE")) { processCreateTable(c, channel, false); } else if (sToken.Equals("MEMORY")) { c.getThis("TABLE"); processCreateTable(c, channel, false); } else if (sToken.Equals("CACHED")) { c.getThis("TABLE"); processCreateTable(c, channel, true); } else if (sToken.Equals("USER")) { string u = c.getstringToken(); c.getThis("PASSWORD"); string p = c.getstringToken(); bool admin; if (c.getstring().Equals("ADMIN")) { admin = true; } else { admin = false; } aAccess.createUser(u, p, admin); } else if (sToken.Equals("ALIAS")) { string name = c.getstring(); sToken = c.getstring(); Trace.check(sToken.Equals("FOR"), Trace.UNEXPECTED_TOKEN, sToken); sToken = c.getstring(); hAlias.Add(name, sToken); } else { bool unique = false; if (sToken.Equals("UNIQUE")) { unique = true; sToken = c.getstring(); } if (!sToken.Equals("INDEX")) { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } string name = c.getName(); c.getThis("ON"); Table t = getTable(c.getstring(), channel); addIndexOn(c, channel, name, t, unique); } return(new Result()); }
/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processSet(Tokenizer c, Channel channel) { string sToken = c.getstring(); if (sToken.Equals("PASSWORD")) { channel.checkReadWrite(); channel.setPassword(c.getstringToken()); } else if (sToken.Equals("READONLY")) { channel.commit(); channel.setReadOnly(processTrueOrFalse(c)); } else if (sToken.Equals("LOGSIZE")) { channel.checkAdmin(); int i = Int32.FromString(c.getstring()); if (lLog != null) { lLog.setLogSize(i); } } else if (sToken.Equals("IGNORECASE")) { channel.checkAdmin(); bIgnoreCase = processTrueOrFalse(c); } else if (sToken.Equals("MAXROWS")) { int i = Int32.FromString(c.getstring()); channel.setMaxRows(i); } else if (sToken.Equals("AUTOCOMMIT")) { channel.setAutoCommit(processTrueOrFalse(c)); } else if (sToken.Equals("TABLE")) { channel.checkReadWrite(); channel.checkAdmin(); Table t = getTable(c.getstring(), channel); c.getThis("INDEX"); c.getstring(); t.setIndexRoots((string)c.getAsValue()); } else if (sToken.Equals("REFERENCIAL_INTEGRITY") || sToken.Equals("REFERENTIAL_INTEGRITY")) { channel.checkAdmin(); bReferentialIntegrity = processTrueOrFalse(c); } else if (sToken.Equals("WRITE_DELAY")) { channel.checkAdmin(); bool delay = processTrueOrFalse(c); if (lLog != null) { lLog.setWriteDelay(delay); } } else { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } return(new Result()); }