Skip to content

Commit

Permalink
[CONJ-1063] DatabaseMetaData.getTypeInfo() returns wrong value for UN…
Browse files Browse the repository at this point in the history
…SIGNED_ATTRIBUTE - datatype correction
  • Loading branch information
rusher committed Mar 16, 2023
1 parent 4c018af commit 5c77c28
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 44 deletions.
84 changes: 43 additions & 41 deletions src/main/java/org/mariadb/jdbc/DatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ public ResultSet getTypeInfo() {
DataType.INTEGER,
DataType.BIT,
DataType.SMALLINT,
DataType.TINYINT,
DataType.BIT,
DataType.BIT,
DataType.BIT,
DataType.VARCHAR,
Expand All @@ -2689,9 +2689,11 @@ public ResultSet getTypeInfo() {
};

String[][] data = {
{"BIT", "-7", "1", "", "", "", "1", "1", "3", "0", "0", "0", "BIT", "0", "0", "0", "0", "10"},
{
"BOOL", "-7", "1", "", "", "", "1", "1", "3", "0", "0", "0", "BOOL", "0", "0", "0", "0",
"BIT", "-7", "1", "", "", "", "1", "1", "3", "\0", "0", "0", "BIT", "0", "0", "0", "0", "10"
},
{
"BOOL", "-7", "1", "", "", "", "1", "1", "3", "\0", "0", "0", "BOOL", "0", "0", "0", "0",
"10"
},
{
Expand All @@ -2704,7 +2706,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"TINYINT",
Expand All @@ -2724,7 +2726,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"TINYINT UNSIGNED",
Expand All @@ -2744,7 +2746,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"BIGINT",
Expand All @@ -2764,7 +2766,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"BIGINT UNSIGNED",
Expand All @@ -2784,7 +2786,7 @@ public ResultSet getTypeInfo() {
"1",
"1",
"3",
"0",
"\0",
"0",
"0",
"LONG VARBINARY",
Expand All @@ -2804,7 +2806,7 @@ public ResultSet getTypeInfo() {
"1",
"1",
"3",
"0",
"\0",
"0",
"0",
"MEDIUMBLOB",
Expand All @@ -2824,7 +2826,7 @@ public ResultSet getTypeInfo() {
"1",
"1",
"3",
"0",
"\0",
"0",
"0",
"LONGBLOB",
Expand All @@ -2835,7 +2837,7 @@ public ResultSet getTypeInfo() {
"10"
},
{
"BLOB", "-4", "65535", "'", "'", "", "1", "1", "3", "0", "0", "0", "BLOB", "0", "0", "0",
"BLOB", "-4", "65535", "'", "'", "", "1", "1", "3", "\0", "0", "0", "BLOB", "0", "0", "0",
"0", "10"
},
{
Expand All @@ -2848,7 +2850,7 @@ public ResultSet getTypeInfo() {
"1",
"1",
"3",
"0",
"\0",
"0",
"0",
"TINYBLOB",
Expand All @@ -2868,7 +2870,7 @@ public ResultSet getTypeInfo() {
"1",
"1",
"3",
"0",
"\0",
"0",
"0",
"VARBINARY",
Expand All @@ -2879,7 +2881,7 @@ public ResultSet getTypeInfo() {
"10"
},
{
"BINARY", "-2", "255", "'", "'", "(M)", "1", "1", "3", "0", "0", "0", "BINARY", "0", "0",
"BINARY", "-2", "255", "'", "'", "(M)", "1", "1", "3", "\0", "0", "0", "BINARY", "0", "0",
"0", "0", "10"
},
{
Expand All @@ -2892,7 +2894,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"LONG VARCHAR",
Expand All @@ -2912,7 +2914,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"MEDIUMTEXT",
Expand All @@ -2932,7 +2934,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"LONGTEXT",
Expand All @@ -2943,7 +2945,7 @@ public ResultSet getTypeInfo() {
"10"
},
{
"TEXT", "-1", "65535", "'", "'", "", "1", "0", "3", "0", "0", "0", "TEXT", "0", "0", "0",
"TEXT", "-1", "65535", "'", "'", "", "1", "0", "3", "\0", "0", "0", "TEXT", "0", "0", "0",
"0", "10"
},
{
Expand All @@ -2956,7 +2958,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"TINYTEXT",
Expand All @@ -2967,7 +2969,7 @@ public ResultSet getTypeInfo() {
"10"
},
{
"CHAR", "1", "255", "'", "'", "(M)", "1", "0", "3", "0", "0", "0", "CHAR", "0", "0", "0",
"CHAR", "1", "255", "'", "'", "(M)", "1", "0", "3", "\0", "0", "0", "CHAR", "0", "0", "0",
"0", "10"
},
{
Expand All @@ -2980,7 +2982,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"NUMERIC",
Expand All @@ -3000,7 +3002,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"DECIMAL",
Expand All @@ -3020,7 +3022,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"INTEGER",
Expand All @@ -3040,7 +3042,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"INTEGER UNSIGNED",
Expand All @@ -3060,7 +3062,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"INT",
Expand All @@ -3080,7 +3082,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"INT UNSIGNED",
Expand All @@ -3100,7 +3102,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"MEDIUMINT",
Expand All @@ -3120,7 +3122,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"MEDIUMINT UNSIGNED",
Expand All @@ -3140,7 +3142,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"SMALLINT",
Expand All @@ -3160,7 +3162,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"1",
"\1",
"0",
"1",
"SMALLINT UNSIGNED",
Expand All @@ -3180,7 +3182,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"FLOAT",
Expand All @@ -3200,7 +3202,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"DOUBLE",
Expand All @@ -3220,7 +3222,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"DOUBLE PRECISION",
Expand All @@ -3240,7 +3242,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"1",
"REAL",
Expand All @@ -3251,23 +3253,23 @@ public ResultSet getTypeInfo() {
"10"
},
{
"VARCHAR", "12", "255", "'", "'", "(M)", "1", "0", "3", "0", "0", "0", "VARCHAR", "0", "0",
"VARCHAR", "12", "255", "'", "'", "(M)", "1", "0", "3", "\0", "0", "0", "VARCHAR", "0", "0",
"0", "0", "10"
},
{
"ENUM", "12", "65535", "'", "'", "", "1", "0", "3", "0", "0", "0", "ENUM", "0", "0", "0",
"ENUM", "12", "65535", "'", "'", "", "1", "0", "3", "\0", "0", "0", "ENUM", "0", "0", "0",
"0", "10"
},
{
"SET", "12", "64", "'", "'", "", "1", "0", "3", "0", "0", "0", "SET", "0", "0", "0", "0",
"SET", "12", "64", "'", "'", "", "1", "0", "3", "\0", "0", "0", "SET", "0", "0", "0", "0",
"10"
},
{
"DATE", "91", "10", "'", "'", "", "1", "0", "3", "0", "0", "0", "DATE", "0", "0", "0", "0",
"DATE", "91", "10", "'", "'", "", "1", "0", "3", "\0", "0", "0", "DATE", "0", "0", "0", "0",
"10"
},
{
"TIME", "92", "18", "'", "'", "[(M)]", "1", "0", "3", "0", "0", "0", "TIME", "0", "0", "0",
"TIME", "92", "18", "'", "'", "[(M)]", "1", "0", "3", "\0", "0", "0", "TIME", "0", "0", "0",
"0", "10"
},
{
Expand All @@ -3280,7 +3282,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"DATETIME",
Expand All @@ -3300,7 +3302,7 @@ public ResultSet getTypeInfo() {
"1",
"0",
"3",
"0",
"\0",
"0",
"0",
"TIMESTAMP",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

import java.sql.SQLException;
import java.util.ServiceLoader;

import org.mariadb.jdbc.Driver;
import org.mariadb.jdbc.plugin.AuthenticationPlugin;
import org.mariadb.jdbc.plugin.TlsSocketPlugin;
import org.mariadb.jdbc.plugin.tls.main.DefaultTlsSocketPlugin;

Expand All @@ -26,7 +24,8 @@ public final class TlsSocketPluginLoader {
public static TlsSocketPlugin get(String type) throws SQLException {
if (type == null) return new DefaultTlsSocketPlugin();

ServiceLoader<TlsSocketPlugin> loader = ServiceLoader.load(TlsSocketPlugin.class, Driver.class.getClassLoader());
ServiceLoader<TlsSocketPlugin> loader =
ServiceLoader.load(TlsSocketPlugin.class, Driver.class.getClassLoader());

for (TlsSocketPlugin implClass : loader) {
if (type.equals(implClass.type())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ private static void checkType(String name, int actualType, String colName, int e
@Test
public void metaUnsigned() throws SQLException {
ResultSet typeInfo = sharedConn.getMetaData().getTypeInfo();
ResultSetMetaData rsmd = typeInfo.getMetaData();
assertEquals(Types.BOOLEAN, rsmd.getColumnType(typeInfo.findColumn("UNSIGNED_ATTRIBUTE")));
while (typeInfo.next()) {
Assertions.assertEquals(
typeInfo.getString("TYPE_NAME").contains("UNSIGNED"),
Expand Down

0 comments on commit 5c77c28

Please sign in to comment.