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

Commit734e421

Browse files
author
Barry Lind
committed
Bugfix for bug reported by Marcus Better (marcus@dactylis.com). When preforming
a get on a bytea value the code was running the raw value from the serverthrough character set conversion, which if the character set was SQL_ASCIIwould cause all 8bit characters to become ?'s.
1 parentf3efaf8 commit734e421

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ else if (connection.haveMinimumCompatibleVersion("7.2"))
404404
//Version 7.2 supports the bytea datatype for byte arrays
405405
if (fields[columnIndex -1].getPGType().equals("bytea"))
406406
{
407-
returnPGbytea.toBytes(getString(columnIndex));
407+
returnPGbytea.toBytes(this_row[columnIndex -1]);
408408
}
409409
else
410410
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ else if (connection.haveMinimumCompatibleVersion("7.2"))
331331
//Version 7.2 supports the bytea datatype for byte arrays
332332
if (fields[columnIndex -1].getPGType().equals("bytea"))
333333
{
334-
returnPGbytea.toBytes(getString(columnIndex));
334+
returnPGbytea.toBytes(this_row[columnIndex -1]);
335335
}
336336
else
337337
{

‎src/interfaces/jdbc/org/postgresql/util/PGbytea.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,48 @@
55
/*
66
* Converts to and from the postgresql bytea datatype used by the backend.
77
*
8-
* $Id: PGbytea.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
8+
* $Id: PGbytea.java,v 1.4 2002/01/05 22:26:23 barry Exp $
99
*/
1010

1111
publicclassPGbytea
1212
{
1313

1414
/*
15-
* Converts a PG byteastring(i.e. thetext representation
15+
* Converts a PG bytearaw value(i.e. theraw binary representation
1616
* of the bytea data type) into a java byte[]
1717
*/
18-
publicstaticbyte[]toBytes(Strings)throwsSQLException
18+
publicstaticbyte[]toBytes(byte[]s)throwsSQLException
1919
{
2020
if (s ==null)
2121
returnnull;
22-
intslength =s.length();
22+
intslength =s.length;
2323
byte[]buf =newbyte[slength];
2424
intbufpos =0;
2525
intthebyte;
26-
charnextchar;
27-
charsecondchar;
26+
bytenextbyte;
27+
bytesecondbyte;
2828
for (inti =0;i <slength;i++)
2929
{
30-
nextchar =s.charAt(i);
31-
if (nextchar =='\\')
30+
nextbyte =s[i];
31+
if (nextbyte ==(byte)'\\')
3232
{
33-
secondchar =s.charAt(++i);
34-
if (secondchar =='\\')
33+
secondbyte =s[++i];
34+
if (secondbyte ==(byte)'\\')
3535
{
3636
//escaped \
3737
buf[bufpos++] = (byte)'\\';
3838
}
3939
else
4040
{
41-
thebyte = (secondchar -48) *64 + (s.charAt(++i) -48) *8 + (s.charAt(++i) -48);
41+
thebyte = (secondbyte -48) *64 + (s[++i] -48) *8 + (s[++i] -48);
4242
if (thebyte >127)
4343
thebyte -=256;
4444
buf[bufpos++] = (byte)thebyte;
4545
}
4646
}
4747
else
4848
{
49-
buf[bufpos++] =(byte)nextchar;
49+
buf[bufpos++] =nextbyte;
5050
}
5151
}
5252
byte[]l_return =newbyte[bufpos];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp