private Result ProcessDrop(Tokenizer tokenizer, Channel channel) { channel.CheckReadWrite(); channel.CheckAdmin(); string sToken = tokenizer.GetString(); if (sToken.Equals("TABLE")) { sToken = tokenizer.GetString(); if (sToken.Equals("IF")) { sToken = tokenizer.GetString(); // EXISTS sToken = tokenizer.GetString(); // <table> DropTable(sToken, true); } else { DropTable(sToken, false); } channel.Commit(); } else if (sToken.Equals("USER")) { _access.DropUser(tokenizer.GetStringToken()); } else if (sToken.Equals("INDEX")) { sToken = tokenizer.GetString(); if (!tokenizer.WasLongName) { throw Trace.Error(Trace.UnexpectedToken, sToken); } string table = tokenizer.LongNameFirst; string index = tokenizer.LongNameLast; 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.UnexpectedToken, sToken); } return(new Result()); }
private void CreateIndex(Channel channel, Table t, int[] col, string name, bool unique) { channel.Commit(); if (t.IsEmpty) { t.CreateIndex(col, name, unique); } else { Table tn = t.MoveDefinition(null); tn.CreateIndex(col, name, unique); tn.MoveData(t); DropTable(t.Name); LinkTable(tn); } }