Compare commits
11 Commits
71a6ee0f3d
...
c2190475a8
Author | SHA1 | Date | |
---|---|---|---|
c2190475a8 | |||
97a8892795 | |||
4b3f04fb47 | |||
c0a7188ca5 | |||
230add6d79 | |||
4151a42621 | |||
ec6435b8ce | |||
1c82cd33d3 | |||
558399c514 | |||
bbd7de4e5e | |||
814e2067d7 |
2
build.sh
2
build.sh
@ -69,6 +69,8 @@ elif [ X"$kernel" = X"asianux" ]; then
|
||||
dist_version="Asianux"
|
||||
elif [ X"$kernel" = X"Darwin" ]; then
|
||||
dist_version="Darwin"
|
||||
elif [ X"$kernel" = X"loongnix-server" ]; then
|
||||
dist_version="loongnix-server"
|
||||
else
|
||||
echo "WARN:Only EulerOS, OPENEULER(aarch64), SUSE, CentOS and Asianux platform support, there will set to UNKNOWN"
|
||||
dist_version="UNKNOWN"
|
||||
|
@ -564,21 +564,8 @@ public enum PGProperty {
|
||||
"if the active node is down, set the timeout threshold for searching for the active node. If the active node is not detected within this timeout period, " +
|
||||
"the cluster is considered to have no active node and no maintenance is performed on the current cluster. This time should include the RTO time of the active node."),
|
||||
|
||||
/**
|
||||
* Adaptively modify the inconsistent set sqlType in batch mode. If the first set sqlType is INTEGER and
|
||||
* the second set is LONG, the first one will be automatically modify to LONG
|
||||
*/
|
||||
ADAPTIVE_SET_SQL_TYPE("adaptiveSetSQLType", "false", "Adaptively modify the inconsistent set sqlType in batch mode. If the first set sqlType is INTEGER and" +
|
||||
" the second set is LONG, the first one will be automatically modify to LONG"),
|
||||
|
||||
/**
|
||||
* Specify 'options' connection initialization parameter.
|
||||
* The value of this parameter may contain spaces and other special characters or their URL representation.
|
||||
*/
|
||||
OPTIONS("options", null, "Specify 'options' connection initialization parameter."),
|
||||
|
||||
B_CMPT_MODE("BCmptMode", "false", "Specify 'dolphin.b_compatibility_mode'"
|
||||
+ " connection initialization parameter."),
|
||||
B_CMPT_MODE("BCmptMode", "true", "Specify 'dolphin.b_compatibility_mode'"
|
||||
+ " connection initialization parameter.")
|
||||
;
|
||||
|
||||
private String _name;
|
||||
|
@ -270,6 +270,8 @@ public class PgResultSet implements ResultSet, org.postgresql.PGRefCursorResultS
|
||||
return getInt(columnIndex);
|
||||
case Types.BIGINT:
|
||||
return getLong(columnIndex);
|
||||
case TypeInfoCache.bIntegerType:
|
||||
return getBigInteger(columnIndex);
|
||||
case Types.NUMERIC:
|
||||
case Types.DECIMAL:
|
||||
return getBigDecimal(columnIndex,
|
||||
@ -2098,16 +2100,7 @@ public class PgResultSet implements ResultSet, org.postgresql.PGRefCursorResultS
|
||||
|
||||
Encoding encoding = connection.getEncoding();
|
||||
try {
|
||||
String typeName = getPGType(columnIndex);
|
||||
String result = trimString(columnIndex, encoding.decode(this_row[columnIndex - 1]));
|
||||
if (("blob".equals(typeName))) {
|
||||
if (connection.unwrap(PgConnection.class).isDolphinCmpt()) {
|
||||
return new String(toBytes(result));
|
||||
}
|
||||
} else if (blobSet.contains(typeName)) {
|
||||
return new String(toBytes(result));
|
||||
}
|
||||
return result;
|
||||
return trimString(columnIndex, encoding.decode(this_row[columnIndex - 1]));
|
||||
} catch (IOException ioe) {
|
||||
throw new PSQLException(
|
||||
GT.tr(
|
||||
@ -2324,6 +2317,19 @@ public class PgResultSet implements ResultSet, org.postgresql.PGRefCursorResultS
|
||||
return toLong(getFixedString(columnIndex));
|
||||
}
|
||||
|
||||
public BigInteger getBigInteger(int columnIndex) throws SQLException {
|
||||
String stringVal = getString(columnIndex);
|
||||
if (stringVal == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(stringVal);
|
||||
} catch (NumberFormatException ex) {
|
||||
connection.getLogger().trace("[" + connection.getSocketAddress() + "] " + "format BigInteger failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A dummy exception thrown when fast byte[] to number parsing fails and no value can be returned.
|
||||
* The exact stack trace does not matter because the exception is always caught and is not visible
|
||||
|
@ -61,6 +61,8 @@ public class TypeInfoCache implements TypeInfo {
|
||||
private PreparedStatement _getArrayDelimiterStatement;
|
||||
private PreparedStatement _getTypeInfoStatement;
|
||||
|
||||
public static final int bIntegerType = 95;
|
||||
|
||||
// basic pg types info:
|
||||
// 0 - type name
|
||||
// 1 - type oid
|
||||
@ -73,6 +75,10 @@ public class TypeInfoCache implements TypeInfo {
|
||||
{"int4", Oid.INT4, Types.INTEGER, "java.lang.Integer", Oid.INT4_ARRAY},
|
||||
{"oid", Oid.OID, Types.BIGINT, "java.lang.Long", Oid.OID_ARRAY},
|
||||
{"int8", Oid.INT8, Types.BIGINT, "java.lang.Long", Oid.INT8_ARRAY},
|
||||
{"uint1", Oid.UNSPECIFIED, Types.SMALLINT, "java.lang.Integer", Oid.INT1_ARRAY},
|
||||
{"uint2", Oid.UNSPECIFIED, Types.INTEGER, "java.lang.Integer", Oid.INT2_ARRAY},
|
||||
{"uint4", Oid.UNSPECIFIED, Types.BIGINT, "java.lang.Long", Oid.INT4_ARRAY},
|
||||
{"uint8", Oid.UNSPECIFIED, bIntegerType, "java.math.BigInteger", Oid.INT8_ARRAY},
|
||||
{"money", Oid.MONEY, Types.DOUBLE, "java.lang.Double", Oid.MONEY_ARRAY},
|
||||
{"numeric", Oid.NUMERIC, Types.NUMERIC, "java.math.BigDecimal", Oid.NUMERIC_ARRAY},
|
||||
{"float4", Oid.FLOAT4, Types.REAL, "java.lang.Float", Oid.FLOAT4_ARRAY},
|
||||
|
@ -0,0 +1,49 @@
|
||||
package org.postgresql.test.jdbc4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.postgresql.test.TestUtil;
|
||||
import org.postgresql.test.jdbc2.BaseTest4;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.sql.*;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class UnsignedTest extends BaseTest4 {
|
||||
|
||||
/**
|
||||
* test uint8 type
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUint8() throws SQLException {
|
||||
TestUtil.createTable(con, "test_unit8", "id uint8");
|
||||
|
||||
PreparedStatement pstmt = con.prepareStatement("INSERT INTO test_unit8 VALUES (?)");
|
||||
BigInteger b = new BigInteger("9223372036859999999");
|
||||
pstmt.setObject(1, b, Types.NUMERIC);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
BigInteger b2 = new BigInteger("15223372036859999999");
|
||||
pstmt.setObject(1, b2, Types.NUMERIC);
|
||||
pstmt.executeUpdate();
|
||||
|
||||
Statement stmt = con.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT id FROM test_unit8");
|
||||
|
||||
assertTrue(rs.next());
|
||||
Object r1 = rs.getObject(1);
|
||||
assertNotNull(r1);
|
||||
assertEquals(b, r1);
|
||||
|
||||
assertTrue(rs.next());
|
||||
Object r2 = rs.getObject(1);
|
||||
assertNotNull(r2);
|
||||
assertEquals(b2, r2);
|
||||
|
||||
TestUtil.dropTable(con, "test_unit8");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user