-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Alex,

On 8/28/18 11:00, Alex O'Ree wrote:
>> From what i understand, the postgres jdbc driver does support
> reading/writing from a result set or command via a input or output
> stream, however from my testing, it looks like it just buffers the
> whole thing in memory.

Yikes. I guess that's what their LargeObject API is intended to avoid.
It's frustrating that they don't provide the same facility through the
standard API. It doesn't seem like it would be that hard to do.

> I actually had one case where i was able to insert 1.2GB of
> content into a bytea column, but could not retrieve it. Something
> about invalid allocation size. Postgres's limit is 1GB and they
> want you to use the large object api. I think it stores it the file
> outside of the normal database table file.

It does. I did a little reading about it this morning because I was
interested. Evidently, those large-objects are stored in a way that
provides absolutely zero authorization-checks against authenticated
users. So if you can log in to the database, you can read all those
files. So if this is a shared database or if you don't 100% trust
every db-user, you might want to think about adding encryption to
those files.

It's unclear to me if they can be modified by other users as well. If
they can be modified but aren't otherwise sensitive, you might want to
add some kind of binary signature to the host table to ensure that the
data hasn't been tampered-with when you weren't looking.

- -chris

> On Tue, Aug 28, 2018 at 10:18 AM Christopher Schultz < 
> ch...@christopherschultz.net> wrote:
> 
> Torsten,
> 
> On 8/28/18 09:27, Torsten Krah wrote:
>>>> Am Dienstag, den 28.08.2018, 09:21 -0400 schrieb Christopher 
>>>> Schultz:
>>>>> Interesting. I wonder why Postgres decided not to support
>>>>> that through the standard JDBC API.
>>>>> 
>>>>> Have you tried setting the "compatible" flag on the
>>>>> connection just to see if it works for you?
>>>> 
>>>> I am curious - afaik the standard JDBC API does not support
>>>> e.g. to use seek() or truncate() on the BLOB to fast forward
>>>> to some position in the file - how would you do that with the
>>>> standard API Christopher - maybe i've missed that feature?
>>>> 
>>>> The LargeObject API does support this.
> 
> I've never tried doing random-access reads into BLOBs in a
> database before... that seems like an architectural mistake to me.
> 
> But if I had to, I'd try to:
> 
> ResultSet rs = ...; Blob blob = rs.getBlob("bigfield");
> 
> // Take a chunk out of the middle byte[] chunk =
> blob.getBytes(start, length); // or InputStream readFromMiddle =
> blob.getBinaryStream(strart, length);
> 
> // Truncate the blob blob.truncate(newEndPos);
> 
> The Blob API isn't really that extensive... I'm not sure how you
> could have missed those methods in there. It's really all there
> is.
> 
> Now... if Postgres artificially places a 1GiB limit on everything
> that goes through that API, well, then you are kind of screwed.
> 
> -chris
>> 
>> ---------------------------------------------------------------------
>>
>> 
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: users-h...@tomcat.apache.org
>> 
>> 
> 
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/

iQIzBAEBCAAdFiEEMmKgYcQvxMe7tcJcHPApP6U8pFgFAluFbBYACgkQHPApP6U8
pFjr7BAApOj8ow7LxZqqbEhMi6FcYTLQ9kTfXyGyhLPSifKktcSJzZ4dWI4tflZO
zgg6Dhe2eomsXErQ2gVOIVXQmJKRPhO0nnaG5IDkZzSZZNZsQHPrBsObZCpUyf04
rnadkfkt+L4FJ1n5/fdJ+SbY5DNjDaKCJ090j7h3BErbMSz+GAIo1gq6aRHu4Nn/
9vQoT19K3s67DWkvZLPMo+UjprCKBmajYUfqJ2370q4wMEaz8+tg8e63h+FuFnFi
gQiPYE06yfNP+h3IVJcu7aosCfEAgbdjdRaRfrAb2/1NEcUfinuFBp1mQT3ltPje
FYkfz74+JCTWUowX5JLnQWyx3xXzVWWqXNzKUE6IHke2Kaa+x30bIjQNXwH9Sw4u
nAmZm7SfybOZw3UmRbNXPGjSkYYlKe6GUQIEcGvskprsP6r4jqEYNWaVtgBIP7vt
nSvlxIhiBOXChCs0fgGQMXPH01nKEHbg/AKn41lnf9kP842vJ3LPknXJHgDur9PM
MMF9qxtC/BjR99juT7fwL4nBOt5w3WXsLYLvsEtJR2w3JKAZdnll/e6uUGOf+zmQ
GZs6Ra23j3J12S0E9/a8j4GuZP7dhBFmimuxSgxKIEccxxmkgHd+Wbh1d+oTiDEB
QLrAfxD4406Z1SDro/AVq+b2KigjMgj+hWQsrAcJdLZP4OYV36c=
=Y+CN
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to