Loading binary data into the database
Loading binary data into the database
От:
Adriaan Joubert <a.joubert@albourne.com>
Дата:
Hi, I'm having serious problems trying to load large amounts of data into the database. I have this data in binary, database compatible, form, but there seems no way left to upload this data except to turn it all back into strings (since 7.0.2 binary copy has been disabled, making quite a few libpq functions superfluous). This is quite a serious deficiency in my view. So, I want to know what my options are. For this type of thing I would have thought that Karel's stored queries would be useful, combined with some way of uploading binary data to the database. Something along the lines of prepare insert into my_table (col1, col2) values (?,?); execute 3, 4; To upload binary data there would have to be a libpq call that uploads the data in the execute statement as binary (there is a specification for this already in the current libpq), and executes the prepared plan. For any application that generates a lot of data (especially floating point data), this would be a huge win. An added advantage would be that this type of schema would allow a serial value on the table to be incremented as in any normal insert, which has always been annoying when using copy. I have no idea how hard this is and whether I'm the only person in the world that will find this useful. I seem to be the only one who moaned about the binary copy vanishing, and breaking code, so perhaps nobody else sees this as a problem? Adriaan
Re: Loading binary data into the database
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Adriaan Joubert writes: > since 7.0.2 binary copy has been disabled, making > quite a few libpq functions superfluous Such as? IIRC, the reason we disabled it was precisely that there was no support on the client side. (What's worse, there's no support in the FE/BE protocol either. I don't see how you could have made this work...) Cross-machine binary copy is a dangerous thing anyway, since it opens you up to all sorts of compatibility problems. If your app is running on the same machine as the server, you can write data to a file and then send a command to do a binary copy from that file. regards, tom lane
Re: Loading binary data into the database
От:
Adriaan Joubert <a.joubert@albourne.com>
Дата:
Tom Lane wrote: > Adriaan Joubert writes: > > since 7.0.2 binary copy has been disabled, making > > quite a few libpq functions superfluous > > Such as? IIRC, the reason we disabled it was precisely that there was > no support on the client side. (What's worse, there's no support in > the FE/BE protocol either. I don't see how you could have made this > work...) I issued a 'copy binary
Re: Loading binary data into the database
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Adriaan Joubert writes: >> Such as? IIRC, the reason we disabled it was precisely that there was >> no support on the client side. (What's worse, there's no support in >> the FE/BE protocol either. I don't see how you could have made this >> work...) > I issued a 'copy binary
Re: Loading binary data into the database
От:
Adriaan Joubert <a.joubert@albourne.com>
Дата:
Tom Lane wrote: > Adriaan Joubert writes: > >> Such as? IIRC, the reason we disabled it was precisely that there was > >> no support on the client side. (What's worse, there's no support in > >> the FE/BE protocol either. I don't see how you could have made this > >> work...) > > > I issued a 'copy binary
Re: Loading binary data into the database
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> Adriaan Joubert writes: > > since 7.0.2 binary copy has been disabled, making > > quite a few libpq functions superfluous > > Such as? IIRC, the reason we disabled it was precisely that there was > no support on the client side. (What's worse, there's no support in > the FE/BE protocol either. I don't see how you could have made this > work...) > > Cross-machine binary copy is a dangerous thing anyway, since it opens > you up to all sorts of compatibility problems. If your app is running > on the same machine as the server, you can write data to a file and > then send a command to do a binary copy from that file. We disabled binary copy? Using \copy or COPY? -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: Loading binary data into the database
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: > We disabled binary copy? Using \copy or COPY? COPY BINARY to stdout or from stdin is disallowed now. It never really worked anyway. AFAIK, psql's \copy has never had a binary option. regards, tom lane