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

Commit06b2979

Browse files
author
Barry Lind
committed
Applied patch from Teofilis Martisius to improve performance.
Also removed some unused files and fixed the which needed a small changeafter the previous patch to build.xml. Modified Files: jdbc/Makefile jdbc/org/postgresql/core/Encoding.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java Removed Files: jdbc/utils/CheckVersion.java jdbc/utils/buildDriver jdbc/utils/changelog.pl
1 parente9f07b1 commit06b2979

File tree

6 files changed

+55
-150
lines changed

6 files changed

+55
-150
lines changed

‎src/interfaces/jdbc/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 2001, PostgreSQL Global Development Group
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.35 2002/07/23 03:59:54 barry Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.36 2002/10/20 02:55:50 barry Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -29,7 +29,7 @@ install: installdirs
2929
-Dinstall.directory=$(javadir)$(properties)
3030

3131
installdirs:
32-
$(mkinstalldirs)$(javadir)
32+
$(mkinstalldirs)$(javadir)
3333

3434
uninstall:
3535
$(ANT) -buildfile$(srcdir)/build.xml uninstall\
@@ -39,4 +39,4 @@ clean distclean maintainer-clean:
3939
$(ANT) -buildfile$(srcdir)/build.xml clean
4040

4141
check: all
42-
$(ANT) -buildfile$(srcdir)/build.xmltest
42+
$(ANT) -buildfile$(srcdir)/build.xmltest$(properties)

‎src/interfaces/jdbc/org/postgresql/core/Encoding.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/*
99
* Converts to and from the character encoding used by the backend.
1010
*
11-
* $Id: Encoding.java,v 1.6 2002/09/06 21:23:05 momjian Exp $
11+
* $Id: Encoding.java,v 1.7 2002/10/20 02:55:50 barry Exp $
1212
*/
1313

1414
publicclassEncoding
@@ -161,6 +161,9 @@ public String decode(byte[] encodedString, int offset, int length) throws SQLExc
161161
}
162162
else
163163
{
164+
if (encoding.equals("UTF-8")) {
165+
returndecodeUTF8(encodedString,offset,length);
166+
}
164167
returnnewString(encodedString,offset,length,encoding);
165168
}
166169
}
@@ -223,4 +226,44 @@ private static boolean isAvailable(String encodingName)
223226
returnfalse;
224227
}
225228
}
229+
230+
/**
231+
* custom byte[] -> String conversion routine, 3x-10x faster than
232+
* standard new String(byte[])
233+
*/
234+
privatestaticfinalintpow2_6 =64;// 26
235+
privatestaticfinalintpow2_12 =4096;// 212
236+
privatestaticchar[]cdata =newchar[50];
237+
238+
privatesynchronizedStringdecodeUTF8(bytedata[],intoffset,intlength) {
239+
char[]l_cdata =cdata;
240+
if (l_cdata.length < (length-offset)) {
241+
l_cdata =newchar[length-offset];
242+
}
243+
inti =offset;
244+
intj =0;
245+
intz,y,x,val;
246+
while (i <length) {
247+
z =data[i] &0xFF;
248+
if (z <0x80) {
249+
l_cdata[j++] = (char)data[i];
250+
i++;
251+
}elseif (z >=0xE0) {// length == 3
252+
y =data[i+1] &0xFF;
253+
x =data[i+2] &0xFF;
254+
val = (z-0xE0)*pow2_12 + (y-0x80)*pow2_6 + (x-0x80);
255+
l_cdata[j++] = (char)val;
256+
i+=3;
257+
}else {// length == 2 (maybe add checking for length > 3, throw exception if it is
258+
y =data[i+1] &0xFF;
259+
val = (z -0xC0)* (pow2_6)+(y-0x80);
260+
l_cdata[j++] = (char)val;
261+
i+=2;
262+
}
263+
}
264+
265+
Strings =newString(l_cdata,0,j);
266+
returns;
267+
}
268+
226269
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
importorg.postgresql.util.*;
1515

1616

17-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.11 2002/10/17 05:33:52 barry Exp $
17+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.12 2002/10/20 02:55:50 barry Exp $
1818
* This class defines methods of the jdbc1 specification. This class is
1919
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
2020
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -367,10 +367,16 @@ public void openConnection(String host, int port, Properties info, String databa
367367
//jdbc by default assumes autocommit is on until setAutoCommit(false)
368368
//is called. Therefore we need to ensure a new connection is
369369
//initialized to autocommit on.
370+
//We also set the client encoding so that the driver only needs
371+
//to deal with utf8. We can only do this in 7.3 because multibyte
372+
//support is now always included
370373
if (haveMinimumServerVersion("7.3"))
371374
{
372375
java.sql.ResultSetacRset =
373-
ExecSQL("show autocommit");
376+
ExecSQL("set client_encoding = 'UNICODE'; show autocommit");
377+
378+
//set encoding to be unicode
379+
encoding =Encoding.getEncoding("UNICODE",null);
374380

375381
if (!acRset.next())
376382
{

‎src/interfaces/jdbc/utils/CheckVersion.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

‎src/interfaces/jdbc/utils/buildDriver

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎src/interfaces/jdbc/utils/changelog.pl

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp