duckdb / duckdb/pg_duckdb

Minimum hugeint overflows in conversion to PG numeric

Open
#593 0 comments 0 reactions 0 assignees View on GitHub
bug incorrect result
Dominant language
C++
Stars
3.2k
Forks
204
PR merge metrics
No merged PRs in 30d

Description

### Description

This query returns `0`:
```
select * from duckdb.query($$ select '-170141183460469231731687303715884105728'::hugeint as result $$);
```
But one higher works fine:

```
select * from duckdb.query($$ select '-170141183460469231731687303715884105728'::hugeint + 1 as result $$);
```

The reason for this is that [this line overflows](https://github.com/duckdb/pg_duckdb/blob/02ebeaec1b42619fab806fc881e67de0821b380d/src/pgduckdb_types.cpp#L274), because the positive 170141183460469231731687303715884105728 cannot be represented in a signed int128.

Found by #577

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.