exec: integer overflow isn't handled in plus or mult projection ops #36691
Labels
A-sql-execution
Relating to SQL execution.
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Milestone
Currently, the addition projection ops don't handle integer overflow, but their equivalents in the
Datum.Eval
model do.We should add overflow detection, assuming that it actually is important. It's unclear to me whether overflow detection is required by the SQL standard, or indeed important to users. Postgres does have it, but it was introduced relatively recently, in 2004: https://www.postgresql.org/message-id/5124.1096832332@sss.pgh.pa.us
The strategy recommended by Zukowski (http://oai.cwi.nl/oai/asset/14075/14075B.pdf) for integer overflow on values smaller than
int64
is to perform the addition on the data type one larger than the input,OR
the overflow bit into a result variable during the addition loop, and check the result of that bit after the loop.For
int64
, we could use a similar structure to avoid conditional branches, but more checks will be required.The text was updated successfully, but these errors were encountered: