NpgsqlBinaryImporter fails with incorrect binary data format
See original GitHub issueI’m trying to do a binary copy from Windows to postgres on ubuntu. After writing several rows of data, the command is closed and an exception is thrown. This is the relevant Npgsql stack trace:
Npgsql.NpgsqlException (0x80004005): 22P03: incorrect binary data format
at Npgsql.NpgsqlConnector.DoReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage, Boolean isPrependedMessage)
at Npgsql.NpgsqlConnector.ReadSingleMessage(DataRowLoadingMode dataRowLoadingMode, Boolean returnNullForAsyncMessage)
at Npgsql.NpgsqlConnector.ReadExpecting[T]()
at Npgsql.NpgsqlBinaryImporter.Close()
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
psycopg2: inexplicable 'DataError: incorrect binary data ...
I'm using a COPY ... WITH BINARY query. The tables I'm copying, only contain integers and only go into tables containing integers.
Read more >ERROR: "incorrect binary data format in bind parameter" while ...
This issue occurs while fetching RAW data from Oracle and inserting data into the Postgre data type bit. The session runs without any...
Read more >ERROR: incorrect binary data format in bind parameter 2
machine works. Are you using x86_64 binary? If so, can you please try this suggestion? - What is "indexer -S" output?
Read more >inserting into "date" field returns error (COPY/BINARY)
WITH BINARY command. All field types are working as expected in PG9.2, except "date": ERROR: incorrect binary data format
Read more >Prisma Postgres $queryRaw butchering numeric types
Running on node 16.11.1 on Ubuntu/WSL. const [{ id }] = await db.$queryRaw`select ${1.5}::int id` // Raw query failed.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Postgresql docs says
That is likely your case. Your postgresql log should give you more information on which column is the culprit.
Had this issue today. My problem was that I passed a
System.DateTimevalue to theNpgsqlBinaryImporter.Write()method for a date column, which then was sent to postgres as a 8 byte value, but postgres requires 4 byte values for date columns. It worked after I explicitly passed NpgsqlDbType as the second argumentbinImporter.Write(value, NpgsqlDbType.Date);@mkedo thanks for the example, I wasn’t aware that PostgreSQL implicitly converts byte array input into geometry in this way.