core: Fix codegen for rowid alias

We should emit `Column` bytecode for a primary key, unless it is an alias for a rowid.
This commit is contained in:
Pekka Enberg 2024-06-21 13:09:55 +03:00
parent 8d4d2f32ee
commit 828fb813a8
2 changed files with 8 additions and 1 deletions

View file

@ -154,6 +154,13 @@ pub struct Column {
pub primary_key: bool,
}
impl Column {
pub fn is_rowid_alias(&self) -> bool {
self.primary_key && self.ty == Type::Integer
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Type {
Null,
Text,

View file

@ -174,7 +174,7 @@ fn translate_columns(
sqlite3_parser::ast::ResultColumn::Star => {
for (i, col) in table.unwrap().columns.iter().enumerate() {
let dest = program.alloc_register();
if col.primary_key {
if col.is_rowid_alias() {
program.emit_insn(Insn::RowId {
cursor_id: cursor_id.unwrap(),
dest,