Esempio n. 1
0
 private void SetTables()
 {
     if (((this.Tables.Length != 0) || (base.Parent != null)) || (base.Root.ScopeTables != null))
     {
         HashMappedList <string, Table> list = new HashMappedList <string, Table>();
         if ((base.Parent == null) && (base.Root.ScopeTables != null))
         {
             for (int j = 0; j < base.Root.ScopeTables.Size(); j++)
             {
                 list.Add(base.Root.ScopeTables.GetKey(j), base.Root.ScopeTables.Get(j));
             }
         }
         else if ((base.Parent != null) && (base.Parent.ScopeTables != null))
         {
             for (int j = 0; j < base.Parent.ScopeTables.Size(); j++)
             {
                 list.Add(base.Parent.ScopeTables.GetKey(j), base.Parent.ScopeTables.Get(j));
             }
         }
         for (int i = 0; i < this.Tables.Length; i++)
         {
             string name = this.Tables[i].GetName().Name;
             if (!list.Add(name, this.Tables[i]))
             {
                 throw Error.GetError(0x15e6, name);
             }
         }
         this.ScopeTables = list;
     }
 }
Esempio n. 2
0
 public void Push(bool isInvoke)
 {
     if (isInvoke)
     {
         this.session.sessionData.persistentStoreCollection.Push();
     }
     this._ObjectArrayStack.Push(this.DynamicArguments);
     this._ObjectArrayStack.Push(this.RoutineArguments);
     this._ObjectArrayStack.Push(this.RoutineVariables);
     this._IRangeIteratorArrayStack.Push(this.RangeIterators);
     this._HashMappedListStack.Push(this.Savepoints);
     this._LongDequeStack.Push(this.SavepointTimestamps);
     this._BoolStack.Push(this.IsAutoCommit);
     this._BoolStack.Push(this.IsReadOnly);
     this._BoolStack.Push(this.NoSql);
     this._IntStack.Push(this.CurrentMaxRows);
     this._DelegateStack.Push(this.RestoreTriggerIterators);
     this._ObjectArrayStack.Push(this.triggerNewData);
     this._ObjectArrayStack.Push(this.triggerOldData);
     this.RangeIterators      = new IRangeIterator[4];
     this.SavepointTimestamps = this.longDequePool.Fetch();
     this.SavepointTimestamps.Clear();
     this.Savepoints = this.hashMappedListPool.Fetch();
     this.Savepoints.Clear();
     this.IsAutoCommit   = false;
     this.CurrentMaxRows = 0;
     this.Depth++;
 }
Esempio n. 3
0
 public SessionContext(Session session)
 {
     this.session               = session;
     this.RangeIterators        = new IRangeIterator[4];
     this.Savepoints            = new HashMappedList <string, int>(4);
     this.SavepointTimestamps   = new LongDeque();
     this.SessionVariables      = new HashMappedList <string, ColumnSchema>();
     this.SessionVariablesRange = new RangeVariable[] { new RangeVariable(this.SessionVariables, true) };
     this.IsAutoCommit          = this.IsReadOnly = this.NoSql = false;
 }
Esempio n. 4
0
 public void AddSessionTable(Table table)
 {
     if (this.SessionTables == null)
     {
         this.SessionTables = new HashMappedList <string, Table>();
     }
     if (this.SessionTables.ContainsKey(table.GetName().Name))
     {
         throw Error.GetError(0x1580);
     }
     this.SessionTables.Add(table.GetName().Name, table);
 }
Esempio n. 5
0
 public RangeVariable(HashMappedList <string, ColumnSchema> variables, bool isVariable)
 {
     this.Variables        = variables;
     this.IsVariable       = isVariable;
     this.RangeTable       = null;
     this.TableAlias       = null;
     this._emptyData       = null;
     this.ColumnsInGroupBy = null;
     this.UsedColumns      = null;
     this.JoinConditions   = new RangeVariableConditions[] { new RangeVariableConditions(this, true) };
     this.WhereConditions  = new RangeVariableConditions[] { new RangeVariableConditions(this, false) };
 }
Esempio n. 6
0
 public Routine(Table table, RangeVariable[] ranges, int impact, int triggerType, int operationType)
 {
     this.DataImpact           = 4;
     this._isNewSavepointLevel = true;
     this.ParameterList        = new HashMappedList <string, ColumnSchema>();
     this.RoutineType          = 8;
     this.ReturnType           = SqlType.SqlAllTypes;
     this.DataImpact           = impact;
     this.Ranges           = ranges;
     this.TriggerTable     = table;
     this.TriggerType      = triggerType;
     this.TriggerOperation = operationType;
 }
Esempio n. 7
0
 public Routine(int type)
 {
     this.DataImpact           = 4;
     this._isNewSavepointLevel = true;
     this.ParameterList        = new HashMappedList <string, ColumnSchema>();
     this.RoutineType          = type;
     this.ReturnType           = SqlType.SqlAllTypes;
     if (this.RoutineType == 0x10)
     {
         this.DataImpact = 2;
     }
     this.Ranges = new RangeVariable[] { new RangeVariable(this.ParameterList, false) };
 }
Esempio n. 8
0
        public virtual void CreateResultTable(Session session)
        {
            QNameManager.QName subqueryTableName = session.database.NameManager.GetSubqueryTableName();
            int type = (this.PersistenceScope == 0x15) ? 2 : 9;
            HashMappedList <string, ColumnSchema> unionColumns = this._leftQueryExpression.GetUnionColumns();

            try
            {
                this.ResultTable = new TableDerived(session.database, subqueryTableName, type, this.UnionColumnTypes, this.UnionColumnNullability, unionColumns, null, null);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 9
0
 private HashMappedList <string, ColumnSchema> GetUnionColumns()
 {
     if (this._unionCorresponding || (this._leftQueryExpression == null))
     {
         HashMappedList <string, ColumnSchema> columnList = ((TableDerived)this.ResultTable).ColumnList;
         HashMappedList <string, ColumnSchema> list3      = new HashMappedList <string, ColumnSchema>();
         for (int i = 0; i < this.UnionColumnMap.Length; i++)
         {
             ColumnSchema schema = columnList.Get(i);
             list3.Add(schema.GetName().Name, schema);
         }
         return(list3);
     }
     return(this._leftQueryExpression.GetUnionColumns());
 }
Esempio n. 10
0
        public QNameManager.QName[] GetResultColumnNames()
        {
            if (this.ResultTable == null)
            {
                return(this._leftQueryExpression.GetResultColumnNames());
            }
            HashMappedList <string, ColumnSchema> columnList = ((TableDerived)this.ResultTable).ColumnList;

            QNameManager.QName[] nameArray2 = new QNameManager.QName[columnList.Size()];
            for (int i = 0; i < nameArray2.Length; i++)
            {
                nameArray2[i] = columnList.Get(i).GetName();
            }
            return(nameArray2);
        }
Esempio n. 11
0
        public void WriteData(int l, SqlType[] types, object[] data, HashMappedList <string, ColumnSchema> cols, int[] primaryKeys)
        {
            bool flag = (primaryKeys != null) && (primaryKeys.Length > 0);
            int  num  = flag ? primaryKeys.Length : l;

            for (int i = 0; i < num; i++)
            {
                int     index = flag ? primaryKeys[i] : i;
                object  o     = data[index];
                SqlType t     = types[index];
                if (cols != null)
                {
                    ColumnSchema schema = cols.Get(index);
                    this.WriteFieldPrefix();
                    this.WriteString(schema.GetName().StatementName);
                }
                this.WriteData(t, o);
            }
        }
Esempio n. 12
0
 private void SetVariables()
 {
     if (this.Variables.Length == 0)
     {
         this.RangeVariables = (base.Parent == null) ? base.Root.GetParameterRangeVariables() : base.Parent.RangeVariables;
     }
     else
     {
         HashMappedList <string, ColumnSchema> variables = new HashMappedList <string, ColumnSchema>();
         if ((base.Parent != null) && (base.Parent.ScopeVariables != null))
         {
             for (int j = 0; j < base.Parent.ScopeVariables.Size(); j++)
             {
                 variables.Add(base.Parent.ScopeVariables.GetKey(j), base.Parent.ScopeVariables.Get(j));
             }
         }
         for (int i = 0; i < this.Variables.Length; i++)
         {
             string name = this.Variables[i].GetName().Name;
             if (!variables.Add(name, this.Variables[i]))
             {
                 throw Error.GetError(0x15e6, name);
             }
             if (base.Root.GetParameterIndex(name) != -1)
             {
                 throw Error.GetError(0x15e6, name);
             }
         }
         this.ScopeVariables = variables;
         RangeVariable variable = new RangeVariable(variables, true);
         if (!base.Root.IsTrigger())
         {
             this.RangeVariables = new RangeVariable[] { base.Root.GetParameterRangeVariables()[0], variable };
         }
         else
         {
             this.RangeVariables = new RangeVariable[base.Root.GetParameterRangeVariables().Length + 1];
             Array.Copy(base.Root.GetParameterRangeVariables(), this.RangeVariables, (int)(this.RangeVariables.Length - 1));
             this.RangeVariables[this.RangeVariables.Length - 1] = variable;
         }
         base.Root.VariableCount = variables.Size();
     }
 }
Esempio n. 13
0
 public Schema(QNameManager.QName name, Grantee owner)
 {
     this.Name                  = name;
     this.TriggerLookup         = new SchemaObjectSet(8);
     this.IndexLookup           = new SchemaObjectSet(20);
     this.ConstraintLookup      = new SchemaObjectSet(5);
     this.TableLookup           = new SchemaObjectSet(3);
     this.SequenceLookup        = new SchemaObjectSet(7);
     this.TypeLookup            = new SchemaObjectSet(12);
     this.CharsetLookup         = new SchemaObjectSet(14);
     this.CollationLookup       = new SchemaObjectSet(15);
     this.ProcedureLookup       = new SchemaObjectSet(0x11);
     this.FunctionLookup        = new SchemaObjectSet(0x10);
     this.AggregateLookup       = new SchemaObjectSet(0x1b);
     this.SpecificRoutineLookup = new SchemaObjectSet(0x18);
     this.AssertionLookup       = new SchemaObjectSet(6);
     this.TableList             = (HashMappedList <string, object>) this.TableLookup.Map;
     this.SequenceList          = (HashMappedList <string, object>) this.SequenceLookup.Map;
     this.Owner                 = owner;
     name.Owner                 = owner;
 }
Esempio n. 14
0
 public void Pop(bool isInvoke)
 {
     if (isInvoke)
     {
         this.session.sessionData.persistentStoreCollection.Pop();
     }
     this.longDequePool.Store(this.SavepointTimestamps);
     this.hashMappedListPool.Store(this.Savepoints);
     this.triggerOldData          = this._ObjectArrayStack.Pop();
     this.triggerNewData          = this._ObjectArrayStack.Pop();
     this.RestoreTriggerIterators = this._DelegateStack.Pop();
     this.CurrentMaxRows          = this._IntStack.Pop();
     this.NoSql               = this._BoolStack.Pop();
     this.IsReadOnly          = this._BoolStack.Pop();
     this.IsAutoCommit        = this._BoolStack.Pop();
     this.SavepointTimestamps = this._LongDequeStack.Pop();
     this.Savepoints          = this._HashMappedListStack.Pop();
     this.RangeIterators      = this._IRangeIteratorArrayStack.Pop();
     this.RoutineVariables    = this._ObjectArrayStack.Pop();
     this.RoutineArguments    = this._ObjectArrayStack.Pop();
     this.DynamicArguments    = this._ObjectArrayStack.Pop();
     this.Depth--;
 }
Esempio n. 15
0
 public void CreateSchema()
 {
     lock (this)
     {
         this._sysLobSession = this._database.sessionManager.GetSysLobSession();
         Stream       manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("LibCore.Resources.lob-schema.sql");
         StreamReader reader = null;
         try
         {
             reader = new StreamReader(manifestResourceStream);
         }
         catch (Exception)
         {
         }
         LineGroupReader reader1 = new LineGroupReader(reader, Starters);
         HashMappedList <string, string> asMap = reader1.GetAsMap();
         reader1.Close();
         string sql    = asMap.Get("/*lob_schema_definition*/");
         Result result = this._sysLobSession.CompileStatement(sql, ResultProperties.DefaultPropsValue).Execute(this._sysLobSession);
         if (result.IsError())
         {
             throw result.GetException();
         }
         this._getLob            = this._sysLobSession.CompileStatement("SELECT * FROM SYSTEM_LOBS.LOB_IDS WHERE LOB_ID = ?", ResultProperties.DefaultPropsValue);
         this._getLobPart        = this._sysLobSession.CompileStatement("SELECT * FROM SYSTEM_LOBS.LOBS WHERE LOB_ID = ? AND BLOCK_OFFSET + BLOCK_COUNT > ? AND BLOCK_OFFSET < ? ORDER BY BLOCK_OFFSET", ResultProperties.DefaultPropsValue);
         this._createLob         = this._sysLobSession.CompileStatement("INSERT INTO SYSTEM_LOBS.LOB_IDS VALUES(?, ?, ?, ?)", ResultProperties.DefaultPropsValue);
         this._createLobPartCall = this._sysLobSession.CompileStatement("CALL SYSTEM_LOBS.ALLOC_BLOCKS(?, ?, ?)", ResultProperties.DefaultPropsValue);
         this._divideLobPartCall = this._sysLobSession.CompileStatement("CALL SYSTEM_LOBS.DIVIDE_BLOCK(?, ?)", ResultProperties.DefaultPropsValue);
         this._deleteLobPartCall = this._sysLobSession.CompileStatement("CALL SYSTEM_LOBS.DELETE_BLOCKS(?,?,?,?)", ResultProperties.DefaultPropsValue);
         this._updateLobLength   = this._sysLobSession.CompileStatement("UPDATE SYSTEM_LOBS.LOB_IDS SET LOB_LENGTH = ? WHERE LOB_ID = ?", ResultProperties.DefaultPropsValue);
         this._updateLobUsage    = this._sysLobSession.CompileStatement("UPDATE SYSTEM_LOBS.LOB_IDS SET LOB_USAGE_COUNT = ? WHERE LOB_ID = ?", ResultProperties.DefaultPropsValue);
         this._getNextLobId      = this._sysLobSession.CompileStatement("VALUES NEXT VALUE FOR SYSTEM_LOBS.LOB_ID", ResultProperties.DefaultPropsValue);
         this._deleteUnusedLobs  = this._sysLobSession.CompileStatement("CALL SYSTEM_LOBS.DELETE_UNUSED()", ResultProperties.DefaultPropsValue);
         this._getLobCount       = this._sysLobSession.CompileStatement("SELECT COUNT(*) FROM SYSTEM_LOBS.LOB_IDS", ResultProperties.DefaultPropsValue);
     }
 }
Esempio n. 16
0
 public TableDerived(Database database, QNameManager.QName name, int type, SqlType[] columnTypes, byte[] columnNullability, HashMappedList <string, ColumnSchema> columnList, QueryExpression queryExpression, SubQuery subQuery) : this(database, name, type, queryExpression, subQuery)
 {
     base.ColTypes               = columnTypes;
     base.ColumnList             = columnList;
     base.ColumnCount            = columnList.Size();
     base.PrimaryKeyCols         = new int[0];
     base.PrimaryKeyTypes        = SqlType.EmptyArray;
     base.PrimaryKeyColsSequence = new int[0];
     base.ColDefaults            = new Expression[base.ColumnCount];
     base.ColNotNull             = new bool[base.ColumnCount];
     for (int i = 0; i < base.ColNotNull.Length; i++)
     {
         base.ColNotNull[i] = columnNullability[i] == 0;
     }
     base.DefaultColumnMap = new int[base.ColumnCount];
     ArrayUtil.FillSequence(base.DefaultColumnMap);
     base.BestIndexForColumn = new int[base.ColTypes.Length];
     ArrayUtil.FillArray(base.BestIndexForColumn, -1);
     base.CreatePrimaryIndex(base.PrimaryKeyCols, base.PrimaryKeyTypes, null);
 }
Esempio n. 17
0
 public UserManager(Database database)
 {
     this._granteeManager = database.GetGranteeManager();
     this._userList       = new HashMappedList <string, User>();
 }
Esempio n. 18
0
 public void PushRoutineTables(HashMappedList <string, Table> map)
 {
     this.PopSessionTables.Push(this.SessionTables);
     this.SessionTables = map;
 }
Esempio n. 19
0
 public void PopRoutineTables()
 {
     this.SessionTables = this.PopSessionTables.Pop();
 }