Cann't save uint64 , error: "value is greater than maximum value for Int4"
Hi, I want to save the value of a uint64 variable in a table, the target column type is "BIGINT", but I get the error "868957043361742 is greater than maximum value for Int4" I have no error when I save this value directly in the table. I used pgxpool.Pool to connect to the database
Only reason that should happen is if the driver thinks the column is an int4. Maybe double check the underlying type. Maybe try with a test table with bigint to confirm.
In my case it was #1248
Same problem:
SELECT NULL
FROM hgv.companies
WHERE id = $1
$1 is 2551565154
failed to encode args[0]: unable to encode 2551565154 into binary format for int4 (OID 23): 2551565154 is greater than maximum value for int4
column type is bigint, actually the following works:
SELECT NULL
FROM hgv.companies
WHERE id = $1::bigint
@emaborsa What type is hgv.companies.id? cc @jackc
@emaborsa What type is hgv.companies.id? cc @jackc
it is bigint
Can you produce a standalone case that reproduces this?
Yes, need some time...
Sorry, I was wrong, hgv.company.id is int, not bigint. However, I am wondering why it works if I cast the parameter to bigint.
pgx sends the SQL text to the PostgreSQL server to make a prepared statement. PostgreSQL responds with the data type of the parameters. When all you have is id = $1 PostgreSQL infers that $1 is the same type as id. But when you have $1::bigint you are telling it the type of $1 is bigint.
Has this issue been resolved?