Decode a tuple written with an older schema version. Columns present in the old schema are extracted normally. Columns added in newer schema versions return their declared default value, or `Value::Null` for nullable columns without a default. `old_col_count` is the number of columns in the schema version that wrote this tuple. Correctness invariant: a non-nullable column added via `ALTER ADD C
(
&self,
tuple: &[u8],
col_idx: usize,
old_col_count: usize,
)
| 269 | /// `NOT NULL` without a `DEFAULT`, so every non-nullable column in the |
| 270 | /// schema must have `col.default` populated. |
| 271 | pub fn extract_value_versioned( |
| 272 | &self, |
| 273 | tuple: &[u8], |
| 274 | col_idx: usize, |
| 275 | old_col_count: usize, |
| 276 | ) -> Result<Value, StrictError> { |
| 277 | self.check_bounds(col_idx)?; |
| 278 | |
| 279 | if col_idx >= old_col_count { |
| 280 | // Column was added after this tuple was written: materialize the |
| 281 | // declared default, or null for nullable columns without a default. |
| 282 | let col = &self.schema.columns[col_idx]; |
| 283 | let value = col |
| 284 | .default |
| 285 | .as_deref() |
| 286 | .map(nodedb_types::columnar::StrictSchema::parse_default_literal) |
| 287 | .unwrap_or(Value::Null); |
| 288 | return Ok(value); |
| 289 | } |
| 290 | |
| 291 | self.extract_value(tuple, col_idx) |
| 292 | } |
| 293 | |
| 294 | /// Access the schema this decoder was built for. |
| 295 | pub fn schema(&self) -> &StrictSchema { |