Skip to content

Commit

Permalink
Add new type to JDBC driver
Browse files Browse the repository at this point in the history
Signed-off-by: Dirkjan Bussink <[email protected]>
  • Loading branch information
dbussink committed Jul 24, 2024
1 parent 427d137 commit fc81d36
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions java/jdbc/src/main/java/io/vitess/util/MysqlDefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public final class MysqlDefs {
static final int FIELD_TYPE_VARCHAR = 15;
// Newer data types
static final int FIELD_TYPE_YEAR = 13;
static final int FIELD_TYPE_VECTOR = 242;
static final int FIELD_TYPE_JSON = 245;
static final int INIT_DB = 2;

Expand Down Expand Up @@ -166,6 +167,7 @@ public final class MysqlDefs {
mysqlToJdbcTypesMap.put("SET", mysqlToJavaType(FIELD_TYPE_SET));
mysqlToJdbcTypesMap.put("GEOMETRY", mysqlToJavaType(FIELD_TYPE_GEOMETRY));
mysqlToJdbcTypesMap.put("JSON", mysqlToJavaType(FIELD_TYPE_JSON));
mysqlToJdbcTypesMap.put("VECTOR", mysqlToJavaType(FIELD_TYPE_VECTOR));
}

static {
Expand Down Expand Up @@ -200,6 +202,7 @@ public final class MysqlDefs {
vitesstoMySqlType.put(Query.Type.TUPLE, Types.OTHER);
vitesstoMySqlType.put(Query.Type.GEOMETRY, Types.BINARY);
vitesstoMySqlType.put(Query.Type.JSON, Types.CHAR);
vitesstoMySqlType.put(Query.Type.VECTOR, Types.BINARY);
}

static {
Expand Down Expand Up @@ -337,6 +340,7 @@ public static int mysqlToJavaType(int mysqlType) {

break;
case MysqlDefs.FIELD_TYPE_GEOMETRY:
case MysqlDefs.FIELD_TYPE_VECTOR:
jdbcType = Types.BINARY;

break;
Expand Down Expand Up @@ -423,6 +427,8 @@ public static int mysqlToJavaType(String mysqlType) {
return mysqlToJavaType(FIELD_TYPE_BIT);
} else if (mysqlType.equalsIgnoreCase("JSON")) {
return mysqlToJavaType(FIELD_TYPE_JSON);
} else if (mysqlType.equalsIgnoreCase("VECTOR")) {
return mysqlToJavaType(FIELD_TYPE_VECTOR);
}

// Punt
Expand Down Expand Up @@ -509,6 +515,9 @@ public static String typeToName(int mysqlType) {
case MysqlDefs.FIELD_TYPE_GEOMETRY:
return "FIELD_TYPE_GEOMETRY";

case MysqlDefs.FIELD_TYPE_VECTOR:
return "FIELD_TYPE_VECTOR";

case MysqlDefs.FIELD_TYPE_JSON:
return "FIELD_TYPE_JSON";

Expand Down

0 comments on commit fc81d36

Please sign in to comment.