Обсуждение: Will Connection.createBlob be implemented any time soon?

Поиск
Список
Период
Сортировка

Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
$subject
 
It'd be nice to be able to do:
 
                val b = con.createBlob()
                val os = b.setBinaryStream(1)
                IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
 
Is there a work-around for it?
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc

Re: Will Connection.createBlob be implemented any time soon?

От
Thomas Kellerer
Дата:
Andreas Joseph Krogh wrote on 19.01.2014 14:14:
> $subject
> It'd be nice to be able to do:
>                  val b = con.createBlob()
>                  val os = b.setBinaryStream(1)
>                  IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
> Is there a work-around for it?

Using PreparedStatement.setBinaryStream() works without problems.
You don't even need the intermediate Blob instance:

PreparedStatement pstmt = con.createStatement("....");

pstmt.setBinaryStream(1, is);
   or
pstmt.setBinaryStream(1, is, length);  // if the length is known




Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På søndag 19. januar 2014 kl. 14:31:00, skrev Thomas Kellerer <spam_eater@gmx.net>:
Andreas Joseph Krogh wrote on 19.01.2014 14:14:
> $subject
> It'd be nice to be able to do:
>                  val b = con.createBlob()
>                  val os = b.setBinaryStream(1)
>                  IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
> Is there a work-around for it?

Using PreparedStatement.setBinaryStream() works without problems.
You don't even need the intermediate Blob instance:

PreparedStatement pstmt = con.createStatement("....");

pstmt.setBinaryStream(1, is);
   or
pstmt.setBinaryStream(1, is, length);  // if the length is known
 
I'm using JPA and need to be able to set a (new) Blob as a field, like this:
 
                val b = con.createBlob()
                val os = b.setBinaryStream(1)
                IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
                myEntity.setData(b)
 
Where MyEntity has a field "data" which is of type "Blob"
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Thomas Kellerer
Дата:
Andreas Joseph Krogh wrote on 19.01.2014 14:41:
>     Using PreparedStatement.setBinaryStream() works without problems.
>     You don't even need the intermediate Blob instance:
>
>     PreparedStatement pstmt = con.createStatement("....");
>
>     pstmt.setBinaryStream(1, is);
>         or
>     pstmt.setBinaryStream(1, is, length);  // if the length is known
>
> I'm using JPA and need to be able to set a (new) Blob as a field, like this:

Ah! The joys of database obfuscation layers.
Sorry, I can't help you with that.

> val b = con.createBlob()
> val os = b.setBinaryStream(1)
> IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
> myEntity.setData(b)

The above code (val b = ...) does not look like Java. What exactly is that?





Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På søndag 19. januar 2014 kl. 14:58:00, skrev Thomas Kellerer <spam_eater@gmx.net>:
Andreas Joseph Krogh wrote on 19.01.2014 14:41:
>     Using PreparedStatement.setBinaryStream() works without problems.
>     You don't even need the intermediate Blob instance:
>
>     PreparedStatement pstmt = con.createStatement("....");
>
>     pstmt.setBinaryStream(1, is);
>         or
>     pstmt.setBinaryStream(1, is, length);  // if the length is known
>
> I'm using JPA and need to be able to set a (new) Blob as a field, like this:

Ah! The joys of database obfuscation layers.
Sorry, I can't help you with that.

> val b = con.createBlob()
> val os = b.setBinaryStream(1)
> IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
> myEntity.setData(b)

The above code (val b = ...) does not look like Java. What exactly is that?
 
Scala, but for this case it is irrelevant.
 
Is there any reason why Connection.createBlob isn't implemented in the official driver?
The NG-driver (https://github.com/impossibl/pgjdbc-ng) has it and it works quite well. I am, however, experiencing some issues in my app and want to test it with the official driver, but am unable to because it doesn't support createBlob, which my app needs.
 
Is it possible to fund development of it and have it merged into the official driver?
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Tom Dunstan
Дата:
Hi Andreas

On 20 January 2014 00:11, Andreas Joseph Krogh <andreak@officenet.no> wrote:
> I'm using JPA and need to be able to set a (new) Blob as a field, like this:
>
>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)
>                 IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
>                 myEntity.setData(b)
>
> Where MyEntity has a field "data" which is of type "Blob"

I was under the impression that most JPA implementations will allow
you to stick a byte[] as your property type and will handle the rest
under the good (usually using the blob support in PreparedStatement).
Is that an option for you, or do you need the streaming functionality?

Cheers

Tom


Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På tirsdag 28. januar 2014 kl. 02:40:03, skrev Tom Dunstan <pgsql@tomd.cc>:
Hi Andreas

On 20 January 2014 00:11, Andreas Joseph Krogh <andreak@officenet.no> wrote:
> I'm using JPA and need to be able to set a (new) Blob as a field, like this:
>
>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)
>                 IOUtils.copyLarge(is, os, new Array[Byte](1024 * 1024))
>                 myEntity.setData(b)
>
> Where MyEntity has a field "data" which is of type "Blob"

I was under the impression that most JPA implementations will allow
you to stick a byte[] as your property type and will handle the rest
under the good (usually using the blob support in PreparedStatement).
Is that an option for you, or do you need the streaming functionality?
 
I need streaming yes, that's why I use Blobs.
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Florian Weimer
Дата:
On 01/28/2014 02:40 AM, Tom Dunstan wrote:

> I was under the impression that most JPA implementations will allow
> you to stick a byte[] as your property type and will handle the rest
> under the good (usually using the blob support in PreparedStatement).

If I recall correctly, you need to special-case byte[], otherwise it
will be turned into a PostgreSQL array type (probably "int array").

--
Florian Weimer / Red Hat Product Security Team


Re: Will Connection.createBlob be implemented any time soon?

От
Florian Weimer
Дата:
On 01/28/2014 09:09 AM, Andreas Joseph Krogh wrote:

> I need streaming yes, that's why I use Blobs.

The PostgreSQL wire protocol does not support streaming BYTEA parameters
and result data.  Your initial example does not actually use streaming
in an essential way, so I'm not sure what you're trying to achieve.

--
Florian Weimer / Red Hat Product Security Team


Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På tirsdag 28. januar 2014 kl. 10:21:34, skrev Florian Weimer <fweimer@redhat.com>:
On 01/28/2014 09:09 AM, Andreas Joseph Krogh wrote:

> I need streaming yes, that's why I use Blobs.

The PostgreSQL wire protocol does not support streaming BYTEA parameters
and result data.
 
Why do you assume I use BYTEA? I use OID for myu blobs.
 
 
  Your initial example does not actually use streaming
in an essential way, so I'm not sure what you're trying to achieve.
 
Read it again, it does use streaming. It copies the "is" stream out to the "os" stream, backed by the Blob.
Using EclipseLink with the pgjdbc-ng driver it works perfectly using Connection.createBlob, streaming etc. I've tried streaming > 200GB stuff with a Blob field in a JPA-object and it works.
 
What pussles me is why the "official" driver doesn't implement createBlob as I thought it should be a quit common use-case to want to stream large data-chunks in the db (for tx-purposes).
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Dave Cramer
Дата:

On Tue, Jan 28, 2014 at 4:29 AM, Andreas Joseph Krogh <andreak@officenet.no> wrote:
På tirsdag 28. januar 2014 kl. 10:21:34, skrev Florian Weimer <fweimer@redhat.com>:
On 01/28/2014 09:09 AM, Andreas Joseph Krogh wrote:

> I need streaming yes, that's why I use Blobs.

The PostgreSQL wire protocol does not support streaming BYTEA parameters
and result data.
 
Why do you assume I use BYTEA? I use OID for myu blobs.
 
 
  Your initial example does not actually use streaming
in an essential way, so I'm not sure what you're trying to achieve.
 
Read it again, it does use streaming. It copies the "is" stream out to the "os" stream, backed by the Blob.
Using EclipseLink with the pgjdbc-ng driver it works perfectly using Connection.createBlob, streaming etc. I've tried streaming > 200GB stuff with a Blob field in a JPA-object and it works.
 
What pussles me is why the "official" driver doesn't implement createBlob as I thought it should be a quit common use-case to want to stream large data-chunks in the db (for tx-purposes).

Apparently it isn't a common use-case as the driver has never had it. 
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På tirsdag 28. januar 2014 kl. 15:31:20, skrev Dave Cramer <pg@fastcrypt.com>:
 
On Tue, Jan 28, 2014 at 4:29 AM, Andreas Joseph Krogh <andreak@officenet.no> wrote:
På tirsdag 28. januar 2014 kl. 10:21:34, skrev Florian Weimer <fweimer@redhat.com>:
On 01/28/2014 09:09 AM, Andreas Joseph Krogh wrote:

> I need streaming yes, that's why I use Blobs.

The PostgreSQL wire protocol does not support streaming BYTEA parameters
and result data.
 
Why do you assume I use BYTEA? I use OID for myu blobs.
 
 
  Your initial example does not actually use streaming
in an essential way, so I'm not sure what you're trying to achieve.
 
Read it again, it does use streaming. It copies the "is" stream out to the "os" stream, backed by the Blob.
Using EclipseLink with the pgjdbc-ng driver it works perfectly using Connection.createBlob, streaming etc. I've tried streaming > 200GB stuff with a Blob field in a JPA-object and it works.
 
What pussles me is why the "official" driver doesn't implement createBlob as I thought it should be a quit common use-case to want to stream large data-chunks in the db (for tx-purposes).
 
 
Apparently it isn't a common use-case as the driver has never had it. 
 
Apparently not common in pg-land.
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Craig Ringer
Дата:
On 01/19/2014 09:14 PM, Andreas Joseph Krogh wrote:
> $subject
>
> It'd be nice to be able to do:
>
>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)

The usual answer to "when will it be implemented" questions is "when
someone steps forward, does it, and submits a patch".

I haven't seen any prototypes or early attempts at this code. I suggest
taking a look and seeing what's involved in adding it.


--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: Will Connection.createBlob be implemented any time soon?

От
Craig Ringer
Дата:
On 01/28/2014 05:29 PM, Andreas Joseph Krogh wrote:
> Read it again, it does use streaming. It copies the "is" stream out to
> the "os" stream, backed by the Blob.

Sure, but if it's backed by a 'bytea' column the scenes PgJDBC still
reads the whole thing into memory before sending it off (for output), or
reads the whole blob from the PostgreSQL database connection before
exposing it to the client (for input).

PostgreSQL supports streaming for pg_largeobject, i.e. the "lob" type,
but not for bytea. That doesn't mean you can't present a streaming
interface to it, just that you don't get any benefit from doing so.

> Using EclipseLink with the pgjdbc-ng driver it works perfectly using
> Connection.createBlob, streaming etc. I've tried streaming > 200GB stuff
> with a Blob field in a JPA-object and it works.

Is the backing column "lob", or a pg_largeobject directly? This won't
work with bytea, so it must be.

> What pussles me is why the "official" driver doesn't implement
> createBlob as I thought it should be a quit common use-case to want to
> stream large data-chunks in the db (for tx-purposes).

Because nobody's wanted it enough to implement it yet.

There are lots of areas where PgJDBC could be better, but nobody who's
had the time has also had the inclination to do the work required to
make it happen.


--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På onsdag 29. januar 2014 kl. 06:57:25, skrev Craig Ringer <craig@2ndquadrant.com>:
On 01/19/2014 09:14 PM, Andreas Joseph Krogh wrote:
> $subject

> It'd be nice to be able to do:

>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)

The usual answer to "when will it be implemented" questions is "when
someone steps forward, does it, and submits a patch".

I haven't seen any prototypes or early attempts at this code. I suggest
taking a look and seeing what's involved in adding it.
 
I kind of  hoped the answer would be ending with "... or someone willing to fund it" but I recognize that the driver is practically in maintenance-mode and nobody has time for any real development on it.
 
Maybe it's time to re-suggest adding pgjdbc-ng to http://jdbc.postgresql.org so people are aware of the alternative, active developed, driver?
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På onsdag 29. januar 2014 kl. 07:01:24, skrev Craig Ringer <craig@2ndquadrant.com>:
On 01/28/2014 05:29 PM, Andreas Joseph Krogh wrote:
> Read it again, it does use streaming. It copies the "is" stream out to
> the "os" stream, backed by the Blob.

Sure, but if it's backed by a 'bytea' column the scenes PgJDBC still
reads the whole thing into memory before sending it off (for output), or
reads the whole blob from the PostgreSQL database connection before
exposing it to the client (for input).

PostgreSQL supports streaming for pg_largeobject, i.e. the "lob" type,
but not for bytea. That doesn't mean you can't present a streaming
interface to it, just that you don't get any benefit from doing so.

> Using EclipseLink with the pgjdbc-ng driver it works perfectly using
> Connection.createBlob, streaming etc. I've tried streaming > 200GB stuff
> with a Blob field in a JPA-object and it works.

Is the backing column "lob", or a pg_largeobject directly? This won't
work with bytea, so it must be.
 
Yes it's backed by a column-type=IOD
 
> What pussles me is why the "official" driver doesn't implement
> createBlob as I thought it should be a quit common use-case to want to
> stream large data-chunks in the db (for tx-purposes).

Because nobody's wanted it enough to implement it yet.

There are lots of areas where PgJDBC could be better, but nobody who's
had the time has also had the inclination to do the work required to
make it happen.
 
 
This official driver has served users and developers well for many year and all credit to it's developers. That said it clarely isn't being actively developed anymore and suggestions for new features often end up in /dev/null, which I understand completely when nobody works on the driver.
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Dave Cramer
Дата:

On Wed, Jan 29, 2014 at 4:12 AM, Andreas Joseph Krogh <andreak@officenet.no> wrote:
På onsdag 29. januar 2014 kl. 06:57:25, skrev Craig Ringer <craig@2ndquadrant.com>:
On 01/19/2014 09:14 PM, Andreas Joseph Krogh wrote:
> $subject

> It'd be nice to be able to do:

>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)

The usual answer to "when will it be implemented" questions is "when
someone steps forward, does it, and submits a patch".

I haven't seen any prototypes or early attempts at this code. I suggest
taking a look and seeing what's involved in adding it.
 
I kind of  hoped the answer would be ending with "... or someone willing to fund it" but I recognize that the driver is practically in maintenance-mode and nobody has time for any real development on it.
 
Maybe it's time to re-suggest adding pgjdbc-ng to http://jdbc.postgresql.org so people are aware of the alternative, active developed, driver?
 

Possibly, however given the man hours that are being spent on it they would be far better spent on this driver. 
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc
 

Re: Will Connection.createBlob be implemented any time soon?

От
Andreas Joseph Krogh
Дата:
På onsdag 29. januar 2014 kl. 12:45:30, skrev Dave Cramer <pg@fastcrypt.com>:
 
On Wed, Jan 29, 2014 at 4:12 AM, Andreas Joseph Krogh <andreak@officenet.no> wrote:
På onsdag 29. januar 2014 kl. 06:57:25, skrev Craig Ringer <craig@2ndquadrant.com>:
On 01/19/2014 09:14 PM, Andreas Joseph Krogh wrote:
> $subject

> It'd be nice to be able to do:

>                 val b = con.createBlob()
>                 val os = b.setBinaryStream(1)

The usual answer to "when will it be implemented" questions is "when
someone steps forward, does it, and submits a patch".

I haven't seen any prototypes or early attempts at this code. I suggest
taking a look and seeing what's involved in adding it.
 
I kind of  hoped the answer would be ending with "... or someone willing to fund it" but I recognize that the driver is practically in maintenance-mode and nobody has time for any real development on it.
 
Maybe it's time to re-suggest adding pgjdbc-ng to http://jdbc.postgresql.org so people are aware of the alternative, active developed, driver?
 
 
Possibly, however given the man hours that are being spent on it they would be far better spent on this driver.
 
Possibly.
 
--
Andreas Joseph Krogh <andreak@officenet.no>      mob: +47 909 56 963
Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no
Public key: http://home.officenet.no/~andreak/public_key.asc