Commit e6d7f3f
fix: avoid panic in TableSchema::with_table_partition_cols on shared Arc
`with_table_partition_cols` appended to an existing partition-column list
via `Arc::get_mut(...).expect(...)`. The `expect` message assumed that
owning `self` implied sole ownership of the inner `Arc<Vec<FieldRef>>`,
which is false: `TableSchema` is `Clone`, and cloning bumps the `Arc`
refcount without copying. Building a `TableSchema`, cloning it, and then
calling `with_table_partition_cols` on either copy panicked.
Use `Arc::make_mut`, which mutates in place when uniquely owned and
copy-on-writes when the `Arc` is shared. This also removes the
empty/non-empty branch since `make_mut` handles both.
Add a regression test that clones a `TableSchema` and appends partition
columns to the clone, verifying no panic and copy-on-write isolation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 50013e5 commit e6d7f3f
1 file changed
Lines changed: 36 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
152 | 149 | | |
153 | 150 | | |
154 | 151 | | |
| |||
276 | 273 | | |
277 | 274 | | |
278 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
279 | 306 | | |
0 commit comments