EnvRenameDatabase() private method

private EnvRenameDatabase ( IntPtr handle, short oldName, short newName ) : int
handle System.IntPtr
oldName short
newName short
return int
Ejemplo n.º 1
0
        /// <summary>
        /// Renames a Database in this Environment
        /// </summary>
        /// <remarks>
        /// This method wraps the native ups_env_rename_db function.
        /// </remarks>
        /// <param name="oldName">The old name of the Database. If a Database
        /// with this name does not exist, the function will throw
        /// <see cref="UpsConst.UPS_DATABASE_NOT_FOUND"/>.</param>
        /// <param name="newName">The new name of the Database. If a Database
        /// with this name already exists, the function will throw
        /// <see cref="UpsConst.UPS_DATABASE_ALREADY_EXISTS"/>.</param>
        /// <exception cref="DatabaseException">
        ///   <list type="bullet">
        ///   <item><see cref="UpsConst.UPS_INV_PARAMETER"/>
        ///     if the new Database name is reserved</item>
        ///   <item><see cref="UpsConst.UPS_DATABASE_NOT_FOUND"/>
        ///     if a Database with this name does not exist</item>
        ///   <item><see cref="UpsConst.UPS_DATABASE_ALREADY_EXISTS"/>
        ///     if a Database with the new name already exists</item>
        ///   <item><see cref="UpsConst.UPS_OUT_OF_MEMORY"/>
        ///     if memory could not be allocated</item>
        ///   </list>
        /// </exception>
        public void RenameDatabase(short oldName, short newName)
        {
            int st;

            lock (this) {
                st = NativeMethods.EnvRenameDatabase(handle, oldName, newName);
            }
            if (st != 0)
            {
                throw new DatabaseException(st);
            }
        }