Compare commits

...

11 Commits

Author SHA1 Message Date
c2190475a8 support loongnix-server 2024-11-27 11:06:50 +08:00
97a8892795 !237 【回合】将uint8类型映射为BigInteger
Merge pull request !237 from zhangtingtingting/7.2.0
2024-05-15 13:14:54 +00:00
4b3f04fb47 将uint8类型映射为BigInteger 2024-05-15 20:36:23 +08:00
c0a7188ca5 !236 处理JDBC连接B库获取blob类型报错问题
Merge pull request !236 from zhangtingtingting/7.2.0
2024-05-15 08:13:51 +00:00
230add6d79 处理blob类型报错问题 2024-05-15 16:05:28 +08:00
4151a42621 !234 修复B模式下 uint1/uint2/uint4/uint8 的getObject类型为PGobject与M*不一致问题
Merge pull request !234 from zhangtingtingting/8.0.4
2024-05-13 07:50:33 +00:00
ec6435b8ce 修复B模式下 uint1/uint2/uint4/uint8 的getObject类型为PGobject与M*不一致问题 2024-05-13 14:53:03 +08:00
1c82cd33d3 !228 【5.0.2补丁版本】回合PR-181
Merge pull request !228 from zhangxubo/5.0.0
2024-05-13 03:07:35 +00:00
558399c514 fix merge conflict 2024-05-09 21:32:30 +08:00
bbd7de4e5e 解决jdbc插入blob类型报错invalid hexadecimal digit 2024-05-09 21:26:27 +08:00
814e2067d7 !222 【5.0.2 补丁版本】 更新版本号
Merge pull request !222 from zhangxubo/5.0.0
2024-04-23 08:28:56 +00:00
5 changed files with 75 additions and 25 deletions

View File

@ -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"

View File

@ -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;

View File

@ -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

View File

@ -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},

View File

@ -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");
}
}