示例#1
0
        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());
        }
示例#2
0
        private Result ProcessCommit(Tokenizer c,
                                     Channel channel)
        {
            string sToken = c.GetString();

            if (!sToken.Equals("WORK"))
            {
                c.Back();
            }

            channel.Commit();

            return(new Result());
        }
示例#3
0
        private Result ProcessConnect(Tokenizer c,
                                      Channel channel)
        {
            c.GetThis("USER");

            string username = c.GetStringToken();

            c.GetThis("PASSWORD");

            string password = c.GetStringToken();
            User   user     = _access.GetUser(username, password);

            channel.Commit();
            channel.SetUser(user);

            return(new Result());
        }
示例#4
0
        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);
            }
        }
示例#5
0
        private Result ProcessShow(Tokenizer tokenizer, Channel channel)
        {
            Result r = new Result(1);

            string sToken = tokenizer.GetString();

            if (sToken.Equals("TABLES"))
            {
                System.Collections.ArrayList al = channel.Database.Tables;
                r.Label[0] = "TABLE";
                r.Type[0]  = ColumnType.VarChar;
                for (int x = 0; x < al.Count; x++)
                {
                    Table    table     = (Table)al[x];
                    string[] tablename = new string [1];
                    tablename[0] = table.Name;
                    r.Add(tablename);
                }
                channel.Commit();
            }
            else if (sToken.Equals("DATABASES"))
            {
                r.Label[0] = "DATABASE";
                r.Type[0]  = ColumnType.VarChar;

                System.IO.DirectoryInfo di = new
                                             System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                System.IO.FileInfo[] rgFiles = di.GetFiles("*.data");
                foreach (System.IO.FileInfo fi in rgFiles)
                {
                    string[] databaseName = new string [1];
                    databaseName[0] = fi.Name.ToUpper().Replace(".DATA", "");
                    r.Add(databaseName);
                }

                channel.Commit();
            }
            else if (sToken.Equals("ALIAS"))
            {
                r          = new Result(2);
                r.Label[0] = "NAME";
                r.Type[0]  = ColumnType.VarChar;
                r.Label[1] = "LIBRARY";
                r.Type[1]  = ColumnType.VarChar;

                foreach (DictionaryEntry entry in _alias)
                {
                    string[] alias = new string [2];
                    alias[0] = entry.Key.ToString();
                    alias[1] = entry.Value.ToString();
                    r.Add(alias);
                }

                channel.Commit();
            }
            else if (sToken.Equals("PARAMETERS"))
            {
                string alias = tokenizer.GetString().ToUpper();

                if (!_alias.ContainsKey(alias))
                {
                    throw Trace.Error(Trace.UNKNOWN_FUNCTION, alias);
                }

                string fqn = _alias[alias].ToString();

                Function f = new Function(fqn, channel);

                System.Reflection.MethodInfo mi = f.GetMethodInfo(fqn);

                r          = new Result(4);
                r.Label[0] = "ALIAS";
                r.Type[0]  = ColumnType.VarChar;
                r.Label[1] = "PARAMETER";
                r.Type[1]  = ColumnType.VarChar;
                r.Label[2] = "TYPE";
                r.Type[2]  = ColumnType.VarChar;
                r.Label[3] = "POSITION";
                r.Type[3]  = ColumnType.Integer;

                System.Reflection.ParameterInfo[] parms = mi.GetParameters();

                int rt = 0;

                if (mi.ReturnType != null)
                {
                    object[] p = new object[4];
                    p[0] = alias;
                    p[1] = "RETURN_VALUE";
                    p[2] = Column.GetColumnTypeString(Function.GetDataType(mi.ReturnType));
                    p[3] = 0;
                    r.Add(p);
                    rt = 1;
                }

                foreach (System.Reflection.ParameterInfo pi in parms)
                {
                    object[] p = new object[4];
                    p[0] = alias;
                    p[1] = pi.Name;
                    p[2] = Column.GetColumnTypeString(Function.GetDataType(pi.ParameterType));
                    p[3] = (pi.Position + rt);
                    r.Add(p);
                }

                channel.Commit();
            }
            else if (sToken.Equals("COLUMNS"))
            {
                string t        = tokenizer.GetString().ToUpper();
                Table  theTable = null;

                foreach (Table table in channel.Database.Tables)
                {
                    if (table.Name.ToUpper() == t)
                    {
                        theTable = table;
                        break;
                    }
                }

                if (theTable == null)
                {
                    throw Trace.Error(Trace.TABLE_NOT_FOUND, t);
                }

                r          = new Result(7);
                r.Label[0] = "TABLE";
                r.Type[0]  = ColumnType.VarChar;
                r.Label[1] = "COLUMN";
                r.Type[1]  = ColumnType.VarChar;
                r.Label[2] = "NATIVETYPE";
                r.Type[2]  = ColumnType.VarChar;
                r.Label[3] = "DBTYPE";
                r.Type[3]  = ColumnType.Integer;
                r.Label[4] = "POSITION";
                r.Type[4]  = ColumnType.Integer;
                r.Label[5] = "NULLABLE";
                r.Type[5]  = ColumnType.Bit;
                r.Label[6] = "IDENTITY";
                r.Type[6]  = ColumnType.Bit;

                for (int ix = 0; ix < theTable.ColumnCount; ix++)
                {
                    Column   col     = theTable.GetColumn(ix);
                    object[] coldata = new object[7];
                    coldata[0] = theTable.Name;
                    coldata[1] = col.Name;
                    coldata[2] = Column.GetColumnTypeString(col.ColumnType);
                    coldata[3] = Column.GetDbType(col.ColumnType);
                    coldata[4] = ix;
                    coldata[5] = col.IsNullable;
                    coldata[6] = col.IsIdentity;
                    r.Add(coldata);
                }
                channel.Commit();
            }
            else
            {
                throw Trace.Error(Trace.UnexpectedToken, sToken);
            }

            return(r);
        }
示例#6
0
        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);
        }
示例#7
0
        private Result ProcessSet(Tokenizer tokenizer, Channel channel)
        {
            string sToken = tokenizer.GetString();

            switch (sToken)
            {
            case "PASSWORD":
                channel.CheckReadWrite();
                channel.SetPassword(tokenizer.GetStringToken());
                break;

            case "READONLY":
                channel.Commit();
                channel.SetReadOnly(ProcessTrueOrFalse(tokenizer));
                break;

            case "LOGSIZE":
            {
                channel.CheckAdmin();

                int i = Int32.Parse(tokenizer.GetString());

                if (_log != null)
                {
                    _log.SetLogSize(i);
                }
            }
            break;

            case "IGNORECASE":
                channel.CheckAdmin();
                _ignoreCase = ProcessTrueOrFalse(tokenizer);
                break;

            case "MAXROWS":
            {
                int i = Int32.Parse(tokenizer.GetString());
                channel.MaxRows = i;
                break;
            }

            case "AUTOCOMMIT":
                channel.SetAutoCommit(ProcessTrueOrFalse(tokenizer));
                break;

            case "TABLE":
            {
                channel.CheckReadWrite();
                channel.CheckAdmin();

                Table t = GetTable(tokenizer.GetString(), channel);

                tokenizer.GetThis("INDEX");
                tokenizer.GetString();
                t.IndexRoots = (string)tokenizer.Value;
            }
            break;

            case "REFERENCIAL_INTEGRITY":
            case "REFERENTIAL_INTEGRITY":
                channel.CheckAdmin();
                _referentialIntegrity = ProcessTrueOrFalse(tokenizer);
                break;

            case "WRITE_DELAY":
            {
                channel.CheckAdmin();

                bool delay = ProcessTrueOrFalse(tokenizer);

                if (_log != null)
                {
                    _log.SetWriteDelay(delay);
                }
            }
            break;

            default:
                if (tokenizer.TokenType == TokenType.VARIABLE)
                {
                    Parser p = new Parser(this, tokenizer, channel);
                    p.ProcessSet(sToken);
                    break;
                }

                throw Trace.Error(Trace.UnexpectedToken, sToken);
            }

            return(new Result());
        }
示例#8
0
文件: sql.cs 项目: Myvar/Eclang
 public void commit(Channel myChannel)
 {
     myChannel.Commit();
 }
示例#9
0
        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);
        }
示例#10
0
        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 TracingHelper.Error(TracingHelper.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 TracingHelper.Error(TracingHelper.UnexpectedToken, sToken);
            }

            return new Result();
        }
示例#11
0
        private Result ProcessConnect(Tokenizer c,
            Channel channel)
        {
            c.GetThis("USER");

            string username = c.GetStringToken();

            c.GetThis("PASSWORD");

            string password = c.GetStringToken();
            User   user = _access.GetUser(username, password);

            channel.Commit();
            channel.SetUser(user);

            return new Result();
        }
示例#12
0
        private Result ProcessCommit(Tokenizer c,
            Channel channel)
        {
            string sToken = c.GetString();

            if (!sToken.Equals("WORK"))
            {
                c.Back();
            }

            channel.Commit();

            return new Result();
        }
示例#13
0
        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);
            }
        }
示例#14
0
        private Result ProcessShow(Tokenizer tokenizer, Channel channel)
        {
            Result r = new Result(1);

            string sToken = tokenizer.GetString();

            if (sToken.Equals("TABLES"))
            {
                r.Table[0] = "SYSTEM_TABLES";
                r.Label[0] = "TABLE_NAME";
                System.Collections.ArrayList al = channel.Database.Tables;
                //r.Label[0] = "TABLE";
                r.Type[0] = ColumnType.VarChar;
                for(int x=0;x<al.Count;x++)
                {
                    Table table = (Table)al[x];
                    string[] tablename = new string [1];
                    tablename[0]=table.Name;
                    r.Add(tablename);
                }
                channel.Commit();
            }
            else if (sToken.Equals("DATABASES"))
            {
                r.Table[0] = "SYSTEM_DATABASES";
                r.Label[0] = "DATABASE";
                r.Type[0] = ColumnType.VarChar;

                System.IO.DirectoryInfo di = new
                    System.IO.DirectoryInfo(System.IO.Directory.GetCurrentDirectory());
                System.IO.FileInfo[] rgFiles = di.GetFiles("*.data");
                foreach(System.IO.FileInfo fi in rgFiles)
                {

                    string[] databaseName = new string [1];
                    databaseName[0]=fi.Name.ToUpper().Replace(".DATA","");
                    r.Add(databaseName);
                }

                channel.Commit();
            }
            else if (sToken.Equals("ALIAS"))
            {
                r = new Result(2);
                r.Label[0]="NAME";
                r.Type[0] = ColumnType.VarChar;
                r.Label[1]="LIBRARY";
                r.Type[1] = ColumnType.VarChar;

                foreach( DictionaryEntry entry in _alias )
                {
                    string[] alias = new string [2];
                    alias[0] = entry.Key.ToString();
                    alias[1] = entry.Value.ToString();
                    r.Add(alias);
                }

                channel.Commit();
            }
            else if (sToken.Equals("PARAMETERS"))
            {
                string alias = tokenizer.GetString().ToUpper();

                if( !_alias.ContainsKey( alias ) )
                    throw TracingHelper.Error(TracingHelper.UNKNOWN_FUNCTION, alias);

                string fqn = _alias[alias].ToString();

                Function f = new Function( fqn, channel );

                System.Reflection.MethodInfo mi = f.GetMethodInfo( fqn );

                r = new Result(4);
                r.Label[0]="ALIAS";
                r.Type[0] = ColumnType.VarChar;
                r.Label[1]="PARAMETER";
                r.Type[1] = ColumnType.VarChar;
                r.Label[2]="TYPE";
                r.Type[2] = ColumnType.VarChar;
                r.Label[3]="POSITION";
                r.Type[3] = ColumnType.Integer;

                System.Reflection.ParameterInfo[] parms = mi.GetParameters();

                int rt = 0;

                if( mi.ReturnType != null )
                {
                    object[] p = new object[4];
                    p[0] = alias;
                    p[1] = "RETURN_VALUE";
                    p[2] = Column.GetColumnTypeString( Function.GetDataType( mi.ReturnType ) );
                    p[3] = 0;
                    r.Add(p);
                    rt = 1;
                }

                foreach( System.Reflection.ParameterInfo pi in parms )
                {
                    object[] p = new object[4];
                    p[0] = alias;
                    p[1] = pi.Name;
                    p[2] = Column.GetColumnTypeString( Function.GetDataType( pi.ParameterType ) );
                    p[3] = (pi.Position + rt);
                    r.Add(p);
                }

                channel.Commit();
            }
            else if (sToken.Equals("COLUMNS"))
            {
                string t = tokenizer.GetString().ToUpper();
                Table theTable = null;

                foreach( Table table in channel.Database.Tables )
                {
                    if( table.Name.ToUpper() == t )
                    {
                        theTable = table;
                        break;
                    }
                }

                if( theTable == null )
                    throw TracingHelper.Error(TracingHelper.TABLE_NOT_FOUND, t);

                r = new Result(7);
                r.Label[0]="TABLE";
                r.Type[0] = ColumnType.VarChar;
                r.Label[1]="COLUMN";
                r.Type[1] = ColumnType.VarChar;
                r.Label[2]="NATIVETYPE";
                r.Type[2] = ColumnType.VarChar;
                r.Label[3]="DBTYPE";
                r.Type[3] = ColumnType.Integer;
                r.Label[4]="POSITION";
                r.Type[4] = ColumnType.Integer;
                r.Label[5]="NULLABLE";
                r.Type[5] = ColumnType.Bit;
                r.Label[6]="IDENTITY";
                r.Type[6] = ColumnType.Bit;

                for(int ix=0;ix<theTable.ColumnCount;ix++)
                {
                    Column col = theTable.GetColumn(ix);
                    object[] coldata = new object[7];
                    coldata[0] = theTable.Name;
                    coldata[1] = col.Name;
                    coldata[2] = Column.GetColumnTypeString( col.ColumnType );
                    coldata[3] = Column.GetDbType( col.ColumnType );
                    coldata[4] = ix;
                    coldata[5] = col.IsNullable;
                    coldata[6] = col.IsIdentity;
                    r.Add(coldata);
                }
                channel.Commit();
            }
            else
            {
                throw TracingHelper.Error(TracingHelper.UnexpectedToken, sToken);
            }

            return r;
        }
示例#15
0
        private Result ProcessSet(Tokenizer tokenizer, Channel channel)
        {
            string sToken = tokenizer.GetString();

            switch(sToken)
            {
                case "PASSWORD":
                    channel.CheckReadWrite();
                    channel.SetPassword(tokenizer.GetStringToken());
                    break;
                case "READONLY":
                    channel.Commit();
                    channel.SetReadOnly(ProcessTrueOrFalse(tokenizer));
                    break;
                case "LOGSIZE":
                {
                    channel.CheckAdmin();

                    int i = Int32.Parse(tokenizer.GetString());

                    if (_log != null)
                    {
                        _log.SetLogSize(i);
                    }
                }
                    break;
                case "IGNORECASE":
                    channel.CheckAdmin();
                    _ignoreCase = ProcessTrueOrFalse(tokenizer);
                    break;
                case "MAXROWS":
                {
                    int i = Int32.Parse(tokenizer.GetString());
                    channel.MaxRows = i;
                    break;
                }
                case "AUTOCOMMIT":
                    channel.SetAutoCommit(ProcessTrueOrFalse(tokenizer));
                    break;
                case "TABLE":
                {
                    channel.CheckReadWrite();
                    channel.CheckAdmin();

                    Table t = GetTable(tokenizer.GetString(), channel);

                    tokenizer.GetThis("INDEX");
                    tokenizer.GetString();
                    t.IndexRoots = (string)tokenizer.Value;
                }
                    break;
                case "REFERENCIAL_INTEGRITY":
                case "REFERENTIAL_INTEGRITY":
                    channel.CheckAdmin();
                    _referentialIntegrity = ProcessTrueOrFalse(tokenizer);
                    break;
                case "WRITE_DELAY":
                {
                    channel.CheckAdmin();

                    bool delay = ProcessTrueOrFalse(tokenizer);

                    if (_log != null)
                    {
                        _log.SetWriteDelay(delay);
                    }
                }
                    break;
                default:
                    if( tokenizer.TokenType == TokenType.VARIABLE )
                    {
                        Parser p = new Parser(this, tokenizer, channel);
                        p.ProcessSet( sToken );
                        break;
                    }

                    throw TracingHelper.Error(TracingHelper.UnexpectedToken, sToken);
            }

            return new Result();
        }