Skip to content

Commit 6a8e0cc

Browse files
committed
controller: DfType for custom types' default value
If a postgres table's column has a custom type (which includes enums), Readyset does not resolve that custom type when determining the column's default value at lowering from MIR to Dataflow. This causes a failure when deriving the column's default value when the column is attributed as either having a default or being not null. This CL passes the known `custom_types` to the existing call to `DfType::from_sql_type()`. Addresses: REA-5746 Release-Note-Core: Fix that allows snapshotting postgres tables where a column of a custom type is attributed NOT NULL but has no default value. Change-Id: I4e37e44bbe0b56b120ccfdb7d65e702e5d1afd8b Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9954 Reviewed-by: Michael Zink <michael.z@readyset.io> Tested-by: Buildkite CI
1 parent ab1dc47 commit 6a8e0cc

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

readyset-server/src/controller/mir_to_flow.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,23 @@ fn make_base_node(
380380
let df: DfValue = dv
381381
.try_into_dialect(mig.dialect.into())
382382
.map_err(|e| internal_err!("Failed to convert default value: {}", e))?;
383-
let dftype_to =
384-
DfType::from_sql_type(&cs.sql_type, mig.dialect, |_| None, collation).map_err(
385-
|e| internal_err!("Failed to convert SQL type to DfType: {}", e),
386-
)?;
383+
let dftype_to = DfType::from_sql_type(
384+
&cs.sql_type,
385+
mig.dialect,
386+
|ty| custom_types.get(&ty).cloned(),
387+
collation,
388+
)
389+
.map_err(|e| internal_err!("Failed to convert SQL type to DfType: {}", e))?;
387390
return df.coerce_to(&dftype_to, &df.infer_dataflow_type());
388-
} else if cs.is_not_null() {
389-
let dftype_to =
390-
DfType::from_sql_type(&cs.sql_type, mig.dialect, |_| None, collation).map_err(
391-
|e| internal_err!("Failed to convert SQL type to DfType: {}", e),
392-
)?;
391+
} else if cs.is_not_null() && mig.dialect == readyset_sql::Dialect::MySQL.into() {
392+
// this branch is really only to support mysql minimal row-based replication.
393+
let dftype_to = DfType::from_sql_type(
394+
&cs.sql_type,
395+
mig.dialect,
396+
|ty| custom_types.get(&ty).cloned(),
397+
collation,
398+
)
399+
.map_err(|e| internal_err!("Failed to convert SQL type to DfType: {}", e))?;
393400

394401
return Ok(DfValue::implicit_default(
395402
collation.unwrap_or(Collation::Utf8),

0 commit comments

Comments
 (0)