private ResultSet readBinaryResultSet(int index, int count) throws SQLException { int dimensions = ByteConverter.int4(fieldBytes, 0); // int flags = ByteConverter.int4(fieldBytes, 4); // bit 0: 0=no-nulls, 1=has-nulls int elementOid = ByteConverter.int4(fieldBytes, 8); int pos = 12; int[] dims = new int[dimensions]; for (int d = 0; d < dimensions; ++d) { dims[d] = ByteConverter.int4(fieldBytes, pos); pos += 4; /* int lbound = ByteConverter.int4(fieldBytes, pos); */ pos += 4; } if (count > 0 && dimensions > 0) { dims[0] = Math.min(count, dims[0]); } List<byte[][]> rows = new ArrayList<byte[][]>(); Field[] fields = new Field[2]; storeValues(rows, fields, elementOid, dims, pos, 0, index); BaseStatement stat = (BaseStatement) connection .createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); return stat.createDriverResultSet(fields, rows); }
private Object readBinaryArray(int index, int count) throws SQLException { int dimensions = ByteConverter.int4(fieldBytes, 0); // int flags = ByteConverter.int4(fieldBytes, 4); // bit 0: 0=no-nulls, 1=has-nulls int elementOid = ByteConverter.int4(fieldBytes, 8); int pos = 12; int[] dims = new int[dimensions]; for (int d = 0; d < dimensions; ++d) { dims[d] = ByteConverter.int4(fieldBytes, pos); pos += 4; /* int lbound = ByteConverter.int4(fieldBytes, pos); */ pos += 4; } if (dimensions == 0) { return java.lang.reflect.Array.newInstance(elementOidToClass(elementOid), 0); } if (count > 0) { dims[0] = Math.min(count, dims[0]); } Object arr = java.lang.reflect.Array.newInstance(elementOidToClass(elementOid), dims); try { storeValues((Object[]) arr, elementOid, dims, pos, 0, index); } catch (IOException ioe) { throw new PSQLException( GT.tr( "Invalid character data was found. This is most likely caused by stored data containing characters that are invalid for the character set the database was created in. The most common example of this is storing 8bit data in a SQL_ASCII database."), PSQLState.DATA_ERROR, ioe); } return arr; }
pos = storeValues((Object[]) arr[i], elementOid, dims, pos, thisDimension + 1, 0);