Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit512a3ae

Browse files
author
Barry Lind
committed
fixed change in behavior introduced in bytea / getBytes changes. This patch reverts back unintentional change in behavior to return raw value even when not bytea column
1 parentc41b6b1 commit512a3ae

File tree

2 files changed

+62
-38
lines changed

2 files changed

+62
-38
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,31 +391,43 @@ public byte[] getBytes(int columnIndex) throws SQLException
391391
if (columnIndex <1 ||columnIndex >fields.length)
392392
thrownewPSQLException("postgresql.res.colrange");
393393

394-
//If the data is already binary then just return it
395-
if (binaryCursor)
396-
returnthis_row[columnIndex -1];
397-
398-
if (connection.haveMinimumCompatibleVersion("7.2"))
394+
wasNullFlag = (this_row[columnIndex -1] ==null);
395+
if (!wasNullFlag)
399396
{
397+
if (binaryCursor)
398+
{
399+
//If the data is already binary then just return it
400+
returnthis_row[columnIndex -1];
401+
}
402+
elseif (connection.haveMinimumCompatibleVersion("7.2"))
403+
{
400404
//Version 7.2 supports the bytea datatype for byte arrays
401-
returnPGbytea.toBytes(getString(columnIndex));
402-
}
403-
else
404-
{
405+
if (fields[columnIndex -1].getPGType().equals("bytea"))
406+
{
407+
returnPGbytea.toBytes(getString(columnIndex));
408+
}
409+
else
410+
{
411+
returnthis_row[columnIndex -1];
412+
}
413+
}
414+
else
415+
{
405416
//Version 7.1 and earlier supports LargeObjects for byte arrays
406-
wasNullFlag = (this_row[columnIndex -1] ==null);
407417
// Handle OID's as BLOBS
408-
if (!wasNullFlag)
418+
if (fields[columnIndex -1].getOID() ==26)
409419
{
410-
if (fields[columnIndex -1].getOID() ==26)
411-
{
412-
LargeObjectManagerlom =connection.getLargeObjectAPI();
413-
LargeObjectlob =lom.open(getInt(columnIndex));
414-
bytebuf[] =lob.read(lob.size());
415-
lob.close();
416-
returnbuf;
417-
}
420+
LargeObjectManagerlom =connection.getLargeObjectAPI();
421+
LargeObjectlob =lom.open(getInt(columnIndex));
422+
bytebuf[] =lob.read(lob.size());
423+
lob.close();
424+
returnbuf;
425+
}
426+
else
427+
{
428+
returnthis_row[columnIndex -1];
418429
}
430+
}
419431
}
420432
returnnull;
421433
}

‎src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -318,31 +318,43 @@ public byte[] getBytes(int columnIndex) throws SQLException
318318
if (columnIndex <1 ||columnIndex >fields.length)
319319
thrownewPSQLException("postgresql.res.colrange");
320320

321-
//If the data is already binary then just return it
322-
if (binaryCursor)
323-
returnthis_row[columnIndex -1];
324-
325-
if (connection.haveMinimumCompatibleVersion("7.2"))
321+
wasNullFlag = (this_row[columnIndex -1] ==null);
322+
if (!wasNullFlag)
326323
{
324+
if (binaryCursor)
325+
{
326+
//If the data is already binary then just return it
327+
returnthis_row[columnIndex -1];
328+
}
329+
elseif (connection.haveMinimumCompatibleVersion("7.2"))
330+
{
327331
//Version 7.2 supports the bytea datatype for byte arrays
328-
returnPGbytea.toBytes(getString(columnIndex));
329-
}
330-
else
331-
{
332+
if (fields[columnIndex -1].getPGType().equals("bytea"))
333+
{
334+
returnPGbytea.toBytes(getString(columnIndex));
335+
}
336+
else
337+
{
338+
returnthis_row[columnIndex -1];
339+
}
340+
}
341+
else
342+
{
332343
//Version 7.1 and earlier supports LargeObjects for byte arrays
333-
wasNullFlag = (this_row[columnIndex -1] ==null);
334344
// Handle OID's as BLOBS
335-
if (!wasNullFlag)
345+
if (fields[columnIndex -1].getOID() ==26)
336346
{
337-
if (fields[columnIndex -1].getOID() ==26)
338-
{
339-
LargeObjectManagerlom =connection.getLargeObjectAPI();
340-
LargeObjectlob =lom.open(getInt(columnIndex));
341-
bytebuf[] =lob.read(lob.size());
342-
lob.close();
343-
returnbuf;
344-
}
347+
LargeObjectManagerlom =connection.getLargeObjectAPI();
348+
LargeObjectlob =lom.open(getInt(columnIndex));
349+
bytebuf[] =lob.read(lob.size());
350+
lob.close();
351+
returnbuf;
352+
}
353+
else
354+
{
355+
returnthis_row[columnIndex -1];
345356
}
357+
}
346358
}
347359
returnnull;
348360
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp