Example #1
0
 /// <summary>
 /// Called from NpgsqlState.ProcessBackendResponses upon CopyOutResponse.
 /// If CopyStream is already set, it is used to write data received from server, after which the copy ends.
 /// Otherwise CopyStream is set to a readable NpgsqlCopyOutStream that receives data from server.
 /// </summary>
 protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
 {
     _copyFormat = copyFormat;
     Stream userFeed = context.Mediator.CopyStream;
     if (userFeed == null)
     {
         context.Mediator.CopyStream = new NpgsqlCopyOutStream(context);
     }
     else
     {
         byte[] buf;
         while ((buf = GetCopyData(context)) != null)
         {
             userFeed.Write(buf, 0, buf.Length);
         }
         userFeed.Close();
     }
 }
Example #2
0
        /// <summary>
        /// Called from NpgsqlState.ProcessBackendResponses upon CopyOutResponse.
        /// If CopyStream is already set, it is used to write data received from server, after which the copy ends.
        /// Otherwise CopyStream is set to a readable NpgsqlCopyOutStream that receives data from server.
        /// </summary>
        protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            _copyFormat = copyFormat;
            Stream userFeed = context.Mediator.CopyStream;

            if (userFeed == null)
            {
                context.Mediator.CopyStream = new NpgsqlCopyOutStream(context);
            }
            else
            {
                byte[] buf;
                while ((buf = GetCopyData(context)) != null)
                {
                    userFeed.Write(buf, 0, buf.Length);
                }
                userFeed.Close();
            }
        }
Example #3
0
		/// <summary>
		/// Called from NpgsqlState.ProcessBackendResponses upon CopyInResponse.
		/// If CopyStream is already set, it is used to read data to push to server, after which the copy is completed.
		/// Otherwise CopyStream is set to a writable NpgsqlCopyInStream that calls SendCopyData each time it is written to.
		/// </summary>
		protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
		{
			_copyFormat = copyFormat;
			Stream userFeed = context.Mediator.CopyStream;
			if (userFeed == null)
			{
				context.Mediator.CopyStream = new NpgsqlCopyInStream(context);
			}
			else
			{
				// copy all of user feed to server at once
				int bufsiz = context.Mediator.CopyBufferSize;
				byte[] buf = new byte[bufsiz];
				int len;
				while ((len = userFeed.Read(buf, 0, bufsiz)) > 0)
				{
					SendCopyData(context, buf, 0, len);
				}
				SendCopyDone(context);
			}
		}
Example #4
0
        /// <summary>
        /// Called from NpgsqlState.ProcessBackendResponses upon CopyInResponse.
        /// If CopyStream is already set, it is used to read data to push to server, after which the copy is completed.
        /// Otherwise CopyStream is set to a writable NpgsqlCopyInStream that calls SendCopyData each time it is written to.
        /// </summary>
        protected override void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            _copyFormat = copyFormat;
            Stream userFeed = context.Mediator.CopyStream;

            if (userFeed == null)
            {
                context.Mediator.CopyStream = new NpgsqlCopyInStream(context);
            }
            else
            {
                // copy all of user feed to server at once
                int    bufsiz = context.Mediator.CopyBufferSize;
                byte[] buf    = new byte[bufsiz];
                int    len;
                while ((len = userFeed.Read(buf, 0, bufsiz)) > 0)
                {
                    SendCopyData(context, buf, 0, len);
                }
                SendCopyDone(context);
            }
        }
Example #5
0
 /// <summary>
 /// Called from NpgsqlState.ProcessBackendResponses upon CopyInResponse.
 /// If CopyStream is already set, it is used to read data to push to server, after which the copy is completed.
 /// Otherwise CopyStream is set to a writable NpgsqlCopyInStream that calls SendCopyData each time it is written to.
 /// </summary>
 internal void StartCopyIn(NpgsqlCopyFormat copyFormat)
 {
     CopyFormat = copyFormat;
     var userFeed = Mediator.CopyStream;
     if (userFeed == null)
     {
         Mediator.CopyStream = new NpgsqlCopyInStream(this);
     }
     else
     {
         // copy all of user feed to server at once
         var bufsiz = Mediator.CopyBufferSize;
         var buf = new byte[bufsiz];
         int len;
         while ((len = userFeed.Read(buf, 0, bufsiz)) > 0)
         {
             SendCopyInData(buf, 0, len);
         }
         SendCopyInDone();
     }
 }
Example #6
0
 /// <summary>
 /// Called from NpgsqlState.ProcessBackendResponses upon CopyOutResponse.
 /// If CopyStream is already set, it is used to write data received from server, after which the copy ends.
 /// Otherwise CopyStream is set to a readable NpgsqlCopyOutStream that receives data from server.
 /// </summary>
 internal void StartCopyOut(NpgsqlCopyFormat copyFormat)
 {
     throw new NotImplementedException();
     /*
     CopyFormat = copyFormat;
     var userFeed = Mediator.CopyStream;
     if (userFeed == null)
     {
         Mediator.CopyStream = new NpgsqlCopyOutStream(this);
     }
     else
     {
         byte[] buf;
         while ((buf = GetCopyOutData()) != null)
         {
             userFeed.Write(buf, 0, buf.Length);
         }
         userFeed.Close();
     }
      */
 }
Example #7
0
 // COPY methods
 protected virtual void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
 {
     throw new InvalidOperationException("Internal Error! " + this);
 }
Example #8
0
        // COPY methods

        protected virtual void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            throw new InvalidOperationException("Internal Error! " + this);
        }
Example #9
0
        // COPY methods

        protected virtual void StartCopy(NpgsqlConnector context, NpgsqlCopyFormat copyFormat)
        {
            throw new InvalidOperationException("¬нутренн¤¤ ќшибка! " + this);
        }