sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.51k stars 445 forks source link

Question: binary copy and dynamic types #1190

Open jamessewell opened 1 day ago

jamessewell commented 1 day ago

Very quick question: I want to perform a binary copy based on the types in a table I inspect at run time, is this possible?

sfackler commented 20 hours ago

What do you want to do with the data you are copying?

jamessewell commented 19 hours ago

Sorry, I missed a critical detail this is copy in.

So:

On Fri, 22 Nov 2024 at 6:11 AM, Steven Fackler @.***> wrote:

What do you want to do with the data you are copying?

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-postgres/issues/1190#issuecomment-2491816249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJJDIZB2DDN5JWJD4SADCD2BYH5BAVCNFSM6AAAAABSGO6G3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJRHAYTMMRUHE . You are receiving this because you authored the thread.Message ID: @.***>

jamessewell commented 18 hours ago

actually maybe I think about it the hard bit here probably isn’t rust-postgres it’s parsing input data to typed data without previous knowledge of the types (I’d need to get that from the table types as well)

On Fri, 22 Nov 2024 at 8:09 AM, James Sewell @.***> wrote:

Sorry, I missed a critical detail this is copy in.

So:

  • inspect table
  • get type signatures
  • binary copy data in with those

On Fri, 22 Nov 2024 at 6:11 AM, Steven Fackler @.***> wrote:

What do you want to do with the data you are copying?

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-postgres/issues/1190#issuecomment-2491816249, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJJDIZB2DDN5JWJD4SADCD2BYH5BAVCNFSM6AAAAABSGO6G3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJRHAYTMMRUHE . You are receiving this because you authored the thread.Message ID: @.***>

sfackler commented 14 hours ago

You may be better off using one of the textual copy formats to avoid having to do that conversion.

jamessewell commented 13 hours ago

That's potentially true - I'm looking to see if it's possible though :)

On Fri, Nov 22, 2024 at 12:50 PM Steven Fackler @.***> wrote:

You may be better off using one of the textual copy formats to avoid having to do that conversion.

— Reply to this email directly, view it on GitHub https://github.com/sfackler/rust-postgres/issues/1190#issuecomment-2492584656, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJJDI2B7PGECG65LIB57LT2BZWVLAVCNFSM6AAAAABSGO6G3CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJSGU4DINRVGY . You are receiving this because you authored the thread.Message ID: @.***>

sfackler commented 13 hours ago

If you can transform your data into the Postgres binary copy format it's possible. I don't know enough about your workflow to tell you whether or not that's possible.