Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces jdbc

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Updated high-unicode patch

The attached patch is an updated and bugfixed version of my earlier
patch to support UTF-8 encoding of unicode codepoints above U+FFFF
(previous version:
http://archives.postgresql.org/pgsql.../msg00213.php). The
only structural change from the previous patch is that the UTF8-specific
code is now in a subclass of Encoding that overrides decode(), rather
than having the logic in the main Encoding class.

I'd like to apply this as the current 8.1 server code now handles (and
might generate) these values. If there are no objections I'll apply to
CVS HEAD in a couple of days.

-O

? build.local.properties
? org/postgresql/core/UTF8Encoding.java
Index: org/postgresql/core/Encoding.java
================================================== =================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/core/Encoding.java,v
retrieving revision 1.20
diff -c -r1.20 Encoding.java
*** org/postgresql/core/Encoding.java 11 Jan 2005 08:25:43 -0000 1.20
--- org/postgresql/core/Encoding.java 29 Jun 2005 14:04:37 -0000
***************
*** 23,29 ****
*/
public class Encoding
{
-
private static final Encoding DEFAULT_ENCODING = new Encoding(null);

/*
--- 23,28 ----
***************
*** 36,41 ****
--- 35,41 ----
// encodings found in backend/util/mb/encnames.c
encodings.put("SQL_ASCII", new String[] { "ASCII", "us-ascii" });
encodings.put("UNICODE", new String[] { "UTF-8", "UTF8" });
+ encodings.put("UTF8", new String[] { "UTF-8", "UTF8" }); // 8.1's canonical name for UNICODE changed.
encodings.put("LATIN1", new String[] { "ISO8859_1" });
encodings.put("LATIN2", new String[] { "ISO8859_2" });
encodings.put("LATIN3", new String[] { "ISO8859_3" });
***************
*** 75,86 ****
}

private final String encoding;
- private final boolean utf8;

! private Encoding(String encoding)
{
this.encoding = encoding;
- this.utf8 = (encoding != null && (encoding.equals("UTF-8") || encoding.equals("UTF8")));
}

/**
--- 75,84 ----
}

private final String encoding;

! protected Encoding(String encoding)
{
this.encoding = encoding;
}

/**
***************
*** 93,99 ****
*/
public static Encoding getJVMEncoding(String jvmEncoding) {
if (isAvailable(jvmEncoding))
! return new Encoding(jvmEncoding);
else
return defaultEncoding();
}
--- 91,102 ----
*/
public static Encoding getJVMEncoding(String jvmEncoding) {
if (isAvailable(jvmEncoding))
! {
! if (jvmEncoding.equals("UTF-8") || jvmEncoding.equals("UTF8"))
! return new UTF8Encoding(jvmEncoding);
! else
! return new Encoding(jvmEncoding);
! }
else
return defaultEncoding();
}
***************
*** 175,183 ****
if (encoding == null)
return new String(encodedString, offset, length);

- if (utf8)
- return decodeUTF8(encodedString, offset, length);
-
return new String(encodedString, offset, length, encoding);
}

--- 178,183 ----
***************
*** 251,316 ****
}
}

- private char[] decoderArray = new char[1024];
-
- /**
- * Custom byte[] -> String conversion routine for UTF-8 only.
- * This is about 30% faster than using the String(byte[],int,int,String)
- * ctor, at least under JDK 1.4.2.
- *
- * @param data the array containing UTF8-encoded data
- * @param offset the offset of the first byte in <code>data</code> to decode from
- * @param length the number of bytes to decode
- * @return a decoded string
- * @throws IOException if something goes wrong
- */
- private synchronized String decodeUTF8(byte[] data, int offset, int length)
- throws IOException {
- char[] cdata = decoderArray;
- if (cdata.length < length)
- cdata = decoderArray = new char[length];
-
- int in = offset;
- int out = 0;
- int end = length + offset;
-
- try
- {
- while (in < end)
- {
- int ch = data[in++] & 0xff;
- if (ch < 0x80)
- {
- // Length 1: \u00000 .. \u0007f
- }
- else if (ch < 0xe0)
- {
- // Length 2: \u00080 .. \u007ff
- ch = ((ch & 0x1f) << 6);
- ch = ch | (data[in++] & 0x3f);
- }
- else
- {
- // Length 3: \u00800 .. \u0ffff
- ch = ((ch & 0x0f) << 12);
- ch = ch | ((data[in++] & 0x3f) << 6);
- ch = ch | (data[in++] & 0x3f);
- }
- cdata[out++] = (char)ch;
- }
- }
- catch (ArrayIndexOutOfBoundsException a)
- {
- throw new IOException("UTF-8 string representation was truncated");
- }
-
- // Check if we ran past the end without seeing an exception.
- if (in > end)
- throw new IOException("UTF-8 string representation was truncated");
-
- return new String(cdata, 0, out);
- }
-
public String toString() {
return (encoding == null ? "<default JVM encoding>" : encoding);
}
--- 251,256 ----
Index: org/postgresql/test/jdbc2/DatabaseEncodingTest.java
================================================== =================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/test/jdbc2/DatabaseEncodingTest.java,v
retrieving revision 1.5
diff -c -r1.5 DatabaseEncodingTest.java
*** org/postgresql/test/jdbc2/DatabaseEncodingTest.java 11 Jan 2005 08:25:48 -0000 1.5
--- org/postgresql/test/jdbc2/DatabaseEncodingTest.java 29 Jun 2005 14:04:37 -0000
***************
*** 12,21 ****
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;

/*
! * Test case for Dario's encoding problems.
! * Ensure the driver's own utf-8 decode method works.
*/
public class DatabaseEncodingTest extends TestCase
{
--- 12,28 ----
import org.postgresql.test.TestUtil;
import junit.framework.TestCase;
import java.sql.*;
+ import org.postgresql.core.Encoding;
+ import org.postgresql.PGConnection;
+ import java.io.IOException;
+ import java.util.Arrays;

/*
! * Test case for various encoding problems.
! *
! * Ensure that we can do a round-trip of all server-supported unicode
! * values without trashing them, and that bad encodings are
! * detected.
*/
public class DatabaseEncodingTest extends TestCase
{
***************
*** 26,32 ****
super(name);
}

! private static final int STEP = 300;

// Set up the fixture for this testcase: a connection to a database with
// a table for this test.
--- 33,39 ----
super(name);
}

! private static final int STEP = 100;

// Set up the fixture for this testcase: a connection to a database with
// a table for this test.
***************
*** 68,84 ****
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT getdatabaseencoding()");
assertTrue(rs.next());
! if (!"UNICODE".equals(rs.getString(1)))
{
rs.close();
return ; // not a UNICODE database.
}

rs.close();

// Create data.
! // NB: we only test up to d800 as code points above that are
! // reserved for surrogates in UTF-16
PreparedStatement insert = con.prepareStatement("INSERT INTO testdbencoding(unicode_ordinal, unicode_string) VALUES (?,?)");
for (int i = 1; i < 0xd800; i += STEP)
{
--- 75,95 ----
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT getdatabaseencoding()");
assertTrue(rs.next());
!
! String dbEncoding = rs.getString(1);
! if (!dbEncoding.equals("UNICODE") && !dbEncoding.equals("UTF8"))
{
+ System.err.println("DatabaseEncodingTest: Skipping UNICODE database tests as test database encoding is " + dbEncoding);
rs.close();
return ; // not a UNICODE database.
}

rs.close();

+ boolean testHighUnicode = TestUtil.haveMinimumServerVersion(con, "8.1");
+
// Create data.
! // NB: we avoid d800-dfff as those are reserved for surrogates in UTF-16
PreparedStatement insert = con.prepareStatement("INSERT INTO testdbencoding(unicode_ordinal, unicode_string) VALUES (?,?)");
for (int i = 1; i < 0xd800; i += STEP)
{
***************
*** 94,102 ****
--- 105,149 ----
assertEquals(1, insert.executeUpdate());
}

+ for (int i = 0xe000; i < 0x10000; i += STEP)
+ {
+ int count = (i + STEP) > 0x10000 ? 0x10000 - i : STEP;
+ char[] testChars = new char[count];
+ for (int j = 0; j < count; ++j)
+ testChars[j] = (char)(i + j);
+
+ String testString = new String(testChars);
+
+ insert.setInt(1, i);
+ insert.setString(2, testString);
+ assertEquals(1, insert.executeUpdate());
+ }
+
+ if (testHighUnicode) {
+ for (int i = 0x10000; i < 0x110000; i += STEP)
+ {
+ int count = (i + STEP) > 0x110000 ? 0x110000 - i : STEP;
+ char[] testChars = new char[count*2];
+ for (int j = 0; j < count; ++j) {
+ testChars[j*2] = (char)(0xd800 + ((i + j - 0x10000) >> 10));
+ testChars[j*2+1] = (char)(0xdc00 + ((i + j - 0x10000) & 0x3ff));
+ }
+
+ String testString = new String(testChars);
+
+ insert.setInt(1, i);
+ insert.setString(2, testString);
+
+ //System.err.println("Inserting: " + dumpString(testString));
+
+ assertEquals(1, insert.executeUpdate());
+ }
+ }
+
con.commit();

// Check data.
+ stmt.setFetchSize(1);
rs = stmt.executeQuery("SELECT unicode_ordinal, unicode_string FROM testdbencoding ORDER BY unicode_ordinal");
for (int i = 1; i < 0xd800; i += STEP)
{
***************
*** 110,116 ****

String testString = new String(testChars);

! assertEquals(dumpString(testString), dumpString(rs.getString(2)));
}
}
}
--- 157,323 ----

String testString = new String(testChars);

! assertEquals("Test string: " + dumpString(testString), dumpString(testString), dumpString(rs.getString(2)));
! }
!
! for (int i = 0xe000; i < 0x10000; i += STEP)
! {
! assertTrue(rs.next());
! assertEquals(i, rs.getInt(1));
!
! int count = (i + STEP) > 0x10000 ? 0x10000 - i : STEP;
! char[] testChars = new char[count];
! for (int j = 0; j < count; ++j)
! testChars[j] = (char)(i + j);
!
! String testString = new String(testChars);
!
! assertEquals("Test string: " + dumpString(testString), dumpString(testString), dumpString(rs.getString(2)));
! }
!
! if (testHighUnicode) {
! for (int i = 0x10000; i < 0x110000; i += STEP)
! {
! assertTrue(rs.next());
! assertEquals(i, rs.getInt(1));
!
! int count = (i + STEP) > 0x110000 ? 0x110000 - i : STEP;
! char[] testChars = new char[count*2];
! for (int j = 0; j < count; ++j) {
! testChars[j*2] = (char)(0xd800 + ((i + j - 0x10000) >> 10));
! testChars[j*2+1] = (char)(0xdc00 + ((i + j - 0x10000) & 0x3ff));
! }
!
! String testString = new String(testChars);
!
! assertEquals("Test string: " + dumpString(testString), dumpString(testString), dumpString(rs.getString(2)));
! }
! }
! }
!
! public void testUTF8Decode() throws Exception {
! // Tests for our custom UTF-8 decoder.
!
! Encoding utf8Encoding = Encoding.getJVMEncoding("UTF-8");
!
! for (int ch = 0; ch < 0x110000; ++ch) {
! if (ch >= 0xd800 && ch < 0xe000)
! continue; // Surrogate range.
!
! String testString;
! if (ch >= 0x10000) {
! testString = new String(new char[] {
! (char) (0xd800 + ((ch-0x10000) >> 10)),
! (char) (0xdc00 + ((ch-0x10000) & 0x3ff)) });
! } else {
! testString = new String(new char[] { (char)ch });
! }
!
! byte[] jvmEncoding = testString.getBytes("UTF-8");
! String jvmDecoding = new String(jvmEncoding, 0, jvmEncoding.length, "UTF-8");
! String ourDecoding = utf8Encoding.decode(jvmEncoding, 0, jvmEncoding.length);
!
! assertEquals("Test string: " + dumpString(testString), dumpString(testString), dumpString(jvmDecoding));
! assertEquals("Test string: " + dumpString(testString), dumpString(testString), dumpString(ourDecoding));
! }
! }
!
! public void testBadUTF8Decode() throws Exception {
! Encoding utf8Encoding = Encoding.getJVMEncoding("UTF-8");
!
! byte[][] badSequences = new byte[][] {
! // One-byte illegal sequences
! { (byte)0x80 }, // First byte may not be 10xxxxxx
!
! // Two-byte illegal sequences
! { (byte)0xc0, (byte)0x00 }, // Second byte must be 10xxxxxx
! { (byte)0xc0, (byte)0x80 }, // Can't represent a value < 0x80
!
! // Three-byte illegal sequences
! { (byte)0xe0, (byte)0x00 }, // Second byte must be 10xxxxxx
! { (byte)0xe0, (byte)0x80, (byte)0x00 }, // Third byte must be 10xxxxxx
! { (byte)0xe0, (byte)0x80, (byte)0x80 }, // Can't represent a value < 0x800
! { (byte)0xed, (byte)0xa0, (byte)0x80 }, // Not allowed to encode the range d800..dfff
!
! // Four-byte illegal sequences
! { (byte)0xf0, (byte)0x00 }, // Second byte must be 10xxxxxx
! { (byte)0xf0, (byte)0x80, (byte)0x00 }, // Third byte must be 10xxxxxx
! { (byte)0xf0, (byte)0x80, (byte)0x80, (byte)0x00 }, // Fourth byte must be 10xxxxxx
! { (byte)0xf0, (byte)0x80, (byte)0x80, (byte)0x80 }, // Can't represent a value < 0x10000
!
! // Five-byte illegal sequences
! { (byte)0xf8 }, // Can't have a five-byte sequence.
!
! // Six-byte illegal sequences
! { (byte)0xfc }, // Can't have a six-byte sequence.
!
! // Seven-byte illegal sequences
! { (byte)0xfe }, // Can't have a seven-byte sequence.
!
! // Eigth-byte illegal sequences
! { (byte)0xff }, // Can't have an eight-byte sequence.
! };
!
! byte[] paddedSequence = new byte[32];
! for (int i = 0; i < badSequences.length; ++i) {
! byte[] sequence = badSequences[i];
!
! try {
! String str = utf8Encoding.decode(sequence, 0, sequence.length);
! fail("Expected an IOException on sequence " + i + ", but decoded to <" + str + ">");
! } catch (IOException ioe) {
! // Expected exception.
! }
!
! // Try it with padding.
! Arrays.fill(paddedSequence, (byte)0);
! System.arraycopy(sequence, 0, paddedSequence, 0, sequence.length);
!
! try {
! String str = utf8Encoding.decode(paddedSequence, 0, paddedSequence.length);
! fail("Expected an IOException on sequence " + i + ", but decoded to <" + str + ">");
! } catch (IOException ioe) {
! // Expected exception.
! }
! }
! }
!
! public void testTruncatedUTF8Decode() throws Exception {
! Encoding utf8Encoding = Encoding.getJVMEncoding("UTF-8");
!
! byte[][] shortSequences = new byte[][] {
! { (byte)0xc0 }, // Second byte must be present
!
! { (byte)0xe0 }, // Second byte must be present
! { (byte)0xe0, (byte)0x80 }, // Third byte must be present
!
! { (byte)0xf0 }, // Second byte must be present
! { (byte)0xf0, (byte)0x80 }, // Third byte must be present
! { (byte)0xf0, (byte)0x80, (byte)0x80 }, // Fourth byte must be present
! };
!
! byte[] paddedSequence = new byte[32];
! for (int i = 0; i < shortSequences.length; ++i) {
! byte[] sequence = shortSequences[i];
!
! try {
! String str = utf8Encoding.decode(sequence, 0, sequence.length);
! fail("Expected an IOException on sequence " + i + ", but decoded to <" + str + ">");
! } catch (IOException ioe) {
! // Expected exception.
! }
!
!
! // Try it with padding and a truncated length.
! Arrays.fill(paddedSequence, (byte)0);
! System.arraycopy(sequence, 0, paddedSequence, 0, sequence.length);
!
! try {
! String str = utf8Encoding.decode(paddedSequence, 0, sequence.length);
! fail("Expected an IOException on sequence " + i + ", but decoded to <" + str + ">");
! } catch (IOException ioe) {
! // Expected exception.
! }
}
}
}
*** /dev/null Thu Jan 1 12:00:00 1970
--- org/postgresql/core/UTF8Encoding.java Thu Jun 30 02:03:28 2005
***************
*** 0 ****
--- 1,157 ----
+ package org.postgresql.core;
+
+ import java.io.IOException;
+ import org.postgresql.util.GT;
+
+ class UTF8Encoding extends Encoding {
+ UTF8Encoding(String jvmEncoding) {
+ super(jvmEncoding);
+ }
+
+ private static final int MIN_2_BYTES = 0x80;
+ private static final int MIN_3_BYTES = 0x800;
+ private static final int MIN_4_BYTES = 0x10000;
+ private static final int MAX_CODE_POINT = 0x10ffff;
+
+ private char[] decoderArray = new char[1024];
+
+ // helper for decode
+ private final static void checkByte(int ch, int pos, int len) throws IOException {
+ if ((ch & 0xc0) != 0x80)
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: byte {0} of {1} byte sequence is not 10xxxxxx: {2}",
+ new Object[] { new Integer(pos), new Integer(len), new Integer(ch) }));
+ }
+
+ private final static void checkMinimal(int ch, int minValue) throws IOException {
+ if (ch >= minValue)
+ return;
+
+ int actualLen;
+ switch (minValue) {
+ case MIN_2_BYTES:
+ actualLen = 2;
+ break;
+ case MIN_3_BYTES:
+ actualLen = 3;
+ break;
+ case MIN_4_BYTES:
+ actualLen = 4;
+ break;
+ default:
+ throw new IllegalArgumentException("unexpected minValue passed to checkMinimal: " + minValue);
+ }
+
+ int expectedLen;
+ if (ch < MIN_2_BYTES)
+ expectedLen = 1;
+ else if (ch < MIN_3_BYTES)
+ expectedLen = 2;
+ else if (ch < MIN_4_BYTES)
+ expectedLen = 3;
+ else
+ throw new IllegalArgumentException("unexpected ch passed to checkMinimal: " + ch);
+
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: {0} bytes used to encode a {1} byte value: {2}",
+ new Object[] { new Integer(actualLen), new Integer(expectedLen), new Integer(ch) }));
+ }
+
+ /**
+ * Custom byte[] -> String conversion routine for UTF-8 only.
+ * This is about twice as fast as using the String(byte[],int,int,String)
+ * ctor, at least under JDK 1.4.2. The extra checks for illegal representations
+ * add about 10-15% overhead, but they seem worth it given the number of SQL_ASCII
+ * databases out there.
+ *
+ * @param data the array containing UTF8-encoded data
+ * @param offset the offset of the first byte in <code>data</code> to decode from
+ * @param length the number of bytes to decode
+ * @return a decoded string
+ * @throws IOException if something goes wrong
+ */
+ public synchronized String decode(byte[] data, int offset, int length) throws IOException {
+ char[] cdata = decoderArray;
+ if (cdata.length < length)
+ cdata = decoderArray = new char[length];
+
+ int in = offset;
+ int out = 0;
+ int end = length + offset;
+
+ try
+ {
+ while (in < end)
+ {
+ int ch = data[in++] & 0xff;
+
+ // Convert UTF-8 to 21-bit codepoint.
+ if (ch < 0x80) {
+ // 0xxxxxxx -- length 1.
+ } else if (ch < 0xc0) {
+ // 10xxxxxx -- illegal!
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: initial byte is {0}: {1}",
+ new Object[] { "10xxxxxx", new Integer(ch) }));
+ } else if (ch < 0xe0) {
+ // 110xxxxx 10xxxxxx
+ ch = ((ch & 0x1f) << 6);
+ checkByte(data[in], 2, 2);
+ ch = ch | (data[in++] & 0x3f);
+ checkMinimal(ch, MIN_2_BYTES);
+ } else if (ch < 0xf0) {
+ // 1110xxxx 10xxxxxx 10xxxxxx
+ ch = ((ch & 0x0f) << 12);
+ checkByte(data[in], 2, 3);
+ ch = ch | ((data[in++] & 0x3f) << 6);
+ checkByte(data[in], 3, 3);
+ ch = ch | (data[in++] & 0x3f);
+ checkMinimal(ch, MIN_3_BYTES);
+ } else if (ch < 0xf8) {
+ // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
+ ch = ((ch & 0x07) << 18);
+ checkByte(data[in], 2, 4);
+ ch = ch | ((data[in++] & 0x3f) << 12);
+ checkByte(data[in], 3, 4);
+ ch = ch | ((data[in++] & 0x3f) << 6);
+ checkByte(data[in], 4, 4);
+ ch = ch | (data[in++] & 0x3f);
+ checkMinimal(ch, MIN_4_BYTES);
+ } else {
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: initial byte is {0}: {1}",
+ new Object[] { "11111xxx", new Integer(ch) }));
+ }
+
+ if (ch > MAX_CODE_POINT)
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: final value is out of range: {0}",
+ new Integer(ch)));
+
+ // Convert 21-bit codepoint to Java chars:
+ // 0..ffff are represented directly as a single char
+ // 10000..10ffff are represented as a "surrogate pair" of two chars
+ // See: http://java.sun.com/developer/techni...Supplementary/
+
+ if (ch > 0xffff) {
+ // Use a surrogate pair to represent it.
+ ch -= 0x10000; // ch is now 0..fffff (20 bits)
+ cdata[out++] = (char) (0xd800 + (ch >> 10)); // top 10 bits
+ cdata[out++] = (char) (0xdc00 + (ch & 0x3ff)); // bottom 10 bits
+ } else if (ch >= 0xd800 && ch < 0xe000) {
+ // Not allowed to encode the surrogate range directly.
+ throw new IOException(GT.tr("Illegal UTF-8 sequence: final value is a surrogate value: {0}",
+ new Integer(ch)));
+ } else {
+ // Normal case.
+ cdata[out++] = (char) ch;
+ }
+ }
+ }
+ catch (ArrayIndexOutOfBoundsException a)
+ {
+ throw new IOException("Illegal UTF-8 sequence: multibyte sequence was truncated");
+ }
+
+ // Check if we ran past the end without seeing an exception.
+ if (in > end)
+ throw new IOException("Illegal UTF-8 sequence: multibyte sequence was truncated");
+
+ return new String(cdata, 0, out);
+ }
+ }


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-15-2008, 11:22 PM
Oliver Jowett
 
Posts: n/a
Default Re: Updated high-unicode patch

Oliver Jowett wrote:

> (previous version:
> http://archives.postgresql.org/pgsql...4/msg00213.php)


Sigh.. the right URL is
http://archives.postgresql.org/pgsql...8/msg00068.php, sorry.

-O

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-15-2008, 11:34 PM
Kris Jurka
 
Posts: n/a
Default Re: Updated high-unicode patch



On Thu, 30 Jun 2005, Oliver Jowett wrote:

> The attached patch is an updated and bugfixed version of my earlier
> patch to support UTF-8 encoding of unicode codepoints above U+FFFF


I'm don't like the cost of the new tests included here. On my 2 x PIII
800 machine the entire JDBC 2 test suite takes 212 seconds. testEncoding
takes 67 seconds testUTF8Decode takes 111 seconds for a whopping 84% of
the test time for 2 out of 220 tests. Do you have any recommendations for
lowering this? Random ideas that I could see:

- using STEP in testUTF8Decode as well to reduce the number of iterations
and adding a BIGSTEP for the high unicode range
- selecting a representative sample of codepoints to test
- creating a separate encoding test suite that is driven by "ant enctest"
- running the tests only occasionally since they don't depend on JVM or
database version and should therefore be pretty static, say randomly
1 out of 10 runs.
- doing nothing 3.5 minutes isn't really all that long

Kris Jurka

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 11:35 PM
Oliver Jowett
 
Posts: n/a
Default Re: Updated high-unicode patch

Kris Jurka wrote:

> - creating a separate encoding test suite that is driven by "ant enctest"


Sure.

> - doing nothing 3.5 minutes isn't really all that long


That was why I added the tests -- I'd rather have the better coverage.
The full test is only run against 8.1 servers with a UNICODE test
database, BTW.

It takes about 60 seconds to run all the tests on my machine.

-O

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:57 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670