Skip to content

Commit e31c165

Browse files
committed
fix panic in aggr queries for n_key_col, return 0 if no grpby
1 parent e41b129 commit e31c165

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

core/translate/insert.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2841,11 +2841,9 @@ fn translate_without_rowid_insert(
28412841
description: format_unique_violation_desc(&table.name, pk_index),
28422842
});
28432843

2844-
28452844
program.preassign_label_to_next_insn(ok_to_insert_label);
28462845
tracing::debug!("Uniqueness check passed. Continuing with insertion.");
28472846

2848-
28492847
let physically_ordered_cols: Vec<&Column> = {
28502848
let mut ordered = Vec::with_capacity(table.columns.len());
28512849
let mut pk_cols_added = std::collections::HashSet::new();
@@ -2902,7 +2900,6 @@ fn translate_without_rowid_insert(
29022900
.map(|col| col.affinity().aff_mask())
29032901
.collect::<String>();
29042902

2905-
29062903
program.emit_insn(Insn::MakeRecord {
29072904
start_reg: reordered_start_reg,
29082905
count: insertion.col_mappings.len(),
@@ -2911,8 +2908,6 @@ fn translate_without_rowid_insert(
29112908
affinity_str: Some(affinity_str),
29122909
});
29132910

2914-
2915-
29162911
program.emit_insn(Insn::IdxInsert {
29172912
cursor_id: pk_cursor_id,
29182913
record_reg: full_record_reg,

core/translate/main_loop.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ pub fn init_loop(
185185
where_clause: None,
186186
index_method: None,
187187
is_primary_key: false,
188-
n_key_col: group_by.as_ref().unwrap().exprs.len(),
188+
n_key_col: if let Some(gb) = group_by.as_ref() {
189+
gb.exprs.len()
190+
} else {
191+
0
192+
},
189193
});
190194
let cursor_id = program.alloc_cursor_id(CursorType::BTreeIndex(index.clone()));
191195
if group_by.is_none() {

core/translate/schema.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,6 @@ fn collect_autoindexes(
452452
};
453453

454454
let needs_index = if us.is_primary_key {
455-
456455
!(is_without_rowid || (col.primary_key() && col.is_rowid_alias()))
457456
} else {
458457
// UNIQUE single needs an index

0 commit comments

Comments
 (0)