feat: Additional uint
datatype support for the SQL interface
#15993
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Finally got to grips with destructuring a nested
vec
("helloas_slice
"😜) so was able to cleanly register some custom datatypes with the SQL parser.Patch notes
PostgreSQL supports the following integer types
int2
,int4
,int8
(for which we also allow thesmallint
,integer
andbigint
aliases). Unfortunately it does not offer unsigned ints, and the parser doesn't offer them (directly) either. We also allowtinyint
for 1 byte ints.There is an extension called
pguint
1 (maintained by one of the PostgreSQL core developers) that addsuint1
,uint2
,uint4
, anduint8
types, as well asint1
.This PR adds support for these additional integer types by registering them via the parser's
SQLDataType::Custom
extension point.Also contains a fix for "CAST", making it strict by default; previously we might silently eat invalid/overflowing casts and return
null
values, which is not desirable.Sorted type parsing code into blocks of related dtypes (vs lexical order) for clarity.
Example
(Note that PostgreSQL defines its datatype sizes in bytes, not bits).
Footnotes
https://github.com/petere/pguint ↩