private Result ProcessRollback(Tokenizer tokenizer, Channel channel) { string sToken = tokenizer.GetString(); if (!sToken.Equals("WORK")) { tokenizer.Back(); } channel.Rollback(); return(new Result()); }
private Result ProcessCommit(Tokenizer c, Channel channel) { string sToken = c.GetString(); if (!sToken.Equals("WORK")) { c.Back(); } channel.Commit(); return(new Result()); }
private Result ProcessScript(Tokenizer tokenizer, Channel channel) { string sToken = tokenizer.GetString(); if (tokenizer.WasValue) { sToken = (string)tokenizer.Value; Log.ScriptToFile(this, sToken, true, channel); return(new Result()); } else { tokenizer.Back(); // try to script all: drop, insert; but no positions for cached tables return(GetScript(true, true, false, channel)); } }
private Result ProcessShutdown(Tokenizer tokenizer, Channel channel) { channel.CheckAdmin(); // don't disconnect system user; need it to save database for (int i = 1; i < _channel.Count; i++) { Channel d = (Channel)_channel[i]; if (d != null) { d.Disconnect(); } } _channel.Clear(); string token = tokenizer.GetString(); switch (token) { case "IMMEDIATELY": Close(-1); break; case "COMPACT": Close(1); break; default: tokenizer.Back(); Close(0); break; } ProcessDisconnect(tokenizer, channel); return(new Result()); }
private void ProcessCreateTable(Tokenizer tokenizer, Channel channel, bool cached) { Table t; string sToken = tokenizer.GetName(); if (cached && _log != null) { t = new Table(this, true, sToken, true); } else { t = new Table(this, true, sToken, false); } tokenizer.GetThis("("); int primarykeycolumn = -1; int column = 0; bool constraint = false; while (true) { bool identity = false; sToken = tokenizer.GetString(); if (sToken.Equals("CONSTRAINT") || sToken.Equals("PRIMARY") || sToken.Equals("FOREIGN") || sToken.Equals("UNIQUE")) { tokenizer.Back(); constraint = true; break; } string sColumn = sToken; ColumnType iType = Column.GetColumnType(tokenizer.GetString()); if (iType == ColumnType.VarChar && _ignoreCase) { iType = ColumnType.VarCharIgnoreCase; } sToken = tokenizer.GetString(); if (iType == ColumnType.DbDouble && sToken.Equals("PRECISION")) { sToken = tokenizer.GetString(); } if (sToken.Equals("(")) { // overread length do { sToken = tokenizer.GetString(); } while (!sToken.Equals(")")); sToken = tokenizer.GetString(); } bool nullable = true; if (sToken.Equals("NULL")) { sToken = tokenizer.GetString(); } else if (sToken.Equals("NOT")) { tokenizer.GetThis("NULL"); nullable = false; sToken = tokenizer.GetString(); } if (sToken.Equals("IDENTITY")) { identity = true; Trace.Check(primarykeycolumn == -1, Trace.SECOND_PRIMARY_KEY, sColumn); sToken = tokenizer.GetString(); primarykeycolumn = column; } if (sToken.Equals("PRIMARY")) { tokenizer.GetThis("KEY"); Trace.Check(identity || primarykeycolumn == -1, Trace.SECOND_PRIMARY_KEY, sColumn); primarykeycolumn = column; sToken = tokenizer.GetString(); } t.AddColumn(sColumn, iType, nullable, identity); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw Trace.Error(Trace.UnexpectedToken, sToken); } column++; } if (primarykeycolumn != -1) { t.CreatePrimaryKey(primarykeycolumn); } else { t.CreatePrimaryKey(); } if (constraint) { int i = 0; while (true) { sToken = tokenizer.GetString(); string name = "SYSTEM_CONSTRAINT" + i; i++; if (sToken.Equals("CONSTRAINT")) { name = tokenizer.GetString(); sToken = tokenizer.GetString(); } if (sToken.Equals("PRIMARY")) { tokenizer.GetThis("KEY"); AddUniqueConstraintOn(tokenizer, channel, name, t); } else if (sToken.Equals("UNIQUE")) { AddUniqueConstraintOn(tokenizer, channel, name, t); } else if (sToken.Equals("FOREIGN")) { tokenizer.GetThis("KEY"); AddForeignKeyOn(tokenizer, channel, name, t); } sToken = tokenizer.GetString(); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw Trace.Error(Trace.UnexpectedToken, sToken); } } } channel.Commit(); LinkTable(t); }
private void ProcessCreateTable(Tokenizer tokenizer, Channel channel, bool cached) { Table t; string sToken = tokenizer.GetName(); if (cached && _log != null) { t = new Table(this, true, sToken, true); } else { t = new Table(this, true, sToken, false); } tokenizer.GetThis("("); int primarykeycolumn = -1; int column = 0; bool constraint = false; while (true) { bool identity = false; sToken = tokenizer.GetString(); if (sToken.Equals("CONSTRAINT") || sToken.Equals("PRIMARY") || sToken.Equals("FOREIGN") || sToken.Equals("UNIQUE")) { tokenizer.Back(); constraint = true; break; } string sColumn = sToken; ColumnType iType = Column.GetColumnType(tokenizer.GetString()); if (iType == ColumnType.VarChar && _ignoreCase) { iType = ColumnType.VarCharIgnoreCase; } sToken = tokenizer.GetString(); if (iType == ColumnType.DbDouble && sToken.Equals("PRECISION")) { sToken = tokenizer.GetString(); } if (sToken.Equals("(")) { // overread length do { sToken = tokenizer.GetString(); } while (!sToken.Equals(")")); sToken = tokenizer.GetString(); } bool nullable = true; if (sToken.Equals("NULL")) { sToken = tokenizer.GetString(); } else if (sToken.Equals("NOT")) { tokenizer.GetThis("NULL"); nullable = false; sToken = tokenizer.GetString(); } if (sToken.Equals("IDENTITY")) { identity = true; TracingHelper.Check(primarykeycolumn == -1, TracingHelper.SECOND_PRIMARY_KEY, sColumn); sToken = tokenizer.GetString(); primarykeycolumn = column; } if (sToken.Equals("PRIMARY")) { tokenizer.GetThis("KEY"); TracingHelper.Check(identity || primarykeycolumn == -1, TracingHelper.SECOND_PRIMARY_KEY, sColumn); primarykeycolumn = column; sToken = tokenizer.GetString(); } t.AddColumn(sColumn, iType, nullable, identity); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw TracingHelper.Error(TracingHelper.UnexpectedToken, sToken); } column++; } if (primarykeycolumn != -1) { t.CreatePrimaryKey(primarykeycolumn); } else { t.CreatePrimaryKey(); } if (constraint) { int i = 0; while (true) { sToken = tokenizer.GetString(); string name = "SYSTEM_CONSTRAINT" + i; i++; if (sToken.Equals("CONSTRAINT")) { name = tokenizer.GetString(); sToken = tokenizer.GetString(); } if (sToken.Equals("PRIMARY")) { tokenizer.GetThis("KEY"); AddUniqueConstraintOn(tokenizer, channel, name, t); } else if (sToken.Equals("UNIQUE")) { AddUniqueConstraintOn(tokenizer, channel, name, t); } else if (sToken.Equals("FOREIGN")) { tokenizer.GetThis("KEY"); AddForeignKeyOn(tokenizer, channel, name, t); } sToken = tokenizer.GetString(); if (sToken.Equals(")")) { break; } if (!sToken.Equals(",")) { throw TracingHelper.Error(TracingHelper.UnexpectedToken, sToken); } } } channel.Commit(); LinkTable(t); }
private Result ProcessCommit(Tokenizer c, Channel channel) { string sToken = c.GetString(); if (!sToken.Equals("WORK")) { c.Back(); } channel.Commit(); return new Result(); }
private Result ProcessShutdown(Tokenizer tokenizer, Channel channel) { channel.CheckAdmin(); // don't disconnect system user; need it to save database for (int i = 1; i < _channel.Count; i++) { Channel d = (Channel) _channel[i]; if (d != null) { d.Disconnect(); } } _channel.Clear(); string token = tokenizer.GetString(); switch(token) { case "IMMEDIATELY": Close(-1); break; case "COMPACT": Close(1); break; default: tokenizer.Back(); Close(0); break; } ProcessDisconnect(tokenizer, channel); return new Result(); }
private Result ProcessScript(Tokenizer tokenizer, Channel channel) { string sToken = tokenizer.GetString(); if (tokenizer.WasValue) { sToken = (string) tokenizer.Value; Log.ScriptToFile(this, sToken, true, channel); return new Result(); } else { tokenizer.Back(); // try to script all: drop, insert; but no positions for cached tables return GetScript(true, true, false, channel); } }
private Result ProcessRollback(Tokenizer tokenizer, Channel channel) { string sToken = tokenizer.GetString(); if (!sToken.Equals("WORK")) { tokenizer.Back(); } channel.Rollback(); return new Result(); }