Skip to content

Commit 3ad7f74

Browse files
committed
fix panic in aggr queries for n_key_col, return 0 if no grpby
1 parent fdc5797 commit 3ad7f74

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
@@ -2842,11 +2842,9 @@ fn translate_without_rowid_insert(
28422842
description: format_unique_violation_desc(&table.name, pk_index),
28432843
});
28442844

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

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

2906-
29072904
program.emit_insn(Insn::MakeRecord {
29082905
start_reg: reordered_start_reg,
29092906
count: insertion.col_mappings.len(),
@@ -2912,8 +2909,6 @@ fn translate_without_rowid_insert(
29122909
affinity_str: Some(affinity_str),
29132910
});
29142911

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

core/translate/main_loop.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,11 @@ pub fn init_loop(
189189
where_clause: None,
190190
index_method: None,
191191
is_primary_key: false,
192-
n_key_col: group_by.as_ref().unwrap().exprs.len(),
192+
n_key_col: if let Some(gb) = group_by.as_ref() {
193+
gb.exprs.len()
194+
} else {
195+
0
196+
},
193197
});
194198
let cursor_id = program.alloc_cursor_id(CursorType::BTreeIndex(index.clone()));
195199
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)