Created
October 11, 2016 04:55
-
-
Save bgrainger/76b3125bd643801e11285851c62da730 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using MySql.Data.MySqlClient; | |
namespace MySqlCompressBlob | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var csb = new MySqlConnectionStringBuilder | |
{ | |
Server = "localhost", | |
Database = "test", | |
UserID = "root", | |
Password = /* redacted */ | |
UseCompression = true, | |
}; | |
using (var connection = new MySqlConnection(csb.ConnectionString)) | |
{ | |
connection.Open(); | |
using (var cmd = new MySqlCommand("drop table if exists test.blobs; create table test.blobs(data longblob)", connection)) | |
cmd.ExecuteNonQuery(); | |
var bytes = new byte[16519390]; // causes http://bugs.mysql.com/bug.php?id=83329 with new byte[16519389] | |
var random = new Random(1); | |
random.NextBytes(bytes); | |
using (var cmd = new MySqlCommand("insert into test.blobs(data) values(@data);", connection)) | |
{ | |
cmd.Parameters.AddWithValue("data", bytes); | |
cmd.ExecuteNonQuery(); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment