Skip to content

Commit 5ac8de1

Browse files
readyset-data: Binary Column inferred default value
This change adds support for binary columns in the inferred default value. Closes: REA-5706 Closes: #1504 Release-Note-Core: Added support for inferring MySQL default values for binary columns. Change-Id: I6f134c9da2d33039d90ccc1bf14eff09bd9f0c3c Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9290 Tested-by: Buildkite CI Reviewed-by: Michael Zink <michael.z@readyset.io>
1 parent d25eb08 commit 5ac8de1

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

readyset-data/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,15 @@ impl DfValue {
10001000
}
10011001
} else if matches!(dftype, DfType::Json) {
10021002
return DfValue::from_str_and_collation("null", Collation::Utf8);
1003+
} else if dftype.is_binary() {
1004+
match dftype {
1005+
DfType::Binary(len) => {
1006+
return DfValue::ByteArray(vec![0; len as usize].into());
1007+
}
1008+
_ => {
1009+
return DfValue::ByteArray(vec![0; 0].into());
1010+
}
1011+
}
10031012
}
10041013
DfValue::None
10051014
}

replicators/tests/tests.rs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4199,3 +4199,57 @@ async fn mysql_minimal_row_based_char_padding() {
41994199

42004200
shutdown_tx.shutdown().await;
42014201
}
4202+
4203+
#[tokio::test(flavor = "multi_thread")]
4204+
#[serial(mysql)]
4205+
#[slow]
4206+
async fn mysql_minimal_row_based_binary() {
4207+
readyset_tracing::init_test_logging();
4208+
let url = mysql_url();
4209+
let mut client = DbConnection::connect(&url).await.unwrap();
4210+
4211+
client
4212+
.query("SET binlog_row_image = minimal;")
4213+
.await
4214+
.unwrap();
4215+
client.query("SET sql_mode = '';").await.unwrap();
4216+
client
4217+
.query("DROP TABLE IF EXISTS mrbr_binary;")
4218+
.await
4219+
.unwrap();
4220+
client
4221+
.query(
4222+
"CREATE TABLE mrbr_binary (id INT, b BINARY(10) NOT NULL, vb VARBINARY(10) NOT NULL);",
4223+
)
4224+
.await
4225+
.unwrap();
4226+
4227+
let (mut ctx, shutdown_tx) = TestHandle::start_noria(url.to_string(), None)
4228+
.await
4229+
.unwrap();
4230+
4231+
ctx.controller_rx
4232+
.as_mut()
4233+
.unwrap()
4234+
.snapshot_completed()
4235+
.await
4236+
.unwrap();
4237+
4238+
client
4239+
.query("INSERT INTO mrbr_binary (id) VALUES (0);")
4240+
.await
4241+
.unwrap();
4242+
4243+
check_results!(
4244+
ctx,
4245+
"mrbr_binary",
4246+
"mrbr_binary_insert",
4247+
&[&[
4248+
DfValue::Int(0),
4249+
DfValue::ByteArray(vec![0; 10].into()),
4250+
DfValue::ByteArray(vec![0; 0].into())
4251+
]]
4252+
);
4253+
4254+
shutdown_tx.shutdown().await;
4255+
}

0 commit comments

Comments
 (0)