Index: jOOQ/src/main/java/org/jooq/util/postgres/PostgresUtils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jOOQ/src/main/java/org/jooq/util/postgres/PostgresUtils.java	(revision 2167)
+++ jOOQ/src/main/java/org/jooq/util/postgres/PostgresUtils.java	(revision )
@@ -37,13 +37,12 @@
 
 import static org.jooq.tools.reflect.Reflect.on;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringReader;
+import java.io.*;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.jooq.exception.DataTypeException;
+import org.jooq.tools.JooqLogger;
 import org.jooq.tools.reflect.Reflect;
 import org.jooq.types.DayToSecond;
 import org.jooq.types.YearToMonth;
@@ -59,6 +58,8 @@
  */
 public class PostgresUtils {
 
+    private static final JooqLogger log = JooqLogger.getLogger(PostgresUtils.class);
+
     private static final String POSTGRESQL_HEX_STRING_PREFIX = "\\x";
 
     // PGobject parsing state machine
@@ -77,36 +78,83 @@
      */
     public static byte[] toBytes(final String string) {
         if (string.startsWith(POSTGRESQL_HEX_STRING_PREFIX)) {
+            return toBytesFromHexEncoding(string); // default since 9.0
+        } else {
+            return toBytesFromOctalEncoding(string);
+        }
+    }
+
+    private static byte[] toBytesFromOctalEncoding(final String string) {
+        final Reader reader = new StringReader(string);
+        final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+        try {
+            convertOctalToBytes(reader, bytes);
+            return bytes.toByteArray();
+        } catch (IOException x) {
+            throw new RuntimeException("failed to parse octal hex string: " + x.getMessage(), x);
+        }
+    }
+
+    private static void convertOctalToBytes(final Reader reader, final OutputStream bytes) throws IOException {
+        int ch;
+        while ((ch = reader.read()) != -1) {
+            if (ch == '\\') {
+                ch = reader.read();
+                if (ch == -1) {
+                    throw new IOException("unexpected end of stream after initial backslash");
+                }
+                if (ch == '\\') {
+                    bytes.write('\\');
+                    continue;
+                }
+                int val = octalValue(ch);
+                ch = reader.read();
+                if (ch == -1) {
+                    throw new IOException("unexpected end of octal value");
+                }
+                val <<= 3;
+                val += octalValue(ch);
+                ch = reader.read();
+                if (ch == -1) {
+                    throw new IOException("unexpected end of octal value");
+                }
+                val <<= 3;
+                val += octalValue(ch);
+                bytes.write(val);
+            } else {
+                bytes.write(ch);
+            }
+        }
+    }
+
+    private static byte[] toBytesFromHexEncoding(String string) {
-            String hex = string.substring(POSTGRESQL_HEX_STRING_PREFIX.length());
+        String hex = string.substring(POSTGRESQL_HEX_STRING_PREFIX.length());
 
-            final StringReader input = new StringReader(hex);
-            final ByteArrayOutputStream bytes = new ByteArrayOutputStream(hex.length() / 2);
-            int hexDigit;
-            int byteValue;
+        final StringReader input = new StringReader(hex);
+        final ByteArrayOutputStream bytes = new ByteArrayOutputStream(hex.length() / 2);
+        int hexDigit;
+        int byteValue;
 
-            try {
-                while ((hexDigit = input.read()) != -1) {
-                    byteValue = (hexValue(hexDigit) << 4);
-                    if ((hexDigit = input.read()) == -1) {
-                        break;
-                    }
-                    byteValue += hexValue(hexDigit);
-                    bytes.write(byteValue);
-                }
-            }
+        try {
+            while ((hexDigit = input.read()) != -1) {
+                byteValue = (hexValue(hexDigit) << 4);
+                if ((hexDigit = input.read()) == -1) {
+                    break;
+                }
+                byteValue += hexValue(hexDigit);
+                bytes.write(byteValue);
+            }
+        }
 
-            // should never happen for a string reader
-            catch (IOException e) {
-                throw new DataTypeException("Error while decoding hex string", e);
-            }
+        // should never happen for a string reader
+        catch (IOException e) {
+            throw new DataTypeException("Error while decoding hex string", e);
+        }
 
-            input.close();
-            return bytes.toByteArray();
-        }
+        input.close();
+        return bytes.toByteArray();
+    }
 
-        throw new DataTypeException("unknown postgresql string format for bytes: " + string);
-    }
-
     /**
      * Get the hex value of a <code>char</code> digit
      */
@@ -123,6 +171,17 @@
 
         throw new DataTypeException("unknown postgresql character format for hexValue: " + hexDigit);
     }
+
+    /**
+     * Get the octal value of a {@code char} digit
+     */
+    private static int octalValue(final int octalDigit) {
+        if (octalDigit < '0' || octalDigit > '7') {
+            throw new DataTypeException("unknown postgresql character format for octalValue: " + octalDigit);
+        }
+        return octalDigit - '0';
+    }
+
 
     /**
      * Convert a jOOQ <code>DAY TO SECOND</code> interval to a Postgres representation
