| 3566 | } |
| 3567 | |
| 3568 | fn key_constraint_err(desc: &RelationDesc, user_keys: &[ColumnName]) -> PlanError { |
| 3569 | let user_keys = user_keys.iter().map(|column| column.as_str()).join(", "); |
| 3570 | |
| 3571 | let existing_keys = desc |
| 3572 | .typ() |
| 3573 | .keys |
| 3574 | .iter() |
| 3575 | .map(|key_columns| { |
| 3576 | key_columns |
| 3577 | .iter() |
| 3578 | .map(|col| desc.get_name(*col).as_str()) |
| 3579 | .join(", ") |
| 3580 | }) |
| 3581 | .join(", "); |
| 3582 | |
| 3583 | sql_err!( |
| 3584 | "Key constraint ({}) conflicts with existing key ({})", |
| 3585 | user_keys, |
| 3586 | existing_keys |
| 3587 | ) |
| 3588 | } |
| 3589 | |
| 3590 | /// Creating this by hand instead of using generate_extracted_config! macro |
| 3591 | /// because the macro doesn't support parameterized enums. See <https://github.com/MaterializeInc/database-issues/issues/6698> |