Closed felixge closed 6 years ago
I don't see anything in that commit that indicates it was changed purposely. However, I believe that the current behavior of returning an int64
is correct. The relevant interface that pgx implements for compatibility with database/sql is database/sql/driver.Rows The Next(dest []Value) error
function populates the slice of driver.Value
.
driver.Value
is a interface{}
so we can put anything we want there, but the documentation states that it must only hold values from a short list of types. int64
is on that list and int32
is not.
The previous behavior may have happened to work, but it was not conforming the required interface.
@jackc makes sense. Thanks for clarifying.
In the process of upgrading telegraf to use the latest version of pgx from b84338d7d62598f75859b2b146d830b22f1b9ec8 to 63f58fd32edb5684b9e9f4cfaac847c6b42b3917 I noticed that some of their regression tests started to fail. E.g.:
Digging deeper, I was able to produce this demonstration which fails for 63f58fd32edb5684b9e9f4cfaac847c6b42b3917 but passes for b84338d7d62598f75859b2b146d830b22f1b9ec8:
Since Postgres integers are using a storage size of 4 bytes I feel like the old behavior of using a Go int32 in b84338d7d62598f75859b2b146d830b22f1b9ec8 is more appropriate. However, since using an int64 to store an int32 isn't technically wrong, I'm wondering if the current behavior is intentional. If it's intentional, I'll try to adjust the CrateDB test cases. Otherwise I can try to send a patch for pgx that restores the old behavior.
I also tried to identify the first commit that caused the change in behavior using the following command:
According to bisect 19c668975218ca857f07e0506cdbcaa83f68fb24 is the first commit where the behavior changed.