pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBug in setClob() ?
3+ messages / 2 participants
[nested] [flat]
* Bug in setClob() ?
@ 2014-09-11 17:06 Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
0 siblings, 2 replies; 3+ messages in thread
From: Giuseppe Sacco @ 2014-09-11 17:06 UTC (permalink / raw)
To: pgsql-jdbc
Hello all,
I found a problem in org/postgresql/jdbc2/AbstractJdbc2Statement on the
setClob(int i, Clob x) method.
I created a clob implementation in my application and then passed it to
postgresql via this method, but the correct value is not stored in the
database.
What happen is that this jdbc implementation read all data from my clob
using two methods, getAsciiStream() and length(), this way:
InputStream l_inStream = x.getAsciiStream();
int l_length = (int) x.length();
LargeObjectManager lom = connection.getLargeObjectAPI();
long oid = lom.createLO();
LargeObject lob = lom.open(oid);
OutputStream los = lob.getOutputStream();
try
{
int c = l_inStream.read();
int p = 0;
while (c > -1 && p < l_length)
{
los.write(c);
c = l_inStream.read();
p++;
}
los.close();
[...]
So, it does read from an ASCII stream using a counter based on the
number of characters present in the clob.
My clob does not contain ASCII characters, but multibyte ones. So, I
think I should probably fail on getAsciiStream(), but this driver does
not use any other way to get the data.
I tried to implement getAsciiStream() as:
return new ByteArrayInputStream( data.getBytes() );
but of course the byte array size is in bytes, so if you only read
length() bytes, you will not store the complete string.
Now, I think the problem is clear, but I don't know what is the best way
to fix it. Let see a couple of proposal for changing the setClob
implementation in this driver:
1. remove the usage of lenth() and just loop until the l_inStream.read()
fail.
2. use getCharacterStream(), when available, with precedence on
getAsciiStream()
what do you suggest? Will the "los" object accept non ASCII data?
Thanks,
Giuseppe
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bug in setClob() ?
@ 2014-09-12 08:28 Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
parent: Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
1 sibling, 0 replies; 3+ messages in thread
From: Giuseppe Sacco @ 2014-09-12 08:28 UTC (permalink / raw)
To: pgsql-jdbc
Hello,
I just found that the problem I reported has already been solved (since
a few months) in the GIT version.
Do you have any idea about when the next official build will be published?
Thank you,
Giuseppe Sacco
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bug in setClob() ?
@ 2014-10-29 06:20 Craig Ringer <craig@2ndquadrant.com>
parent: Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
1 sibling, 0 replies; 3+ messages in thread
From: Craig Ringer @ 2014-10-29 06:20 UTC (permalink / raw)
To: Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>; pgsql-jdbc
On 09/12/2014 04:28 PM, Giuseppe Sacco wrote:
> Do you have any idea about when the next official build will be published?
Probably some time after the final release of PostgreSQL 9.4.
It's mostly a matter of when there's time to do it and the urgency of
queued up fixes.
It's simple to compile the current git head for the driver in the mean time.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2014-10-29 06:20 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-09-11 17:06 Bug in setClob() ? Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
2014-09-12 08:28 ` Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
2014-10-29 06:20 ` Craig Ringer <craig@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox