is_rowid_alias instead of primary_key

This commit is contained in:
jussisaurio
2024-08-11 17:10:52 +03:00
parent 2e32ca0bdb
commit 9ab08ee2e6
2 changed files with 9 additions and 9 deletions

View File

@@ -817,9 +817,9 @@ fn table_columns(
let mut cur_reg = start_reg;
let cursor_id = cursor_override.unwrap_or(program.resolve_cursor_id(table_identifier, None));
for i in 0..table.columns.len() {
let is_primary_key = table.columns[i].primary_key;
let is_rowid = table.column_is_rowid_alias(&table.columns[i]);
let col_type = &table.columns[i].ty;
if is_primary_key {
if is_rowid {
program.emit_insn(Insn::RowId {
cursor_id,
dest: cur_reg,

View File

@@ -1046,9 +1046,9 @@ pub fn translate_expr(
ast::Expr::FunctionCallStar { .. } => todo!(),
ast::Expr::Id(ident) => {
// let (idx, col) = table.unwrap().get_column(&ident.0).unwrap();
let (idx, col_type, cursor_id, is_primary_key) =
let (idx, col_type, cursor_id, is_rowid_alias) =
resolve_ident_table(program, &ident.0, referenced_tables, cursor_hint)?;
if is_primary_key {
if is_rowid_alias {
program.emit_insn(Insn::RowId {
cursor_id,
dest: target_register,
@@ -1234,12 +1234,12 @@ pub fn resolve_ident_table(
.iter()
.enumerate()
.find(|(_, col)| col.name == *ident)
.map(|(idx, col)| (idx, col.ty, col.primary_key));
.map(|(idx, col)| (idx, col.ty, catalog_table.column_is_rowid_alias(col)));
let mut idx;
let mut col_type;
let mut is_primary_key;
let mut is_rowid_alias;
if res.is_some() {
(idx, col_type, is_primary_key) = res.unwrap();
(idx, col_type, is_rowid_alias) = res.unwrap();
// overwrite if cursor hint is provided
if let Some(cursor_hint) = cursor_hint {
let cols = &program.cursor_ref[cursor_hint].1;
@@ -1251,11 +1251,11 @@ pub fn resolve_ident_table(
}) {
idx = res.0;
col_type = res.1.ty;
is_primary_key = res.1.primary_key;
is_rowid_alias = catalog_table.column_is_rowid_alias(&res.1);
}
}
let cursor_id = program.resolve_cursor_id(identifier, cursor_hint);
found.push((idx, col_type, cursor_id, is_primary_key));
found.push((idx, col_type, cursor_id, is_rowid_alias));
}
}
if found.len() == 1 {