예제 #1
0
        /// <summary>
        /// Cancels and terminates an ongoing operation. Any data already written will be discarded.
        /// </summary>
        public void Cancel()
        {
            CheckDisposed();

            if (CanWrite)
            {
                _isDisposed = true;
                _buf.Clear();
                _connector.SendSingleMessage(new CopyFailMessage());
                try
                {
                    var msg = _connector.ReadSingleMessage();
                    // The CopyFail should immediately trigger an exception from the read above.
                    _connector.Break();
                    throw new Exception("Expected ErrorResponse when cancelling COPY but got: " + msg.Code);
                }
                catch (NpgsqlException e)
                {
                    if (e.Code == "57014")
                    {
                        return;
                    }
                    throw;
                }
            }
            else
            {
                _connector.CancelRequest();
            }
        }
예제 #2
0
        /// <summary>
        /// Cancels and terminates an ongoing operation. Any data already written will be discarded.
        /// </summary>
        public void Cancel()
        {
            CheckDisposed();

            if (CanWrite)
            {
                _isDisposed = true;
                _buf.Clear();
                _connector.SendSingleMessage(new CopyFailMessage());
                try
                {
                    var msg = _connector.ReadSingleMessage();
                    _connector.State = ConnectorState.Broken;
                    throw new Exception("Expected ErrorResponse when cancelling COPY but got: " + msg.Code);
                }
                catch (NpgsqlException e)
                {
                    if (e.Code == "57014")
                    {
                        return;
                    }
                    throw;
                }
            }
            else
            {
                _connector.CancelRequest();
            }
        }
예제 #3
0
 /// <summary>
 /// Cancels and terminates an ongoing import. Any data already written will be discarded.
 /// </summary>
 public void Cancel()
 {
     _isDisposed = true;
     _buf.Clear();
     _connector.SendSingleMessage(new CopyFailMessage());
     try {
         var msg = _connector.ReadSingleMessage();
         _connector.Break();
         throw new Exception("Expected ErrorResponse when cancelling COPY but got: " + msg.Code);
     } catch (NpgsqlException e) {
         if (e.Code == "57014")
         {
             return;
         }
         throw;
     }
 }