Re: BLOB / CLOB support in PostgreSQL

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: BLOB / CLOB support in PostgreSQL
Date: 2020-09-28 20:44:21
Message-ID: CAB=Je-GZ9Bqp-JO=v7-YyZdaWub9RH4po6x3rM606WO-kD2uqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-jdbc

Andrew>To the best of my knowledge there is no concrete proposal for the
type
Andrew>of data type / interface you suggest.

To the best of my knowledge, one of the concrete proposals was in the very
first message.

Let me please copy it:

Vladimir> **Here goes the question**: do you think such an implementation
Vladimir> ("large string stored in Large Objects" could be merged into the
core eventually)?

---

Andrew>In the first place, what
Andrew>I have proposed is an optional behaviour

Adding optional behaviors makes support complicated, so flags should be
avoided when
a standard solution is possible.

Even if you name the behavior "optional", people would still rely on it.
For instance, you implement Clob.truncate(int) as in-driver-memory truncate
operation, however,
in practice, that API should truncate the value in the database.

Just in case: the current behavior for LO-based lobs is that
Blob.truncate(int) immediately truncates LO.
So if the application works with the current LO mode, then they would get a
behavior change if they flip the switch.

The same for setString and other modifications.

An escape hatch could be like "ok, let's throw unimplemented for clob
modifications", however, it contradicts the spec
which says:

JDBC Spec> * All methods on the <code>Clob</code> interface must be fully
implemented if the
JDBC Spec> * JDBC driver supports the data type.

What I say here is that the behavior you suggest spans far away from just
"blob maps to bytea".

----

Andrew>Furthermore, it's
Andrew>consistent with how the MySQL driver behaves, AIUI,
Andrew>and possibly others as well

Oracle DB behaves differently. They have BLOB/CLOB column types, and
Clob/Blob interfaces
map to CLOB/BLOB.

Andrew>That consistency is a major motivator for the work I've done.

PostgreSQL supports large binary via LargeObject API, so the driver maps
Blob to LO.

If people want to use bytea, they can use `setBinaryStream(...)`.
What does drive people to use Clob/Blob when the database lacks APIs for it?

Vladimir

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2020-09-28 21:12:05 Re: BLOB / CLOB support in PostgreSQL
Previous Message John Naylor 2020-09-28 20:42:39 Re: WIP: BRIN multi-range indexes

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andrew Dunstan 2020-09-28 21:12:05 Re: BLOB / CLOB support in PostgreSQL
Previous Message Andrew Dunstan 2020-09-28 18:12:50 Re: BLOB / CLOB support in PostgreSQL