-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement is and is not where constraints #847
Conversation
Those two expr seem to be supported
Now it has the same name as NotNull, so it is easier to write macros
The main difference between = and != is how null values are handled. SQLite passes a flag "NULLEQ" to Eq and Ne to disambiguate that. In the presence of that flag, NULL = NULL. Some prep work is done to make sure we can pass a flag instead of a boolean to Eq and Ne. I looked into the bitflags crate but got a bit scared with the list of dependencies.
core/vdbe/insn.rs
Outdated
@@ -6,6 +6,36 @@ use crate::storage::wal::CheckpointMode; | |||
use crate::types::{OwnedRecord, OwnedValue}; | |||
use limbo_macros::Description; | |||
|
|||
#[derive(Clone, Copy, Debug, Default)] | |||
pub struct Flags(usize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we call this e.g. CmpInsnFlags
and add a documentation comment:
/// Flags provided to comparison instructions (e.g. Eq, Ne) which determine behavior related to NULL values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I'd rather rename the Flags
struct.
Could you also create an issue about the OR
behavior so we can track it
Those Flags in SQLite are global, but it doesn't mean it has to be the case for us as well.
This seems to really be just an alias for IS: "The IS NOT DISTINCT FROM operator is an alternative spelling for the IS operator. Likewise, the IS DISTINCT FROM operator means the same thing as IS NOT. Standard SQL does not support the compact IS and IS NOT notation. Those compact forms are an SQLite extension. You have to use the prolix and much less readable IS NOT DISTINCT FROM and IS DISTINCT FROM operators on other SQL database engines."
The main difference between = and != is how null values are handled.
SQLite passes a flag "NULLEQ" to Eq and Ne to disambiguate that.
In the presence of that flag, NULL = NULL.
Some prep work is done to make sure we can pass a flag instead of a
boolean to Eq and Ne. I looked into the bitflags crate but got a bit
scared with the list of dependencies.
Warning:
The following query produces a different result for Limbo:
I strongly suspect the issue is with the OR implementation, though. The bytecode generated is quite different.