jackc / pgx

PostgreSQL driver and toolkit for Go
MIT License
10.84k stars 846 forks source link

`pgtype.Int8.Scan` compares an `int64` with `math.MinInt64` #2051

Closed rpstw closed 5 months ago

rpstw commented 5 months ago

https://github.com/jackc/pgx/blob/9907b874c223887dba628215feae29be69306e73/pgtype/int.go#L1188 https://github.com/jackc/pgx/blob/9907b874c223887dba628215feae29be69306e73/pgtype/int.go#L1209-L1213 An int64 can never be less than math.MinInt64 or more than math.MaxInt64, maybe we should delete these code.

jackc commented 5 months ago

🤷

The Int2, Int4, and Int8 code is generated from the same template. The bounds checking is unnecessary in the Int8 case but it is necessary for Int2 and Int4.

I don't think it is worth specializing the template for Int8 to eliminate those calls.