get_binlog_stream, detect if a col is a primary key #335
-
Hello, i am using now i want to know the primary keys of the i expected something like this to work: EventData::RowsEvent(row_event) => {
let table = /* .... */;
for row in row_event.rows(table) {
match row.unwrap() {
(Some(before), Some(after)) => {
for col in before.columns().iter() {
let is_primary_key = col.flags().contains(ColumnFlags::PRI_KEY_FLAG);
println!("{} is pk: {}", col.name_str(), is_primary_key);
}
},
_ => unreachable!()
};
}
} the problem here is that the primary key is not detected. i also tryed to read it from what is the way to detect the primary key? thanks a lot. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi. At the moment this info is not collected during BinlogRow deserialization. I think it clould be easily added into For now, I believe, you can read it from |
Beta Was this translation helpful? Give feedback.
Hi. At the moment this info is not collected during BinlogRow deserialization. I think it clould be easily added into
impl MyDeserialize for BinlogRow
somewhere near to other flags deserialization.For now, I believe, you can read it from
TableMapEvent
usingiter_optional_meta
– variants of interest areSimplePrimaryKey
andPrimaryKeyWithPrefix
. Description is here