Esempio n. 1
0
        internal void PrepareInternal(string sql, PrepareOption flag)
        {
            con.ReconnectIfNeed();

            CubridStream stream = con.Stream;

            stream.RequestPrepare(sql, flag);

            handle = stream.ResponseCode;
            resultCacheLifetime = stream.ReadInt();
            statementType       = (CubridStatementype)stream.ReadByte();
            bindCount           = stream.ReadInt();
            isUpdateable        = (stream.ReadByte() == 1);
            columnCount         = stream.ReadInt();

            Debug.WriteLine("handle = " + handle);
            Debug.WriteLine("resultCacheLifetime = " + resultCacheLifetime);
            Debug.WriteLine("statementType = " + statementType);
            Debug.WriteLine("bindCount = " + bindCount);
            Debug.WriteLine("isUpdateable = " + isUpdateable);
            Debug.WriteLine("columnCount = " + columnCount);

            columnInfos = stream.ReadColumnInfo(columnCount);

            if (bindCount > 0)
            {
                parameters = new CubridParameter[bindCount];
            }

            if (statementType == CubridStatementype.CallStoredProcedure)
            {
                columnCount = bindCount + 1;
            }
        }
Esempio n. 2
0
        public void ConnectToServer(string server, int port, string db, string user, string password)
        {
            this.server   = server;
            this.port     = port;
            this.database = db;
            this.user     = user;
            this.password = password;

            isKeepConnection   = false;
            isStatementPooling = false;

            stream = new CubridStream();
            Reconnect();
        }
Esempio n. 3
0
        internal void GetOutResultSet(int handle)
        {
            CubridStream stream = con.Stream;

            this.handle = stream.RequestOutResultSet(handle); //TODO: check to need to free old handle

            statementType = (CubridStatementype)stream.ReadByte();
            resultCount   = stream.ReadInt();
            isUpdateable  = (stream.ReadByte() == 1);
            columnCount   = stream.ReadInt();

            Debug.WriteLine("handle = " + handle);
            Debug.WriteLine("statementType = " + statementType);
            Debug.WriteLine("isUpdateable = " + isUpdateable);
            Debug.WriteLine("columnCount = " + columnCount);

            columnInfos = stream.ReadColumnInfo(columnCount);
        }
Esempio n. 4
0
        internal void ExecuteInternal()
        {
            if (parameters != null && IsAllParameterBound() == false)
            {
                throw new CubridException("All parameters are not bound.");
            }

            CubridStream stream = con.Stream;

            byte[] paramModes = null;
            byte   fetchFlag  = 0;

            if (statementType == CubridStatementype.CallStoredProcedure && parameters != null)
            {
                paramModes = new byte[parameters.Length];
                for (int i = 0; i < parameters.Length; i++)
                {
                    paramModes[i] = (byte)parameters[i].Direction;
                }
            }

            if (statementType == CubridStatementype.Select)
            {
                fetchFlag = 1;
            }

            int totalTupleCount = stream.RequestExecute(handle, ExecutionOption.Normal, parameters,
                                                        paramModes, fetchFlag, con.AutoCommit);

            cache_reusable = stream.ReadByte();
            resultCount    = stream.ReadInt();

            Debug.WriteLine("cache_reusable = {0}" + cache_reusable);
            Debug.WriteLine("resultCount = {0}" + resultCount);

            resultInfos = stream.ReadResultInfo(resultCount);

            if (statementType == CubridStatementype.Select)
            {
                int fetchCode  = stream.ReadInt();
                int tupleCount = stream.ReadInt();
                cursor = new CubridDataReader(this, handle, totalTupleCount, columnInfos, tupleCount);
            }
        }
Esempio n. 5
0
        internal bool NextResult()
        {
            CubridStream stream = con.Stream;

            int totalTupleCount = stream.RequestNextResult(handle);

            CubridStatementype commandTypeIs = (CubridStatementype)stream.ReadByte();
            bool isUpdatable  = (stream.ReadByte() == 1) ? true : false;
            int  columnNumber = stream.ReadInt();

            columnInfos = stream.ReadColumnInfo(columnNumber);


            if (commandTypeIs == CubridStatementype.Select)
            {
                cursor = new CubridDataReader(this, handle, totalTupleCount, columnInfos);
            }

            return(true);
        }
Esempio n. 6
0
        private void Fetch()
        {
            CubridStream stream = con.Stream;

            tupleCount += stream.RequestFetch(handle);
        }
Esempio n. 7
0
        private void MoveCursor(int offset, CursorOrigin origin)
        {
            CubridStream stream = con.Stream;

            int totalTupleNumber = stream.RequestMoveCursor(handle, offset, origin);
        }
Esempio n. 8
0
        internal void Write(CubridStream stream)
        {
            if (val == null)
            {
                stream.WriteByteArg((byte)CubridDataType.Null);
                stream.WriteNullArg();
            }
            else
            {
                stream.WriteByteArg((byte)type);

                switch (type)
                {
                case CubridDataType.Null:
                    stream.WriteNullArg();
                    break;

                case CubridDataType.Char:
                case CubridDataType.Nchar:
                case CubridDataType.String:
                case CubridDataType.Varnchar:
                    stream.WriteStringArg((string)val, Encoding.Default);
                    break;

                case CubridDataType.Short:
                    stream.WriteShortArg((short)val);
                    break;

                case CubridDataType.Int:
                    stream.WriteIntArg((int)val);
                    break;

                case CubridDataType.Float:
                    stream.WriteFloatArg((float)val);
                    break;

                case CubridDataType.Double:
                case CubridDataType.Monetary:
                    stream.WriteDoubleArg((double)val);
                    break;

                case CubridDataType.Date:
                    stream.WriteDateArg((DateTime)val);
                    break;

                case CubridDataType.Time:
                    stream.WriteTimeArg((DateTime)val);
                    break;

                case CubridDataType.Timestamp:
                    stream.WriteDateTimeArg((DateTime)val);
                    break;

                case CubridDataType.Set:
                case CubridDataType.Multiset:
                case CubridDataType.Sequence:
                    stream.WriteCollection((object[])val);
                    break;

                case CubridDataType.Bit:
                case CubridDataType.Varbit:
                    stream.WriteByteArg((byte[])val);
                    break;

                case CubridDataType.Numeric:
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 9
0
        public void ConnectToServer(string server, int port, string db, string user, string password)
        {
            this.server = server;
            this.port = port;
            this.database = db;
            this.user = user;
            this.password = password;

            isKeepConnection = false;
            isStatementPooling = false;

            stream = new CubridStream();
            Reconnect();
        }
Esempio n. 10
0
        internal void Write(CubridStream stream)
        {
            if (val == null)
            {
                stream.WriteByteArg((byte)CubridDataType.Null);
                stream.WriteNullArg();
            }
            else
            {
                stream.WriteByteArg((byte)type);

                switch (type)
                {
                    case CubridDataType.Null:
                        stream.WriteNullArg();
                        break;

                    case CubridDataType.Char:
                    case CubridDataType.Nchar:
                    case CubridDataType.String:
                    case CubridDataType.Varnchar:
                        stream.WriteStringArg((string)val, Encoding.Default);
                        break;

                    case CubridDataType.Short:
                        stream.WriteShortArg((short)val);
                        break;

                    case CubridDataType.Int:
                        stream.WriteIntArg((int)val);
                        break;

                    case CubridDataType.Float:
                        stream.WriteFloatArg((float)val);
                        break;

                    case CubridDataType.Double:
                    case CubridDataType.Monetary:
                        stream.WriteDoubleArg((double)val);
                        break;

                    case CubridDataType.Date:
                        stream.WriteDateArg((DateTime)val);
                        break;

                    case CubridDataType.Time:
                        stream.WriteTimeArg((DateTime)val);
                        break;

                    case CubridDataType.Timestamp:
                        stream.WriteDateTimeArg((DateTime)val);
                        break;

                    case CubridDataType.Set:
                    case CubridDataType.Multiset:
                    case CubridDataType.Sequence:
                        stream.WriteCollection((object[])val);
                        break;

                    case CubridDataType.Bit:
                    case CubridDataType.Varbit:
                        stream.WriteByteArg((byte[])val);
                        break;

                    case CubridDataType.Numeric:
                        break;

                    default:
                        break;
                }
            }
        }