コード例 #1
0
ファイル: SystemUserSession.cs プロジェクト: prepare/deveeldb
 public SystemUserSession(IDatabase database, ITransaction transaction, string currentSchema)
 {
     Database = database;
     CurrentSchema =currentSchema;
     Transaction = transaction;
     SessionInfo = new SessionInfo(User.System, transaction.Isolation);
 }
コード例 #2
0
ファイル: UserSession.cs プロジェクト: prepare/deveeldb
        /// <summary>
        /// Constructs the session for the given user and transaction to the
        /// given database.
        /// </summary>
        /// <param name="database">The database to which the user is connected.</param>
        /// <param name="transaction">A transaction that handles the commands issued by
        /// the user during the session.</param>
        /// <param name="sessionInfo">The information about the session to be created (user, 
        /// connection endpoint, statistics, etc.)</param>
        /// <seealso cref="ITransaction"/>
        /// <seealso cref="SessionInfo"/>
        public UserSession(IDatabase database, ITransaction transaction, SessionInfo sessionInfo)
        {
            if (database == null)
                throw new ArgumentNullException("database");
            if (transaction == null)
                throw new ArgumentNullException("transaction");
            if (sessionInfo == null)
                throw new ArgumentNullException("sessionInfo");

            if (sessionInfo.User.IsSystem ||
                sessionInfo.User.IsPublic)
                throw new ArgumentException(String.Format("Cannot open a session for user '{0}'.", sessionInfo.User.Name));

            Database = database;
            Transaction = transaction;

            Database.DatabaseContext.Sessions.Add(this);

            SessionInfo = sessionInfo;
        }
コード例 #3
0
        public static IUserSession CreateUserSession(this IDatabase database, SessionInfo sessionInfo)
        {
            if (sessionInfo == null)
                throw new ArgumentNullException("sessionInfo");

            // TODO: if the isolation is not specified, use a configured default one
            var isolation = sessionInfo.Isolation;
            if (isolation == TransactionIsolation.Unspecified)
                isolation = TransactionIsolation.Serializable;

            if (sessionInfo.CommitId >= 0)
                throw new ArgumentException("Cannot create a session that reference an existing commit state.");

            var transaction = database.CreateTransaction(isolation);
            return new UserSession(database, transaction, sessionInfo);
        }
コード例 #4
0
        public static IUserSession OpenUserSession(this IDatabase database, SessionInfo sessionInfo)
        {
            if (sessionInfo == null)
                throw new ArgumentNullException("sessionInfo");

            var commitId = sessionInfo.CommitId;

            if (commitId < 0)
                throw new ArgumentException("Invalid commit reference specified.");

            var transaction = database.FindTransactionById(commitId);
            if (transaction == null)
                throw new InvalidOperationException(String.Format("The request transaction with ID '{0}' is not open.", commitId));

            return new UserSession(database, transaction, sessionInfo);
        }