예제 #1
0
        /// <summary>
        /// isc_database_info
        /// </summary>
        private void DatabaseInfo(byte[] items, byte[] buffer, int bufferLength)
        {
            lock (this)
            {
                try
                {
                    // see src/remote/protocol.h for packet	definition (p_info struct)
                    this.Send.Write(IscCodes.op_info_database);                         //	operation
                    this.Send.Write(this.handle);                                       //	db_handle
                    this.Send.Write(0);                                                 //	incarnation
                    this.Send.WriteBuffer(items, items.Length);                         //	items
                    this.Send.Write(bufferLength);                                      //	result buffer length

                    this.Send.Flush();

                    GdsResponse r = this.ReadGenericResponse();

                    Buffer.BlockCopy(r.Data, 0, buffer, 0, bufferLength);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_network_error);
                }
            }
        }
예제 #2
0
        public override void PutSlice(System.Array sourceArray, int sliceLength)
        {
            lock (this.db)
            {
                try
                {
                    byte[] sdl   = this.GenerateSDL(this.Descriptor);
                    byte[] slice = this.EncodeSliceArray(sourceArray);

                    this.db.Send.Write(IscCodes.op_put_slice);                      // Op code
                    this.db.Send.Write(this.transaction.Handle);                    // Transaction
                    this.db.Send.Write((long)0);                                    // Array Handle
                    this.db.Send.Write(sliceLength);                                // Slice length
                    this.db.Send.WriteBuffer(sdl);                                  // Slice descriptor	language
                    this.db.Send.Write(String.Empty);                               // Slice parameters
                    this.db.Send.Write(sliceLength);                                // Slice length
                    this.db.Send.Write(slice, 0, slice.Length);                     // Slice proper
                    this.db.Send.Flush();

                    GdsResponse r = this.db.ReadGenericResponse();

                    this.handle = r.BlobId;
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
예제 #3
0
        private void CreateOrOpen(int op, BlobParameterBuffer bpb)
        {
            lock (this.db)
            {
                try
                {
                    this.db.Send.Write(op);
                    if (bpb != null)
                    {
                        this.db.Send.WriteTyped(IscCodes.isc_bpb_version1, bpb.ToArray());
                    }
                    this.db.Send.Write(this.transaction.Handle);
                    this.db.Send.Write(this.blobId);
                    this.db.Send.Flush();

                    GdsResponse r = this.db.ReadGenericResponse();

                    this.blobId     = r.BlobId;
                    this.blobHandle = r.ObjectHandle;
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
예제 #4
0
        internal GdsResponse ReadGenericResponse()
        {
            try
            {
                if (this.ReadOperation() == IscCodes.op_response)
                {
                    GdsResponse r = new GdsResponse(
                        this.receive.ReadInt32(),
                        this.receive.ReadInt64(),
                        this.receive.ReadBuffer());

                    r.Warning = this.ReadStatusVector();

                    return(r);
                }
                else
                {
                    return(null);
                }
            }
            catch (IOException)
            {
                throw new IscException(IscCodes.isc_net_read_err);
            }
        }
예제 #5
0
		public void Query(
			ServiceParameterBuffer	spb,
			int						requestLength,
			byte[]					requestBuffer,
			int						bufferLength,
			byte[]					buffer)
		{
			lock (this)
			{
				try
				{
					this.connection.Send.Write(IscCodes.op_service_info);	//	operation
					this.connection.Send.Write(this.Handle);				//	db_handle
					this.connection.Send.Write((int)0);						//	incarnation					
					this.connection.Send.WriteTyped(
						IscCodes.isc_spb_version, spb.ToArray());			//	Service parameter buffer
					this.connection.Send.WriteBuffer(
						requestBuffer, requestLength);						//	request	buffer
					this.connection.Send.Write(bufferLength);				//	result buffer length

					this.connection.Send.Flush();

					GdsResponse r = this.connection.ReadGenericResponse();

					Buffer.BlockCopy(r.Data, 0, buffer, 0, bufferLength);
				}
				catch (IOException)
				{
					throw new IscException(IscCodes.isc_network_error);
				}
			}
		}
예제 #6
0
        protected override byte[] GetSegment()
        {
            int requested = this.SegmentSize;

            lock (this.db)
            {
                try
                {
                    this.db.Send.Write(IscCodes.op_get_segment);
                    this.db.Send.Write(this.blobHandle);
                    this.db.Send.Write((requested + 2 < short.MaxValue) ? requested + 2 : short.MaxValue);
                    this.db.Send.Write((int)0);                         // Data	segment
                    this.db.Send.Flush();

                    GdsResponse r = this.db.ReadGenericResponse();

                    this.RblRemoveValue(IscCodes.RBL_segment);
                    if (r.ObjectHandle == 1)
                    {
                        this.RblAddValue(IscCodes.RBL_segment);
                    }
                    else if (r.ObjectHandle == 2)
                    {
                        this.RblAddValue(IscCodes.RBL_eof_pending);
                    }

                    byte[] buffer = r.Data;

                    if (buffer.Length == 0)
                    {
                        // previous	segment	was	last, this has no data
                        return(buffer);
                    }

                    int len     = 0;
                    int srcpos  = 0;
                    int destpos = 0;
                    while (srcpos < buffer.Length)
                    {
                        len     = IscHelper.VaxInteger(buffer, srcpos, 2);
                        srcpos += 2;

                        Buffer.BlockCopy(buffer, srcpos, buffer, destpos, len);
                        srcpos  += len;
                        destpos += len;
                    }

                    byte[] result = new byte[destpos];
                    Buffer.BlockCopy(buffer, 0, result, 0, destpos);

                    return(result);
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
예제 #7
0
        internal GdsResponse ReadGenericResponse()
        {
            GdsResponse response = this.connection.ReadGenericResponse();

            if (response != null && response.Warning != null)
            {
                if (this.warningMessage != null)
                {
                    this.warningMessage(response.Warning);
                }
            }

            return(response);
        }
예제 #8
0
        public override void Prepare(string commandText)
        {
            // Clear data
            this.Clear();
            this.parameters = null;
            this.fields     = null;

            lock (this.db)
            {
                if (this.state == StatementState.Deallocated)
                {
                    // Allocate	statement
                    this.Allocate();
                }

                try
                {
                    this.db.Send.Write(IscCodes.op_prepare_statement);
                    this.db.Send.Write(this.transaction.Handle);
                    this.db.Send.Write(this.handle);
                    this.db.Send.Write((int)this.db.Dialect);
                    this.db.Send.Write(commandText);
                    this.db.Send.WriteBuffer(DescribeInfoItems, DescribeInfoItems.Length);
                    this.db.Send.Write(IscCodes.MAX_BUFFER_SIZE);
                    this.db.Send.Flush();

                    GdsResponse r = this.db.ReadGenericResponse();
                    this.fields = this.ParseSqlInfo(r.Data, DescribeInfoItems);

                    // Determine the statement type
                    this.statementType = this.GetStatementType();

                    this.state = StatementState.Prepared;
                }
                catch (IOException)
                {
                    this.state = StatementState.Error;
                    throw new IscException(IscCodes.isc_net_read_err);
                }
            }
        }
예제 #9
0
        protected override void Seek(int position)
        {
            lock (this.db)
            {
                try
                {
                    this.db.Send.Write(IscCodes.op_seek_blob);
                    this.db.Send.Write(this.blobHandle);
                    this.db.Send.Write(0);                                              // Seek	mode
                    this.db.Send.Write(position);                                       // Seek	offset
                    this.db.Send.Flush();

                    GdsResponse r = db.ReadGenericResponse();

                    this.position = r.ObjectHandle;
                }
                catch (IOException)
                {
                    throw new IscException(IscCodes.isc_network_error);
                }
            }
        }
		internal GdsResponse ReadGenericResponse()
		{
			try
			{
				if (this.ReadOperation() == IscCodes.op_response)
				{
					GdsResponse r = new GdsResponse(
						this.receive.ReadInt32(),
						this.receive.ReadInt64(),
						this.receive.ReadBuffer());

					r.Warning = this.ReadStatusVector();

					return r;
				}
				else
				{
					return null;
				}
			}
			catch (IOException)
			{
				throw new IscException(IscCodes.isc_net_read_err);
			}
		}