Ejemplo n.º 1
0
        public OrderedHashSet <string> GetColumnsForAllRights(Table table)
        {
            if (this.IsFull)
            {
                return(table.GetColumnNameSet());
            }
            if ((this.IsFullSelect || this.IsFullInsert) || (this.IsFullUpdate || this.IsFullReferences))
            {
                return(table.GetColumnNameSet());
            }
            OrderedHashSet <string> set2 = new OrderedHashSet <string>();

            if (this._selectColumnSet != null)
            {
                set2.AddAll(this._selectColumnSet);
            }
            if (this._insertColumnSet != null)
            {
                set2.AddAll(this._insertColumnSet);
            }
            if (this._updateColumnSet != null)
            {
                set2.AddAll(this._updateColumnSet);
            }
            if (this._referencesColumnSet != null)
            {
                set2.AddAll(this._referencesColumnSet);
            }
            return(set2);
        }
Ejemplo n.º 2
0
        public override void Resolve(Session session, RangeVariable[] rangeVars)
        {
            for (int i = 0; i < this.Statements.Length; i++)
            {
                if ((this.Statements[i].GetStatementType() == 0x59) || (this.Statements[i].GetStatementType() == 0x66))
                {
                    if (!this.FindLabel((StatementSimple)this.Statements[i]))
                    {
                        throw Error.GetError(0x1584, ((StatementSimple)this.Statements[i]).label.Name);
                    }
                }
                else if ((this.Statements[i].GetStatementType() == 0x3a) && !base.Root.IsFunction())
                {
                    throw Error.GetError(0x15e2, "RETURN");
                }
            }
            for (int j = 0; j < this.Statements.Length; j++)
            {
                this.Statements[j].Resolve(session, this.RangeVariables);
            }
            for (int k = 0; k < this.Handlers.Length; k++)
            {
                this.Handlers[k].Resolve(session, this.RangeVariables);
            }
            OrderedHashSet <QNameManager.QName> c    = new OrderedHashSet <QNameManager.QName>();
            OrderedHashSet <QNameManager.QName> set2 = new OrderedHashSet <QNameManager.QName>();
            OrderedHashSet <QNameManager.QName> set3 = new OrderedHashSet <QNameManager.QName>();

            for (int m = 0; m < this.Variables.Length; m++)
            {
                set3.AddAll(this.Variables[m].GetReferences());
            }
            for (int n = 0; n < this.Statements.Length; n++)
            {
                set3.AddAll(this.Statements[n].GetReferences());
                set2.AddAll(this.Statements[n].GetTableNamesForRead());
                c.AddAll(this.Statements[n].GetTableNamesForWrite());
            }
            for (int num6 = 0; num6 < this.Handlers.Length; num6++)
            {
                set3.AddAll(this.Handlers[num6].GetReferences());
                set2.AddAll(this.Handlers[num6].GetTableNamesForRead());
                c.AddAll(this.Handlers[num6].GetTableNamesForWrite());
            }
            set2.RemoveAll(c);
            base.ReadTableNames = new QNameManager.QName[set2.Size()];
            set2.ToArray(base.ReadTableNames);
            base.WriteTableNames = new QNameManager.QName[c.Size()];
            c.ToArray(base.WriteTableNames);
            base.References = set3;
        }
Ejemplo n.º 3
0
        public void AddSimpleObjects(OrderedHashSet <object> unresolved)
        {
            Iterator <object> iterator = this.SpecificRoutineLookup.Map.GetValues().GetIterator();

            while (iterator.HasNext())
            {
                Routine key = (Routine)iterator.Next();
                if ((key.DataImpact == 1) || (key.DataImpact == 2))
                {
                    unresolved.Add(key);
                }
            }
            unresolved.AddAll(this.TypeLookup.Map.GetValues());
            unresolved.AddAll(this.CharsetLookup.Map.GetValues());
            unresolved.AddAll(this.CollationLookup.Map.GetValues());
        }
Ejemplo n.º 4
0
        public OrderedHashSet <SubQuery> GetSubqueries()
        {
            OrderedHashSet <SubQuery> set = null;

            if (this.JoinCondition != null)
            {
                set = this.JoinCondition.CollectAllSubqueries(set);
            }
            if (!(this.RangeTable is TableDerived))
            {
                return(set);
            }
            QueryExpression queryExpression = this.RangeTable.GetQueryExpression();

            if (((TableDerived)this.RangeTable).view != null)
            {
                if (set == null)
                {
                    set = new OrderedHashSet <SubQuery>();
                }
                set.AddAll(((TableDerived)this.RangeTable).view.GetSubqueries());
                return(set);
            }
            if (queryExpression == null)
            {
                return(OrderedHashSet <SubQuery> .Add(set, this.RangeTable.GetSubQuery()));
            }
            OrderedHashSet <SubQuery> subqueries = queryExpression.GetSubqueries();

            set = OrderedHashSet <SubQuery> .AddAll(set, subqueries);

            SubQuery subQuery = this.RangeTable.GetSubQuery();

            return(OrderedHashSet <SubQuery> .AddAll(OrderedHashSet <SubQuery> .Add(set, subQuery), subQuery.GetExtraSubqueries()));
        }
Ejemplo n.º 5
0
        public OrderedHashSet <ISchemaObject> GetComponents()
        {
            OrderedHashSet <ISchemaObject> set1 = new OrderedHashSet <ISchemaObject>();

            set1.AddAll(this.Routines);
            return(set1);
        }
Ejemplo n.º 6
0
 public override void CollectTableNamesForWrite(OrderedHashSet <QNameManager.QName> set)
 {
     if (this._expression == null)
     {
         set.AddAll(this.Procedure.GetTableNamesForWrite());
     }
 }
Ejemplo n.º 7
0
        protected virtual OrderedHashSet <SubQuery> GetDependents()
        {
            OrderedHashSet <SubQuery> first = new OrderedHashSet <SubQuery>();

            OrderedHashSet <SubQuery> .AddAll(first, this.queryExpression.GetSubqueries());

            first.Remove(this);
            return(first);
        }
Ejemplo n.º 8
0
        private void SetReferences()
        {
            OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();

            for (int i = 0; i < this.ParameterTypes.Length; i++)
            {
                set.AddAll(this.ParameterList.Get(i).GetReferences());
            }
            if (this.statement != null)
            {
                set.AddAll(this.statement.GetReferences());
            }
            if (set.Contains(this.GetSpecificName()))
            {
                set.Remove(this.GetSpecificName());
                this.IsRecursive = true;
            }
            this._references = set;
        }
Ejemplo n.º 9
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();

            for (int i = 0; i < this.Routines.Length; i++)
            {
                set.AddAll(this.Routines[i].GetReferences());
            }
            return(set);
        }
Ejemplo n.º 10
0
 public override void CollectTableNamesForRead(OrderedHashSet <QNameManager.QName> set)
 {
     if (base.BaseTable.IsView())
     {
         this.GetTriggerTableNames(set, false);
     }
     else if (!base.BaseTable.IsTemp())
     {
         for (int m = 0; m < base.BaseTable.FkConstraints.Length; m++)
         {
             Constraint constraint = base.BaseTable.FkConstraints[m];
             if ((base.type == 0x52) || (base.type == 0x80))
             {
                 if (ArrayUtil.HaveCommonElement(constraint.GetRefColumns(), base.UpdateColumnMap))
                 {
                     set.Add(base.BaseTable.FkConstraints[m].GetMain().GetName());
                 }
             }
             else if (base.type == 50)
             {
                 set.Add(base.BaseTable.FkConstraints[m].GetMain().GetName());
             }
         }
         if ((base.type == 0x52) || (base.type == 0x80))
         {
             base.BaseTable.CollectFkReadLocks(base.UpdateColumnMap, set);
         }
         else if (base.type == 0x13)
         {
             base.BaseTable.CollectFkReadLocks(null, set);
         }
         this.GetTriggerTableNames(set, false);
     }
     for (int i = 0; i < base.RangeVariables.Length; i++)
     {
         Table rangeTable       = base.RangeVariables[i].RangeTable;
         QNameManager.QName key = rangeTable.GetName();
         if ((!rangeTable.IsReadOnly() && !rangeTable.IsTemp()) && (key.schema != SqlInvariants.SystemSchemaQname))
         {
             set.Add(key);
         }
     }
     for (int j = 0; j < base.Subqueries.Length; j++)
     {
         if (base.Subqueries[j].queryExpression != null)
         {
             base.Subqueries[j].queryExpression.GetBaseTableNames(set);
         }
     }
     for (int k = 0; k < base.Routines.Length; k++)
     {
         set.AddAll(base.Routines[k].GetTableNamesForRead());
     }
 }
Ejemplo n.º 11
0
        public OrderedHashSet <ISchemaObject> GetComponents()
        {
            if (this._constraints == null)
            {
                return(null);
            }
            OrderedHashSet <ISchemaObject> set1 = new OrderedHashSet <ISchemaObject>();

            set1.AddAll(this._constraints);
            return(set1);
        }
Ejemplo n.º 12
0
 public override void CollectTableNamesForRead(OrderedHashSet <QNameManager.QName> set)
 {
     if (this._expression == null)
     {
         set.AddAll(this.Procedure.GetTableNamesForRead());
     }
     else
     {
         for (int i = 0; i < base.Subqueries.Length; i++)
         {
             if (base.Subqueries[i].queryExpression != null)
             {
                 base.Subqueries[i].queryExpression.GetBaseTableNames(set);
             }
         }
         for (int j = 0; j < base.Routines.Length; j++)
         {
             set.AddAll(base.Routines[j].GetTableNamesForRead());
         }
     }
 }
Ejemplo n.º 13
0
        public override void Compile(Session session, ISchemaObject parentObject)
        {
            using (Scanner scanner = new Scanner(this.statement))
            {
                ParserDQL rdql = new ParserDQL(session, scanner);
                rdql.Read();
                this.ViewSubQuery    = rdql.XreadViewSubquery(this);
                base.queryExpression = this.ViewSubQuery.queryExpression;
                if (base.GetColumnCount() == 0)
                {
                    if (this.ColumnNames == null)
                    {
                        this.ColumnNames = this.ViewSubQuery.queryExpression.GetResultColumnNames();
                    }
                    if (this.ColumnNames.Length != this.ViewSubQuery.queryExpression.GetColumnCount())
                    {
                        throw Error.GetError(0x15d9, this.GetName().StatementName);
                    }
                    TableUtil.SetColumnsInSchemaTable(this, this.ColumnNames, base.queryExpression.GetColumnTypes(), base.queryExpression.GetColumnNullability());
                }
                OrderedHashSet <SubQuery> set = OrderedHashSet <SubQuery> .AddAll(OrderedHashSet <SubQuery> .Add(base.queryExpression.GetSubqueries(), this.ViewSubQuery), this.ViewSubQuery.GetExtraSubqueries());

                this.ViewSubqueries = new SubQuery[set.Size()];
                set.ToArray(this.ViewSubqueries);
                ArraySort.Sort <SubQuery>(this.ViewSubqueries, 0, this.ViewSubqueries.Length, this.ViewSubqueries[0]);
                foreach (SubQuery query in this.ViewSubqueries)
                {
                    if (query.ParentView == null)
                    {
                        query.ParentView = this;
                    }
                    query.PrepareTable(session);
                }
                this.ViewSubQuery.GetTable().view       = this;
                this.ViewSubQuery.GetTable().ColumnList = base.ColumnList;
                this._schemaObjectNames = rdql.compileContext.GetSchemaObjectNames();
                this._baseTable         = base.queryExpression.GetBaseTable();
            }
            if (this._baseTable != null)
            {
                switch (this._check)
                {
                case 0:
                case 2:
                    return;

                case 1:
                    base.queryExpression.GetCheckCondition();
                    return;
                }
                throw Error.RuntimeError(0xc9, "View");
            }
        }
Ejemplo n.º 14
0
        protected override OrderedHashSet <SubQuery> GetDependents()
        {
            OrderedHashSet <SubQuery> first = new OrderedHashSet <SubQuery>();

            OrderedHashSet <SubQuery> .AddAll(first, base.queryExpression.GetSubqueries());

            if (this.RecursiveQueryExpression != null)
            {
                OrderedHashSet <SubQuery> .AddAll(first, this.RecursiveQueryExpression.GetSubqueries());
            }
            first.Remove(this);
            return(first);
        }
Ejemplo n.º 15
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();

            for (int i = 0; i < this._constraints.Length; i++)
            {
                OrderedHashSet <QNameManager.QName> references = this._constraints[i].GetReferences();
                if (references != null)
                {
                    set.AddAll(references);
                }
            }
            return(set);
        }
Ejemplo n.º 16
0
        public OrderedHashSet <string> GetUniqueColumnNameSet()
        {
            OrderedHashSet <string> set = new OrderedHashSet <string>();

            if (this._columnAliases != null)
            {
                set.AddAll(this._columnAliases);
                return(set);
            }
            for (int i = 0; i < this.RangeTable.ColumnList.Size(); i++)
            {
                string name = this.RangeTable.GetColumn(i).GetName().Name;
                if (!set.Add(name))
                {
                    throw Error.GetError(0x15ca, name);
                }
            }
            return(set);
        }
Ejemplo n.º 17
0
        public virtual SubQuery[] GetSubqueries(Session session)
        {
            OrderedHashSet <SubQuery> first = null;

            for (int i = 0; i < this.TargetRangeVariables.Length; i++)
            {
                if (this.TargetRangeVariables[i] != null)
                {
                    OrderedHashSet <SubQuery> subqueries = this.TargetRangeVariables[i].GetSubqueries();
                    first = OrderedHashSet <SubQuery> .AddAll(first, subqueries);
                }
            }
            for (int j = 0; j < this.UpdateExpressions.Length; j++)
            {
                first = this.UpdateExpressions[j].CollectAllSubqueries(first);
            }
            if (this.InsertExpression != null)
            {
                first = this.InsertExpression.CollectAllSubqueries(first);
            }
            if (this.condition != null)
            {
                first = this.condition.CollectAllSubqueries(first);
            }
            if (this.queryExpression != null)
            {
                OrderedHashSet <SubQuery> subqueries = this.queryExpression.GetSubqueries();
                first = OrderedHashSet <SubQuery> .AddAll(first, subqueries);
            }
            if ((first == null) || (first.Size() == 0))
            {
                return(SubQuery.EmptySubqueryArray);
            }
            SubQuery[] a = new SubQuery[first.Size()];
            first.ToArray(a);
            ArraySort.Sort <SubQuery>(a, 0, a.Length, a[0]);
            for (int k = 0; k < a.Length; k++)
            {
                a[k].PrepareTable(session);
            }
            return(a);
        }
Ejemplo n.º 18
0
 public override void CollectTableNamesForRead(OrderedHashSet <QNameManager.QName> set)
 {
     for (int i = 0; i < base.RangeVariables.Length; i++)
     {
         Table rangeTable       = base.RangeVariables[i].RangeTable;
         QNameManager.QName key = rangeTable.GetName();
         if ((!rangeTable.IsReadOnly() && !rangeTable.IsTemp()) && (key.schema != SqlInvariants.SystemSchemaQname))
         {
             set.Add(key);
         }
     }
     for (int j = 0; j < base.Subqueries.Length; j++)
     {
         if (base.Subqueries[j].queryExpression != null)
         {
             base.Subqueries[j].queryExpression.GetBaseTableNames(set);
         }
     }
     for (int k = 0; k < base.Routines.Length; k++)
     {
         set.AddAll(base.Routines[k].GetTableNamesForRead());
     }
 }
Ejemplo n.º 19
0
        public void DropColumn(int colIndex, bool cascade)
        {
            OrderedHashSet <QNameManager.QName> dropConstraintSet     = new OrderedHashSet <QNameManager.QName>();
            OrderedHashSet <Constraint>         dependentConstraints  = this._table.GetDependentConstraints(colIndex);
            OrderedHashSet <Constraint>         containingConstraints = this._table.GetContainingConstraints(colIndex);
            OrderedHashSet <QNameManager.QName> containingIndexNames  = this._table.GetContainingIndexNames(colIndex);
            ColumnSchema column = this._table.GetColumn(colIndex);

            QNameManager.QName name = column.GetName();
            OrderedHashSet <QNameManager.QName> referencingObjectNames = this._database.schemaManager.GetReferencingObjectNames(this._table.GetName(), name);

            this.CheckModifyTable();
            if (!cascade)
            {
                if (!containingConstraints.IsEmpty())
                {
                    QNameManager.QName name2 = containingConstraints.Get(0).GetName();
                    throw Error.GetError(0x15a0, name2.GetSchemaQualifiedStatementName());
                }
                if (!referencingObjectNames.IsEmpty())
                {
                    for (int j = 0; j < referencingObjectNames.Size(); j++)
                    {
                        QNameManager.QName name3 = referencingObjectNames.Get(j);
                        if (name3 != name)
                        {
                            for (int k = 0; k < dependentConstraints.Size(); k++)
                            {
                                if (dependentConstraints.Get(k).GetName() == name3)
                                {
                                    continue;
                                }
                            }
                            throw Error.GetError(0x15a0, name3.GetSchemaQualifiedStatementName());
                        }
                    }
                }
            }
            dependentConstraints.AddAll(containingConstraints);
            containingConstraints.Clear();
            OrderedHashSet <Table> tableSet = new OrderedHashSet <Table>();

            for (int i = 0; i < dependentConstraints.Size(); i++)
            {
                Constraint constraint = dependentConstraints.Get(i);
                if (constraint.ConstType == 0)
                {
                    tableSet.Add(constraint.GetMain());
                    dropConstraintSet.Add(constraint.GetMainName());
                    dropConstraintSet.Add(constraint.GetRefName());
                    containingIndexNames.Add(constraint.GetRefIndex().GetName());
                }
                if (constraint.ConstType == 1)
                {
                    tableSet.Add(constraint.GetRef());
                    dropConstraintSet.Add(constraint.GetMainName());
                    dropConstraintSet.Add(constraint.GetRefName());
                    containingIndexNames.Add(constraint.GetRefIndex().GetName());
                }
                dropConstraintSet.Add(constraint.GetName());
            }
            tableSet = this.MakeNewTables(tableSet, dropConstraintSet, containingIndexNames);
            Table newTable = this._table.MoveDefinition(this._session, this._table.TableType, null, null, null, colIndex, -1, dropConstraintSet, containingIndexNames);

            this.MoveData(this._table, newTable, colIndex, -1);
            this._database.schemaManager.RemoveSchemaObjects(referencingObjectNames);
            this._database.schemaManager.RemoveSchemaObjects(dropConstraintSet);
            this._database.schemaManager.RemoveSchemaObject(name);
            this.SetNewTableInSchema(newTable);
            this.SetNewTablesInSchema(tableSet);
            this.UpdateConstraints(newTable, this.EmptySetQName);
            this.UpdateConstraints(tableSet, dropConstraintSet);
            this._database.schemaManager.RecompileDependentObjects(tableSet);
            this._database.schemaManager.RecompileDependentObjects(newTable);
            newTable.Compile(this._session, null);
            if (column.GetDataType().IsLobType())
            {
                IRowIterator rowIterator = this._table.GetRowIterator(this._session);
                while (rowIterator.HasNext())
                {
                    object[] rowData = rowIterator.GetNextRow().RowData;
                    if (rowData[colIndex] != null)
                    {
                        this._session.sessionData.AdjustLobUsageCount(rowData[colIndex], -1);
                    }
                }
            }
            this._table = newTable;
        }
Ejemplo n.º 20
0
 public virtual OrderedHashSet <SubQuery> GetSubqueries()
 {
     return(OrderedHashSet <SubQuery> .AddAll(this._leftQueryExpression.GetSubqueries(), this._rightQueryExpression.GetSubqueries()));
 }
Ejemplo n.º 21
0
        public void GetTriggerTableNames(OrderedHashSet <QNameManager.QName> set, bool write)
        {
            int index = 0;

            while (index < base.BaseTable.TriggerList.Length)
            {
                TriggerDef def  = base.BaseTable.TriggerList[index];
                int        type = base.type;
                if (type <= 50)
                {
                    if (type == 0x13)
                    {
                        if (def.GetStatementType() != 0x13)
                        {
                            goto Label_0070;
                        }
                    }
                    else
                    {
                        if (type != 50)
                        {
                            goto Label_00A9;
                        }
                        if (def.GetStatementType() != 50)
                        {
                            goto Label_0070;
                        }
                    }
                    goto Label_0076;
                }
                if (type != 0x52)
                {
                    if (type != 0x80)
                    {
                        goto Label_00A9;
                    }
                    if ((def.GetStatementType() != 50) && (def.GetStatementType() != 0x52))
                    {
                        goto Label_0070;
                    }
                    goto Label_0076;
                }
                if (def.GetStatementType() == 0x52)
                {
                    goto Label_0076;
                }
Label_0070:
                index++;
                continue;
Label_0076:
                if (def.routine != null)
                {
                    if (write)
                    {
                        set.AddAll(def.routine.GetTableNamesForWrite());
                    }
                    else
                    {
                        set.AddAll(def.routine.GetTableNamesForRead());
                    }
                }
                goto Label_0070;
Label_00A9:
                throw Error.RuntimeError(0xc9, "StatementDML");
            }
        }