Skip to content

Commit

Permalink
core: Move datetime.rs to vdbe/
Browse files Browse the repository at this point in the history
The file contains SQL functions invoked by the VDBE so let's move the
file there.
  • Loading branch information
penberg committed Aug 2, 2024
1 parent 01d432f commit d55e9f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 0 additions & 1 deletion core/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod datetime;
mod error;
mod function;
mod io;
Expand Down
File renamed without changes.
15 changes: 8 additions & 7 deletions core/vdbe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ pub mod builder;
pub mod explain;
pub mod sorter;

use crate::datetime::{exec_date, exec_time};
mod datetime;

use crate::error::LimboError;
use crate::function::{AggFunc, ScalarFunc};
use crate::pseudo::PseudoCursor;
Expand All @@ -31,6 +32,8 @@ use crate::storage::{btree::BTreeCursor, pager::Pager};
use crate::types::{AggContext, Cursor, CursorResult, OwnedRecord, OwnedValue, Record};
use crate::Result;

use datetime::{exec_date, exec_time};

use regex::Regex;
use std::borrow::BorrowMut;
use std::cell::RefCell;
Expand Down Expand Up @@ -1277,9 +1280,8 @@ impl Program {
}
ScalarFunc::Date => {
if *start_reg == 0 {
let date_str = exec_date(&OwnedValue::Text(Rc::new(
"now".to_string(),
)))?;
let date_str =
exec_date(&OwnedValue::Text(Rc::new("now".to_string())))?;
state.registers[*dest] = OwnedValue::Text(Rc::new(date_str));
} else {
let time_value = &state.registers[*start_reg];
Expand All @@ -1300,9 +1302,8 @@ impl Program {
}
ScalarFunc::Time => {
if *start_reg == 0 {
let time_str = exec_time(&OwnedValue::Text(
Rc::new("now".to_string()),
))?;
let time_str =
exec_time(&OwnedValue::Text(Rc::new("now".to_string())))?;
state.registers[*dest] = OwnedValue::Text(Rc::new(time_str));
} else {
let datetime_value = &state.registers[*start_reg];
Expand Down

0 comments on commit d55e9f3

Please sign in to comment.