Beispiel #1
0
        public void AddParameter(ColumnSchema param)
        {
            QNameManager.QName name = param.GetName();
            string             key  = (name == null) ? QNameManager.GetAutoNoNameColumnString(this.ParameterList.Size()) : name.Name;

            this.ParameterList.Add(key, param);
        }
Beispiel #2
0
        public Index CreateAndAddIndexStructure(Session session, QNameManager.QName name, int[] columns, bool[] descending, bool[] nullsLast, bool unique, bool constraint, bool forward)
        {
            Index index = this.CreateIndexStructure(name, columns, descending, nullsLast, unique, constraint, forward);

            this.AddIndex(session, index);
            return(index);
        }
Beispiel #3
0
        private Result GetExplainResult(Session session)
        {
            Result result = Result.NewSingleColumnStringResult("OPERATION", this.Describe(session));
            OrderedHashSet <QNameManager.QName> references = this.GetReferences();

            object[] data = new object[] { "Object References" };
            result.navigator.Add(data);
            for (int i = 0; i < references.Size(); i++)
            {
                QNameManager.QName name      = references.Get(i);
                object[]           objArray2 = new object[] { name.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray2);
            }
            object[] objArray3 = new object[] { "Read Locks" };
            result.navigator.Add(objArray3);
            for (int j = 0; j < base.ReadTableNames.Length; j++)
            {
                QNameManager.QName name2     = base.ReadTableNames[j];
                object[]           objArray4 = new object[] { name2.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray4);
            }
            object[] objArray5 = new object[] { "WriteLocks" };
            result.navigator.Add(objArray5);
            for (int k = 0; k < base.WriteTableNames.Length; k++)
            {
                QNameManager.QName name3     = base.WriteTableNames[k];
                object[]           objArray6 = new object[] { name3.GetSchemaQualifiedStatementName() };
                result.navigator.Add(objArray6);
            }
            return(result);
        }
Beispiel #4
0
 public Constraint(QNameManager.QName name, OrderedHashSet <string> mainCols, int type)
 {
     this.Core       = new ConstraintCore();
     this._name      = name;
     this.ConstType  = type;
     this.MainColSet = mainCols;
 }
Beispiel #5
0
 private static SqlType GetTimeStamp()
 {
     QNameManager.QName name = QNameManager.NewInfoSchemaObjectName("TIME_STAMP", false, 13);
     TimeStamp = new DateTimeType(0x5d, 0x5d, 6);
     TimeStamp.userTypeModifier = new UserTypeModifier(name, 13, TimeStamp);
     return(TimeStamp);
 }
Beispiel #6
0
 private void SetOrCheckObjectName(Session session, QNameManager.QName parent, QNameManager.QName name, bool check)
 {
     if (name.schema == null)
     {
         name.schema = base.SchemaName ?? session.GetCurrentSchemaQName();
     }
     else
     {
         name.schema = session.GetSchemaQName(name.schema.Name);
         if (name.schema == null)
         {
             throw Error.GetError(0x1581);
         }
         if (this.IsSchemaDefinition && (base.SchemaName != name.schema))
         {
             throw Error.GetError(0x1581);
         }
     }
     name.Parent = parent;
     if (!this.IsSchemaDefinition)
     {
         CheckSchemaUpdateAuthorisation(session, name.schema);
     }
     if (check)
     {
         session.database.schemaManager.CheckSchemaObjectNotExists(name);
     }
 }
Beispiel #7
0
 public Session NewSysSession(QNameManager.QName schema, User user)
 {
     return(new Session(this._sysSession.database, user, false, false, 0L, null, 0)
     {
         CurrentSchema = schema
     });
 }
Beispiel #8
0
        public Right GetAllGrantableRights(QNameManager.QName name)
        {
            if (this._isAdmin)
            {
                return(name.schema.Owner.OwnerRights);
            }
            if (name.schema.Owner == this)
            {
                return(this.OwnerRights);
            }
            if (this.Roles.Contains(name.schema.Owner))
            {
                return(name.schema.Owner.OwnerRights);
            }
            OrderedHashSet <Grantee> allRoles = this.GetAllRoles();

            for (int i = 0; i < allRoles.Size(); i++)
            {
                Grantee grantee = allRoles.Get(i);
                if (name.schema.Owner == grantee)
                {
                    return(grantee.OwnerRights);
                }
            }
            Right right2 = this._fullRightsMap.Get(name);

            if ((right2 != null) && (right2.GrantableRights != null))
            {
                return(right2.GrantableRights);
            }
            return(Right.NoRights);
        }
Beispiel #9
0
 public User(QNameManager.QName name, GranteeManager manager) : base(name, manager)
 {
     if (manager != null)
     {
         base.UpdateAllRights();
     }
 }
Beispiel #10
0
 public void RemoveDbObject(QNameManager.QName name)
 {
     for (int i = 0; i < this._map.Size(); i++)
     {
         this._map.Get(i).RevokeDbObject(name);
     }
 }
Beispiel #11
0
        public OrderedHashSet <QNameManager.QName> GetReferences()
        {
            switch (this.ConstType)
            {
            case 0:
            {
                OrderedHashSet <QNameManager.QName> set1 = new OrderedHashSet <QNameManager.QName>();
                set1.Add(this.Core.UniqueName);
                return(set1);
            }

            case 3:
            {
                OrderedHashSet <QNameManager.QName> set = new OrderedHashSet <QNameManager.QName>();
                this.Check.CollectObjectNames(set);
                for (int i = set.Size() - 1; i >= 0; i--)
                {
                    QNameManager.QName name = set.Get(i);
                    if ((name.type == 9) || (name.type == 3))
                    {
                        set.Remove(i);
                    }
                }
                return(set);
            }
            }
            return(new OrderedHashSet <QNameManager.QName>());
        }
Beispiel #12
0
 private static SqlType GetYesOrNo()
 {
     QNameManager.QName name = QNameManager.NewInfoSchemaObjectName("YES_OR_NO", false, 13);
     YesOrNo = new CharacterType(12, 3L);
     YesOrNo.userTypeModifier = new UserTypeModifier(name, 13, YesOrNo);
     return(YesOrNo);
 }
Beispiel #13
0
 private static SqlType GetCharacterData()
 {
     QNameManager.QName name = QNameManager.NewInfoSchemaObjectName("CHARACTER_DATA", false, 13);
     CharacterData = new CharacterType(12, 0x10000L);
     CharacterData.userTypeModifier = new UserTypeModifier(name, 13, CharacterData);
     return(CharacterData);
 }
Beispiel #14
0
 private static SqlType GetSqlIdentifier()
 {
     QNameManager.QName name = QNameManager.NewInfoSchemaObjectName("SQL_IDENTIFIER", false, 13);
     SqlIdentifier = new CharacterType(12, 0x80L);
     SqlIdentifier.userTypeModifier = new UserTypeModifier(name, 13, SqlIdentifier);
     return(SqlIdentifier);
 }
Beispiel #15
0
 public void PrepareTable(Session session, QNameManager.QName name, QNameManager.QName[] columns)
 {
     if (!this._isResolved)
     {
         if (this._table == null)
         {
             this._table = new TableDerived(this.database, name, 2, this.queryExpression, this);
         }
         bool flag1 = (columns != null) && (this.queryExpression > null);
         if (flag1)
         {
             this.queryExpression.GetMainSelect().SetColumnAliases(columns);
         }
         this._table.ColumnList  = this.queryExpression.GetColumns();
         this._table.ColumnCount = this.queryExpression.GetColumnCount();
         if (flag1 && (columns.Length <= this._table.ColumnCount))
         {
             for (int i = 0; i < columns.Length; i++)
             {
                 ColumnSchema schema = this._table.ColumnList.Get(i);
                 schema.ColumnName = columns[i];
                 this._table.ColumnList.Set(i, columns[i].Name, schema);
             }
         }
         TableUtil.SetTableIndexesForSubquery(this._table, this._uniqueRows || this._fullOrder, this._uniqueRows);
         this._isResolved = true;
     }
 }
Beispiel #16
0
 private static SqlType GetCardinalNumber()
 {
     QNameManager.QName name = QNameManager.NewInfoSchemaObjectName("CARDINAL_NUMBER", false, 13);
     CardinalNumber = new NumberType(0x19, 0L, 0);
     CardinalNumber.userTypeModifier = new UserTypeModifier(name, 13, CardinalNumber);
     return(CardinalNumber);
 }
Beispiel #17
0
 public TableDerived(Database database, QNameManager.QName name, int type) : base(database, name, type)
 {
     if (((type != 1) && (type != 8)) && (type != 11))
     {
         throw Error.RuntimeError(0xc9, "Table");
     }
 }
Beispiel #18
0
 private Result ProcessSetUserInitialSchema(Session session)
 {
     try
     {
         User user = (User)this.Parameters[0];
         QNameManager.QName schema = (QNameManager.QName) this.Parameters[1];
         session.CheckDdlWrite();
         if (user == null)
         {
             user = session.GetUser();
         }
         else
         {
             session.CheckAdmin();
             session.CheckDdlWrite();
             user = session.database.userManager.Get(user.GetNameString());
         }
         if (schema != null)
         {
             schema = session.database.schemaManager.GetSchemaQName(schema.Name);
         }
         user.SetInitialSchema(schema);
         session.database.schemaManager.SetSchemaChangeTimestamp();
         return(Result.UpdateZeroResult);
     }
     catch (CoreException exception1)
     {
         return(Result.NewErrorResult(exception1, base.Sql));
     }
 }
Beispiel #19
0
 public void AddConditionName(QNameManager.QName conditionName)
 {
     if (!(((this._conditionNames.Add(conditionName.Name) & this._conditionGroups.IsEmpty()) & this._conditionStates.IsEmpty()) & this._conditionErroCodes.IsEmpty()))
     {
         throw Error.GetError(0x15e4);
     }
 }
Beispiel #20
0
        private void AddToFullRights(MultiValueHashMap <QNameManager.QName, Right> map)
        {
            Iterator <QNameManager.QName> iterator = map.GetKeySet().GetIterator();

            while (iterator.HasNext())
            {
                QNameManager.QName key       = iterator.Next();
                Iterator <Right>   iterator2 = map.Get(key);
                Right right = this._fullRightsMap.Get(key);
                while (iterator2.HasNext())
                {
                    Right right2 = iterator2.Next();
                    if (right == null)
                    {
                        right = right2.Duplicate();
                        this._fullRightsMap.Put(key, right);
                    }
                    else
                    {
                        right.Add(right2);
                    }
                    if (right2.GrantableRights != null)
                    {
                        if (right.GrantableRights == null)
                        {
                            right.GrantableRights = right2.GrantableRights.Duplicate();
                        }
                        else
                        {
                            right.GrantableRights.Add(right2.GrantableRights);
                        }
                    }
                }
            }
        }
Beispiel #21
0
        public IndexAVL(QNameManager.QName name, long id, TableBase table, int[] columns, bool[] descending, bool[] nullsLast, SqlType[] colTypes, bool pk, bool unique, bool constraint, bool forward)
        {
            this.PersistenceId = id;
            this.Name          = name;
            this.ColIndex      = columns;
            this.ColTypes      = colTypes;
            this.ColDesc       = descending ?? new bool[columns.Length];
            this.NullsLast     = nullsLast ?? new bool[columns.Length];
            this.IsPk          = pk;
            this.isUnique      = unique;
            this.isConstraint  = constraint;
            this.isForward     = forward;
            this.table         = table;
            this.ColCheck      = table.GetNewColumnCheckList();
            ArrayUtil.IntIndexesToboolArray(this.ColIndex, this.ColCheck);
            this.DefaultColMap = new int[columns.Length];
            ArrayUtil.FillSequence(this.DefaultColMap);
            bool flag = this.ColIndex.Length > 0;

            for (int i = 0; i < this.ColDesc.Length; i++)
            {
                if (this.ColDesc[i] || this.NullsLast[i])
                {
                    flag = false;
                }
            }
            this.IsSimpleOrder = flag;
            this.IsSimple      = this.IsSimpleOrder && (this.ColIndex.Length == 1);
            this._nullData     = new object[this.ColIndex.Length];
        }
 public bool SetWaitedSessionsTpl(Session session, Statement cs)
 {
     session.TempSet.Clear();
     if (cs == null)
     {
         return(true);
     }
     if (!session.AbortTransaction)
     {
         foreach (QNameManager.QName name in cs.GetTableNamesForWrite())
         {
             if (name.schema != SqlInvariants.SystemSchemaQname)
             {
                 Session key = this._tableWriteLocks.Get(name);
                 if ((key != null) && (key != session))
                 {
                     session.TempSet.Add(key);
                 }
                 Iterator <Session> iterator = this._tableReadLocks.Get(name);
                 while (iterator.HasNext())
                 {
                     key = iterator.Next();
                     if (key != session)
                     {
                         session.TempSet.Add(key);
                     }
                 }
             }
         }
         QNameManager.QName[] tableNamesForRead = cs.GetTableNamesForRead();
         if ((this.TxModel == 1) && session.IsReadOnly())
         {
             tableNamesForRead = this.catalogNameList;
         }
         for (int i = 0; i < tableNamesForRead.Length; i++)
         {
             QNameManager.QName key = tableNamesForRead[i];
             if (key.schema != SqlInvariants.SystemSchemaQname)
             {
                 Session session3 = this._tableWriteLocks.Get(key);
                 if ((session3 != null) && (session3 != session))
                 {
                     session.TempSet.Add(session3);
                 }
             }
         }
         if (session.TempSet.IsEmpty())
         {
             return(true);
         }
         if (this.CheckDeadlock(session, session.TempSet))
         {
             return(true);
         }
         session.TempSet.Clear();
         session.AbortTransaction = true;
     }
     return(false);
 }
Beispiel #23
0
 public StatementSimple(int type, QNameManager.QName label, string cursorVariableName) : base(type, 0x7d3)
 {
     this._conditionIndex         = -1;
     this.cursorVariableNameIndex = -1;
     base.References         = new OrderedHashSet <QNameManager.QName>();
     this.label              = label;
     this.cursorVariableName = cursorVariableName;
 }
Beispiel #24
0
 public StatementSimple(int type, QNameManager.QName label) : base(type, 0x7d7)
 {
     this._conditionIndex         = -1;
     this.cursorVariableNameIndex = -1;
     base.References             = new OrderedHashSet <QNameManager.QName>();
     base.isTransactionStatement = false;
     this.label = label;
 }
Beispiel #25
0
 public TableDerived(Database database, QNameManager.QName name, int type, QueryExpression queryExpression, SubQuery subQuery) : base(database, name, type)
 {
     if ((type != 2) && ((type - 8) > 1))
     {
         throw Error.RuntimeError(0xc9, "Table");
     }
     this.queryExpression = queryExpression;
     this._subQuery       = subQuery;
 }
Beispiel #26
0
 public StatementSimple(int type, QNameManager.QName conditionName, Dictionary <int, Expression> conditionInformationItems) : base(type, 0x7d7)
 {
     this._conditionIndex         = -1;
     this.cursorVariableNameIndex = -1;
     base.References                 = new OrderedHashSet <QNameManager.QName>();
     base.isTransactionStatement     = false;
     this._conditionName             = conditionName;
     this._conditionInformationItems = conditionInformationItems;
 }
Beispiel #27
0
 public static void SetColumnsInSchemaTable(Table table, QNameManager.QName[] columnNames, SqlType[] columnTypes, byte[] columnNullability)
 {
     for (int i = 0; i < columnNames.Length; i++)
     {
         QNameManager.QName name   = columnNames[i];
         ColumnSchema       column = new ColumnSchema(table.database.NameManager.NewColumnSchemaQName(table.GetName(), name), columnTypes[i], (columnNullability == null) || (columnNullability[i] > 0), false, null);
         table.AddColumn(column);
     }
     table.SetColumnStructures();
 }
Beispiel #28
0
 public ColumnSchema(QNameManager.QName name, SqlType type, bool isNullable, bool isPrimaryKey, Expression defaultExpression)
 {
     this.ColumnName         = name;
     base.Nullability        = isNullable ? ((byte)1) : ((byte)0);
     base.DataType           = type;
     this._isPrimaryKey      = isPrimaryKey;
     this._defaultExpression = defaultExpression;
     this.HasDefault         = defaultExpression > null;
     this.SetReferences();
 }
Beispiel #29
0
        public bool IsAccessible(QNameManager.QName name)
        {
            if (this.IsFullyAccessibleByRole(name))
            {
                return(true);
            }
            Right right = this._fullRightsMap.Get(name);

            return(((right != null) && !right.IsEmpty()) || (!this._isPublic && this.granteeManager.PublicRole.IsAccessible(name)));
        }
Beispiel #30
0
        public User CreateUser(QNameManager.QName name, string password)
        {
            User user = this._granteeManager.AddUser(name);

            user.SetPassword(password);
            if (!this._userList.Add(name.Name, user))
            {
                throw Error.GetError(0xfa3, name.StatementName);
            }
            return(user);
        }