apache / apache/shardingsphere

use proxy create table ,show unexpected results

Open
#23,820 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: proxy
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
9h 55m
Merged PRs (30d)
311

Description

Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Please pay attention on issues you submitted, because we maybe need more details.
If no response anymore and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

cf769d3200b0b9a6afe1e7dd210c50f486a8530a

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

Proxy

Expected behavior
mysql> CREATE TABLE tb_user (
    -> id INT AUTO_INCREMENT PRIMARY KEY ,
    -> NAME VARCHAR ( 10 ) NOT NULL UNIQUE ,
    -> age INT CHECK ( age > 0 and age <= 120 ) ,
    -> STATUS CHAR ( 1 ) DEFAULT '1' ,
    -> gender CHAR ( 1 )
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql> show create table tb_user;
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                                                                                                                                                        |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tb_user | CREATE TABLE `tb_user` (
  `id` int NOT NULL AUTO_INCREMENT,
  `NAME` varchar(10) NOT NULL,
  `age` int DEFAULT NULL,
  `STATUS` char(1) DEFAULT '1',
  `gender` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `NAME` (`NAME`),
  CONSTRAINT `tb_user_chk_1` CHECK (((`age` > 0) and (`age` <= 120)))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Actual behavior
mysql> CREATE TABLE tb_user (
    -> id INT AUTO_INCREMENT PRIMARY KEY ,
    -> NAME VARCHAR ( 10 ) NOT NULL UNIQUE ,
    -> age INT CHECK ( age > 0 and age <= 120 ) ,
    -> STATUS CHAR ( 1 ) DEFAULT '1' ,
    -> gender CHAR ( 1 )
    -> );
Query OK, 0 rows affected (0.03 sec)

mysql>
mysql> show create table tb_user;
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table   | Create Table                                                                                                                                                                                                                                                                              |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tb_user | CREATE TABLE `tb_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `NAME` varchar(10) NOT NULL,
  `age` int(11) DEFAULT NULL,
  `STATUS` char(1) DEFAULT '1',
  `gender` char(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `NAME` (`NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
+---------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Reason analyze (If you can)
Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.
Example codes for reproduce this issue (such as a github link).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the ShardingSphere-Proxy path that handles MySQL CREATE TABLE and SHOW CREATE TABLE statements. Reproduce the tb_user example and compare the expected and actual definitions, including the missing CHECK constraint and changed integer display; done means the proxy returns the expected table definition.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, mysql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.