Remove unnecessary nanos arg from uuid7, add insn const

This commit is contained in:
PThorpe92
2024-12-19 20:25:52 -05:00
parent c1561ecbb0
commit f96f289609
2 changed files with 20 additions and 13 deletions

View File

@@ -161,15 +161,6 @@ Feature support of [sqlite expr syntax](https://www.sqlite.org/lang_expr.html).
| zeroblob(N) | Yes | |
|-------------------------------------------------|
| LibSql / sqlean Scalar | | |
| ---------------------------- | ------ | ------- |
| uuid4() | Yes | uuid version 4 **uuid's are `blob` by default** |
| uuid4_str() | Yes | uuid v4 string alias `gen_random_uuid()` for PG compatibility|
| uuid7(X?) | Yes | uuid version 7, Optional arg for seconds since epoch|
| uuid7_timestamp_ms(X) | Yes | Convert a uuid v7 to milliseconds since epoch|
| uuid_str(X) | Yes | Convert a valid uuid to string|
| uuid_blob(X) | Yes | Convert a valid uuid to blob|
@@ -462,3 +453,16 @@ Feature support of [sqlite expr syntax](https://www.sqlite.org/lang_expr.html).
| Variable | No |
| VerifyCookie | No |
| Yield | Yes |
| LibSql Compatibility / Extensions| | |
| ---------------------------- | ------ | ------- |
| **UUID** | | UUID's in limbo are `blobs` by default|
| uuid4() | Yes | uuid version 4 |
| uuid4_str() | Yes | uuid v4 string alias `gen_random_uuid()` for PG compatibility|
| uuid7(X?) | Yes | uuid version 7, Optional arg for seconds since epoch|
| uuid7_timestamp_ms(X) | Yes | Convert a uuid v7 to milliseconds since epoch|
| uuid_str(X) | Yes | Convert a valid uuid to string|
| uuid_blob(X) | Yes | Convert a valid uuid to blob|

View File

@@ -1231,17 +1231,17 @@ pub fn translate_expr(
}
ScalarFunc::Uuid7 => {
let args = match args {
Some(args) if args.len() > 3 => crate::bail_parse_error!(
"{} function with more than 2 arguments",
Some(args) if args.len() > 1 => crate::bail_parse_error!(
"{} function with more than 1 argument",
srf.to_string()
),
Some(args) => args,
None => &vec![],
};
let mut start_reg = None;
for arg in args.iter() {
if let Some(arg) = args.first() {
let reg = program.alloc_register();
start_reg = Some(start_reg.unwrap_or(reg));
start_reg = Some(reg);
translate_expr(
program,
referenced_tables,
@@ -1249,6 +1249,9 @@ pub fn translate_expr(
reg,
precomputed_exprs_to_registers,
)?;
if let ast::Expr::Literal(_) = arg {
program.mark_last_insn_constant()
}
}
program.emit_insn(Insn::Function {
constant_mask: 0,