Skip to content

Commit

Permalink
if pk specified in col constraint, do not rewrite it into table const…
Browse files Browse the repository at this point in the history
…raint

Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Jan 6, 2025
1 parent dcaec6e commit b958c45
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/frontend/src/catalog/purify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,17 @@ pub fn try_purify_table_source_create_sql_ast(
});
}

// Remove primary key constraint from the column options. It will be specified with
// table constraints later.
column_def
.options
.retain(|o| !matches!(o.option, ColumnOption::Unique { is_primary: true }));

purified_column_defs.push(column_def);
}
*column_defs = purified_column_defs;

if row_id_index.is_none() {
// User-defined primary key.
// Specify user-defined primary key in table constraints.
let has_pk_column_constraint = column_defs.iter().any(|c| {
c.options
.iter()
.any(|o| matches!(o.option, ColumnOption::Unique { is_primary: true }))
});
if !has_pk_column_constraint && row_id_index.is_none() {
let mut pk_columns = Vec::new();

for &id in pk_column_ids {
Expand Down

0 comments on commit b958c45

Please sign in to comment.