apache / shardingsphere

Distributed SQL transaction & query engine for data sharding, scaling, encryption, and more - on any database.
Apache License 2.0
19.87k stars 6.73k forks source link

auto-unboxing NullPointerException #21259

Closed c1258445690 closed 3 months ago

c1258445690 commented 2 years ago

Bug Report

project: ShardingSphere-JDBC version: 5.2.0 database: mysql-8.0.28

reason

In method org.apache.shardingsphere.infra.metadata.database.schema.loader.dialect.MySQLSchemaMetaDataLoader.loadColumnMetaData, when a table contains column of linestring or geomcollection type, dataTypeMap.get(dataType) will return null which causes auto-unboxing NullPointerException

Steps to reproduce the behavior

CREATE TABLE `student_1` (
  `id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `age` int DEFAULT NULL,
  PRIMARY KEY (`id`)
);
CREATE TABLE `student_2` (
  `id` int NOT NULL,
  `name` varchar(255) DEFAULT NULL,
  `age` int DEFAULT NULL,
  PRIMARY KEY (`id`)
);
CREATE TABLE `geom` (
  `a` geometry NOT NULL,
  `b` point DEFAULT NULL,
  `d` polygon DEFAULT NULL,
  `e` geomcollection DEFAULT NULL,
  `c` linestring DEFAULT NULL
) ;
<dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
            <version>5.2.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.2.2</version>
        </dependency>
spring:
  shardingsphere:
    datasource:
      names: ds_1, ds_2
      ds_1:
        type: com.zaxxer.hikari.HikariDataSource
        driverClassName: com.mysql.cj.jdbc.Driver
        jdbcUrl: jdbc:mysql://192.168.1.66:3306/test?useUnicode=true&allowMultiQueries=true&characterEncoding=utf-8&useSSL=false
        username: root
        password: Ebupt#2016
      ds_2:
        type: com.zaxxer.hikari.HikariDataSource
        driverClassName: com.mysql.cj.jdbc.Driver
        jdbcUrl: jdbc:mysql://192.168.7.65:3306/test?useUnicode=true&allowMultiQueries=true&characterEncoding=utf-8&useSSL=false
        username: root
        password: 6
    rules:
      sharding:
        tables:
          student:
            #YamlTableRuleConfiguration
            actual-data-nodes: ds_$->{1..2}.student_$->{1..2}
            key-generate-strategy:
              column: id
              key-generator-name: snowflake
            database-strategy:
              standard:
                sharding-column: id
                sharding-algorithm-name: database-inline
            table-strategy:
              standard:
                sharding-column: id
                sharding-algorithm-name: table-inline
        key-generators:
          snowflake:
            type:
              SNOWFLAKE
        sharding-algorithms:
          database-inline:
            type: INLINE
            props:
              algorithm-expression: ds_$->{id%2+1}
          table-inline:
            type: INLINE
            props:
              algorithm-expression: student_$->{id%2+1}
    props:
      sql:
        show: true
mybatis:
  mapper-locations:
    - mybatis-mapper/*.xml
logging.level:
  com.example.shardingjdbcdemo: debug
RaigorJiang commented 2 years ago

Hi @c1258445690 Thanks for your feedback, we will investigate this problem.

terrymanu commented 3 months ago

shardingsphere-jdbc-core-spring-boot-starter is deprecated and removed in 5.3.0, please try new version and use ShardingSphere Driver.