Esempio n. 1
0
 /// <summary>
 /// Skips the current column without interpreting its value.
 /// </summary>
 public void Skip()
 {
     ReadColumnLenIfNeeded();
     if (_columnLen != -1)
     {
         _buf.Skip(_columnLen);
     }
     _columnLen = int.MinValue;
     _column++;
 }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed || !disposing)
            {
                return;
            }

            if (CanWrite)
            {
                Flush();
                _connector.SendMessage(CopyDoneMessage.Instance);
                _connector.ReadExpecting <CommandCompleteMessage>();
                _connector.ReadExpecting <ReadyForQueryMessage>();
            }
            else
            {
                if (!_isConsumed)
                {
                    if (_leftToReadInDataMsg > 0)
                    {
                        _readBuf.Skip(_leftToReadInDataMsg);
                    }
                    _connector.SkipUntil(BackendMessageCode.ReadyForQuery);
                }
            }

            _connector.CurrentCopyOperation = null;
            _connector.EndUserAction();
            Cleanup();
        }
Esempio n. 3
0
        /// <remarks>
        /// A type handler may implement IChunkingTypeHandler for types other than its primary one.
        /// This is why this method has type parameter T2 and not T.
        /// </remarks>
        internal override ValueTask <T2> Read <T2>(ReadBuffer buf, int len, bool async, FieldDescription fieldDescription = null)
        {
            var asTypedHandler = this as IChunkingTypeHandler <T2>;

            if (asTypedHandler == null)
            {
                buf.Skip(len);  // Perform this in sync for performance
                throw new SafeReadException(new InvalidCastException(fieldDescription == null
                    ? "Can't cast database type to " + typeof(T2).Name
                    : $"Can't cast database type {fieldDescription.Handler.PgDisplayName} to {typeof(T2).Name}"
                                                                     ));
            }

            return(asTypedHandler.Read(buf, len, async, fieldDescription));
        }