-
Notifications
You must be signed in to change notification settings - Fork 97
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
refactor numeric code and handle typmod better #2091
base: main
Are you sure you want to change the base?
Conversation
// This is to reverse what make_numeric_typmod of Postgres does: | ||
// logic copied from: https://github.com/postgres/postgres/blob/c4d5cb71d229095a39fda1121a75ee40e6069a2a/src/backend/utils/adt/numeric.c#L929 | ||
// Maps most "invalid" typmods to be unconstrained (same as -1) | ||
func NewParsedNumericTypmod(typmod int32) *NumericTypmod { |
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.
func NewParsedNumericTypmod(typmod int32) *NumericTypmod { | |
func NewParsedNumericTypmod(typmod int32) NumericTypmod { |
Seems like a type best passed by value & treated as immutable. Can even fit a Valid bool without impacting struct size, but seems that's what constrained
might be
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.
not a big fan of passing by value since we need to store this in QField which currently has no way to communicate something is only needed for numerics
basically an implicit vs explicit thing
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.
That'd be handled by a Valid bool
precision := int16((offsetMod >> 16) & 0x7FFF) | ||
scale := int16(offsetMod & 0x7FFF) | ||
return precision, scale | ||
func (t *NumericTypmod) PrecisionAndScale() (int16, int16) { |
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 make Precision/Scale public & remove this. No need for nil checks if you usually work with these by value
started with numeric refactor, but discovered typmod is being handled improperly in some places
bumped BQ to BIGNUMERIC limits
added tests for typmod parsing