[CONJ-1097] JSON类型字段在select union中返回列类型错误 Created: 2023-08-04  Updated: 2023-08-04

Status: Open
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 3.0.5
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: wangxinyu Assignee: Diego Dupin
Resolution: Unresolved Votes: 0
Labels: JSON, union
Environment:

操作系统:Windows10专业版;
MariaDB Connector/J版本:3.1.4
MySQL Server版本:5.7.24
IntelliJ IDEA: 2019.2


Issue Links:
Blocks
blocks CONJ-1093 Check the manual that corresponds to ... Closed

 Description   

操作系统:Windows10专业版;
MariaDB Connector/J版本:3.1.4
MySQL Server版本:5.7.24
IntelliJ IDEA: 2019.2
客户端代码:
private static String url = "jdbc:mariadb://127.0.0.1:3306/world?useUnicode=true&characterEncoding=utf-8";

public static void main(String args[]) {
try (Connection conn = DriverManager.getConnection(url, "root", "xxxxxx")) {
String sql = "(select json_col from json1) union all (select json_col from json2) order by 1 asc;";
try (Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery(sql)) {
ResultSetMetaData rsmd = resultSet.getMetaData();
while (resultSet.next()) {

}
}
} catch (Throwable e)

{ e.printStackTrace(); }

}

问题现象:
1、当使用select UNION时(select json_col from json1) union all (select json_col from json2) order by 1 asc;,查询结果集返回列类型为BLOB,是错误的。
无法上传附件截图,可在IDEA中断点查看rsmd的fieldPackets,第一项为BlobColumn(其dataType为BLOB)

2、当未使用select UNION时select json_col from json1 order by 1 asc,查询结果集返回列类型为JSON,是正确的。
无法上传附件截图,可在IDEA中断点查看rsmd的fieldPackets,第一项为JsonColumn(其dataType为JSON);


Generated at Thu Feb 08 03:20:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.