예제 #1
0
        public void GetCharsOnLongTextColumn()
        {
            execSQL("INSERT INTO Test (id, text1) VALUES(1, 'Test')");

            MySqlCommand    cmd    = new MySqlCommand("SELECT id, text1 FROM Test", conn);
            MySqlDataReader reader = null;

            try
            {
                char[] buf = new char[2];

                reader = cmd.ExecuteReader();
                reader.Read();
                reader.GetChars(1, 0, buf, 0, 2);
                Assert.AreEqual('T', buf[0]);
                Assert.AreEqual('e', buf[1]);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
예제 #2
0
 public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length)
 {
     if (types[ordinal].ClrEquivalentType != reader.GetFieldType(ordinal))
     {
         return((long)GetValue(ordinal));
     }
     return(reader.GetChars(ordinal, dataOffset, buffer, bufferOffset, length));
 }
예제 #3
0
        private void InternalGetChars(bool prepare)
        {
            ExecuteSQL("DROP TABLE IF EXISTS Test");
            ExecuteSQL("CREATE TABLE Test (id INT NOT NULL, text1 LONGTEXT, PRIMARY KEY(id))");

            char[] data = new char[20000];
            for (int x = 0; x < data.Length; x++)
            {
                data[x] = (char)(65 + (x % 20));
            }

            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, ?text1)", Connection);

            cmd.Parameters.AddWithValue("?text1", data);
            if (prepare)
            {
                cmd.Prepare();
            }
            cmd.ExecuteNonQuery();

            cmd.CommandText = "SELECT * FROM Test";
            cmd.Parameters.Clear();
            if (prepare)
            {
                cmd.Prepare();
            }

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                reader.Read();

                // now we test chunking
                char[] dataOut   = new char[data.Length];
                int    pos       = 0;
                int    lenToRead = data.Length;
                while (lenToRead > 0)
                {
                    int size = Math.Min(lenToRead, 1024);
                    int read = (int)reader.GetChars(1, pos, dataOut, pos, size);
                    lenToRead -= read;
                    pos       += read;
                }
                // now see if the buffer is intact
                for (int x = 0; x < data.Length; x++)
                {
                    Assert.True(data[x] == dataOut[x], "Checking first text array at " + x);
                }
            }
        }
예제 #4
0
        public void GetCharsOnLongTextColumn()
        {
            execSQL("CREATE TABLE Test (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))");
            execSQL("INSERT INTO Test (id, text1) VALUES(1, 'Test')");

            MySqlCommand cmd = new MySqlCommand("SELECT id, text1 FROM Test", conn);

            char[] buf = new char[2];

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                reader.Read();
                reader.GetChars(1, 0, buf, 0, 2);
                Assert.AreEqual('T', buf[0]);
                Assert.AreEqual('e', buf[1]);
            }
        }
예제 #5
0
        public void GetCharsOnLongTextColumn()
        {
            //if (st.conn.connectionState != ConnectionState.Open)
            //  st.conn.Open();

            st.execSQL("CREATE TABLE Test1 (id INT NOT NULL, blob1 LONGBLOB, text1 LONGTEXT, PRIMARY KEY(id))");
            st.execSQL("INSERT INTO Test1 (id, text1) VALUES(1, 'Test')");

            MySqlCommand cmd = new MySqlCommand("SELECT id, text1 FROM Test1", st.conn);

            char[] buf = new char[2];

            using (MySqlDataReader reader = cmd.ExecuteReader())
            {
                reader.Read();
                reader.GetChars(1, 0, buf, 0, 2);
                Assert.Equal(buf[0], 'T');
                Assert.Equal(buf[1], 'e');
            }
        }
예제 #6
0
 public override long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length)
 {
     return(reader.GetChars(ordinal, dataOffset, buffer, bufferOffset, length));
 }
 public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
 {
     return(_mySqlDataReader.GetChars(i, fieldoffset, buffer, bufferoffset, length));
 }
예제 #8
0
        private void InternalGetChars(bool prepare)
        {
            execSQL("TRUNCATE TABLE Test");

            char[] data = new char[20000];
            for (int x = 0; x < data.Length; x++)
            {
                data[x] = (char)(65 + (x % 20));
            }

            MySqlCommand cmd = new MySqlCommand("INSERT INTO Test VALUES (1, NULL, ?text1)", conn);

            cmd.Parameters.AddWithValue("?text1", data);
            if (prepare)
            {
                cmd.Prepare();
            }
            cmd.ExecuteNonQuery();

            cmd.CommandText = "SELECT * FROM Test";
            cmd.Parameters.Clear();
            if (prepare)
            {
                cmd.Prepare();
            }
            MySqlDataReader reader = null;

            try
            {
                reader = cmd.ExecuteReader();
                reader.Read();

                // now we test chunking
                char[] dataOut   = new char[data.Length];
                int    pos       = 0;
                int    lenToRead = data.Length;
                while (lenToRead > 0)
                {
                    int size = Math.Min(lenToRead, 1024);
                    int read = (int)reader.GetChars(2, pos, dataOut, pos, size);
                    lenToRead -= read;
                    pos       += read;
                }
                // now see if the buffer is intact
                for (int x = 0; x < data.Length; x++)
                {
                    Assert.AreEqual(data[x], dataOut[x], "Checking first text array at " + x);
                }
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
        }
예제 #9
0
 public long GetChars(int ordinal, long dataOffset, char[] buffer, int bufferOffset, int length) => _dataReader.GetChars(ordinal, dataOffset, buffer, bufferOffset, length);