-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding NUMERIC and DECIMAL types (#186)
`NUMERIC` and `DECIMAL` types are used for arbitrary precision exact numbers. This has a been long in development. It's required several rewrites and some major changes and improvements to vsql in previous versions to lay the foundation for these types to be fully integrated as first class citizens. Now, number literals that contains a '.' (even if they are a whole numbers such as `123.`) are treated as `NUMERIC` with the scale and precision determined from the number. Arithmetic operations can result in types that are higher in scale and precision, according to the standard (which is very specific about all of that). As far as I'm aware vsql is the only SQL database to treat these as distinct types according to the standard, rather than being aliases of the same underlying type. In a nutshell, `NUMERIC` and `DECIMAL` are both stored as fractions, but `NUMERIC` permits any denominator within range, whereas a `DECIMAL` must have a base 10 denominator. You can think of `DECIMAL` as having "exactly" the precision specified (i.e good for currency), but `NUMERIC` has "at least" the precision specified. Meaning it's possible to `CAST` a `NUMERIC` to a higher precision and get more decimal places (from the inherent nature of a fraction). The docs explain this much better, with examples. Since this does introduce new storage types, a database file version bump is required but this likely be the last version bump before v1.0.0 is released. Along with the two new SQL types, there are some functions that work directly with exact numbers: `ABS`, `CEIL`, `FLOOR` and `MOD`. SQL Standard E011-03
- Loading branch information
1 parent
2a1989a
commit 9895e3b
Showing
32 changed files
with
1,553 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.