/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processRollback(Tokenizer c, Channel channel) { string sToken = c.getstring(); if (!sToken.Equals("WORK")) { c.back(); } channel.rollback(); return(new Result()); }
/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processScript(Tokenizer c, Channel channel) { string sToken = c.getstring(); if (c.wasValue()) { sToken = (string)c.getAsValue(); Log.scriptToFile(this, sToken, true, channel); return(new Result()); } else { c.back(); // try to script all: drop, insert; but no positions for cached tables return(getScript(true, true, false, channel)); } }
/** * Method declaration * * * @param c * @param channel * * @return * * @throws Exception */ private Result processShutdown(Tokenizer c, Channel channel) { channel.checkAdmin(); // don't disconnect system user; need it to save database for (int i = 1; i < cChannel.Count; i++) { Channel d = (Channel)cChannel[i]; if (d != null) { d.disconnect(); } } cChannel.Clear(); string token = c.getstring(); if (token.Equals("IMMEDIATELY")) { close(-1); } else if (token.Equals("COMPACT")) { close(1); } else { c.back(); close(0); } processDisconnect(c, channel); return(new Result()); }
/** * Method declaration * * * @param c * @param channel * @param cached * * @throws Exception */ private void processCreateTable(Tokenizer c, Channel channel, bool cached) { Table t; string sToken = c.getName(); if (cached && lLog != null) { t = new Table(this, true, sToken, true); } else { t = new Table(this, true, sToken, false); } c.getThis("("); int primarykeycolumn = -1; int column = 0; bool constraint = false; while (true) { bool identity = false; sToken = c.getstring(); if (sToken.Equals("CONSTRAINT") || sToken.Equals("PRIMARY") || sToken.Equals("FOREIGN") || sToken.Equals("UNIQUE")) { c.back(); constraint = true; break; } string sColumn = sToken; int iType = Column.getTypeNr(c.getstring()); if (iType == Column.VARCHAR && bIgnoreCase) { iType = Column.VARCHAR_IGNORECASE; } sToken = c.getstring(); if (iType == Column.DOUBLE && sToken.Equals("PRECISION")) { sToken = c.getstring(); } if (sToken.Equals("(")) { // overread length do { sToken = c.getstring(); } while (!sToken.Equals(")")); sToken = c.getstring(); } bool nullable = true; if (sToken.Equals("NULL")) { sToken = c.getstring(); } else if (sToken.Equals("NOT")) { c.getThis("NULL"); nullable = false; sToken = c.getstring(); } if (sToken.Equals("IDENTITY")) { identity = true; Trace.check(primarykeycolumn == -1, Trace.SECOND_PRIMARY_KEY, sColumn); sToken = c.getstring(); primarykeycolumn = column; } if (sToken.Equals("PRIMARY")) { c.getThis("KEY"); Trace.check(identity || primarykeycolumn == -1, Trace.SECOND_PRIMARY_KEY, sColumn); primarykeycolumn = column; sToken = c.getstring(); } t.addColumn(sColumn, iType, nullable, identity); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } column++; } if (primarykeycolumn != -1) { t.createPrimaryKey(primarykeycolumn); } else { t.createPrimaryKey(); } if (constraint) { int i = 0; while (true) { sToken = c.getstring(); string name = "SYSTEM_CONSTRAINT" + i; i++; if (sToken.Equals("CONSTRAINT")) { name = c.getstring(); sToken = c.getstring(); } if (sToken.Equals("PRIMARY")) { c.getThis("KEY"); addUniqueConstraintOn(c, channel, name, t); } else if (sToken.Equals("UNIQUE")) { addUniqueConstraintOn(c, channel, name, t); } else if (sToken.Equals("FOREIGN")) { c.getThis("KEY"); addForeignKeyOn(c, channel, name, t); } sToken = c.getstring(); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw Trace.error(Trace.UNEXPECTED_TOKEN, sToken); } } } channel.commit(); linkTable(t); }