Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing 80K bytea columns #1166

Closed
jdabbs003 opened this issue Nov 10, 2016 · 5 comments
Closed

Writing 80K bytea columns #1166

jdabbs003 opened this issue Nov 10, 2016 · 5 comments

Comments

@jdabbs003
Copy link

I'm trying to insert a row with a bytea column, using a Uint8Array variable.

pool.queryPool ( "INSERT INTO DeviceOS (elf_file) VALUES($1::bytea)", [elf_file], function(err, result) {...});

elf_file is a Uint8Array

The operation fails. In the callback:
err.code ends up being '22001'
err.message ends up being 'value too long for type character varying(1024)'

Is this a bug or operator error? Is Uint8Array not a valid type for a bytea field?

@jdabbs003
Copy link
Author

Actually, elf_filecan be a Uint8Array or a Buffer. Same result. In this case, it's about 80,000 bytes long.

@jdabbs003 jdabbs003 changed the title Writing bytea columns Writing 80K bytea columns Nov 11, 2016
@rpedela
Copy link
Contributor

rpedela commented Nov 12, 2016

What is your table's schema?

@jdabbs003
Copy link
Author

elf_file is a bytea column, Not Null with extended storage. The other fields are an integer, a bigint, and a character varying 32.

@rpedela
Copy link
Contributor

rpedela commented Nov 14, 2016

Can you provide a simple but complete example? Can you provide the full psql output for \d DeviceOS?

@charmander
Copy link
Collaborator

byteas need to be passed as Buffers (currently). Uint8Arrays will be converted to strings (JSON-encoded, specifically) and give unexpected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants