File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed
src/interfaces/jdbc/org/postgresql Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -404,7 +404,7 @@ else if (connection.haveMinimumCompatibleVersion("7.2"))
404
404
//Version 7.2 supports the bytea datatype for byte arrays
405
405
if (fields [columnIndex - 1 ].getPGType ().equals ("bytea" ))
406
406
{
407
- return PGbytea .toBytes (getString ( columnIndex ) );
407
+ return PGbytea .toBytes (this_row [ columnIndex - 1 ] );
408
408
}
409
409
else
410
410
{
Original file line number Diff line number Diff line change @@ -331,7 +331,7 @@ else if (connection.haveMinimumCompatibleVersion("7.2"))
331
331
//Version 7.2 supports the bytea datatype for byte arrays
332
332
if (fields [columnIndex - 1 ].getPGType ().equals ("bytea" ))
333
333
{
334
- return PGbytea .toBytes (getString ( columnIndex ) );
334
+ return PGbytea .toBytes (this_row [ columnIndex - 1 ] );
335
335
}
336
336
else
337
337
{
Original file line number Diff line number Diff line change 5
5
/*
6
6
* Converts to and from the postgresql bytea datatype used by the backend.
7
7
*
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 $
9
9
*/
10
10
11
11
public class PGbytea
12
12
{
13
13
14
14
/*
15
- * Converts a PG bytea string (i.e. the text representation
15
+ * Converts a PG bytea raw value (i.e. the raw binary representation
16
16
* of the bytea data type) into a java byte[]
17
17
*/
18
- public static byte [] toBytes (String s ) throws SQLException
18
+ public static byte [] toBytes (byte [] s ) throws SQLException
19
19
{
20
20
if (s == null )
21
21
return null ;
22
- int slength = s .length () ;
22
+ int slength = s .length ;
23
23
byte [] buf = new byte [slength ];
24
24
int bufpos = 0 ;
25
25
int thebyte ;
26
- char nextchar ;
27
- char secondchar ;
26
+ byte nextbyte ;
27
+ byte secondbyte ;
28
28
for (int i = 0 ; i < slength ; i ++)
29
29
{
30
- nextchar = s . charAt ( i ) ;
31
- if (nextchar == '\\' )
30
+ nextbyte = s [ i ] ;
31
+ if (nextbyte == ( byte ) '\\' )
32
32
{
33
- secondchar = s . charAt ( ++i ) ;
34
- if (secondchar == '\\' )
33
+ secondbyte = s [ ++i ] ;
34
+ if (secondbyte == ( byte ) '\\' )
35
35
{
36
36
//escaped \
37
37
buf [bufpos ++] = (byte )'\\' ;
38
38
}
39
39
else
40
40
{
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 );
42
42
if (thebyte > 127 )
43
43
thebyte -= 256 ;
44
44
buf [bufpos ++] = (byte )thebyte ;
45
45
}
46
46
}
47
47
else
48
48
{
49
- buf [bufpos ++] = ( byte ) nextchar ;
49
+ buf [bufpos ++] = nextbyte ;
50
50
}
51
51
}
52
52
byte [] l_return = new byte [bufpos ];
You can’t perform that action at this time.
0 commit comments