Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix decimal output #19643

Conversation

daviszhen
Copy link
Contributor

@daviszhen daviszhen commented Oct 28, 2024

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #https://github.com/matrixorigin/MO-Cloud/issues/4318

https://github.com/matrixorigin/MO-Cloud/issues/4321

What this PR does / why we need it:

1, show columns(desc) 中decimal类型增加精度。

修改前:

mysql> desc tb_1;                                                                                                    
+-------+-------------+------+------+---------+-------+---------+
| Field | Type        | Null | Key  | Default | Extra | Comment |
+-------+-------------+------+------+---------+-------+---------+
| c1    | DECIMAL(15) | YES  |      | NULL    |       |         |                                                
| c2    | INT(32)     | YES  |      | NULL    |       |         |                                                
+-------+-------------+------+------+---------+-------+---------+    

修改后:

mysql> desc tb_1;                                          
+-------+---------------+------+------+---------+-------+---------+
| Field | Type          | Null | Key  | Default | Extra | Comment |
+-------+---------------+------+------+---------+-------+---------+
| c1    | DECIMAL(15,2) | YES  |      | NULL    |       |         |
| c2    | INT(32)       | YES  |      | NULL    |       |         |
+-------+---------------+------+------+---------+-------+---------+

2, cherry-pick show columns(desc)兼容性问题。

原因:mysql 中default值,show columns(desc)与show create table的展示结果是不同的。

mysql的结果

mysql> show create table t1;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                            |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| t1    | CREATE TABLE `t1` (
  `a` varchar(100) DEFAULT 'abc',
  `b` char(1) DEFAULT '0',
  `c` varchar(100) DEFAULT 'abc''d'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show full columns from t1;
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type         | Collation          | Null | Key | Default | Extra | Privileges                      | Comment |
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
| a     | varchar(100) | utf8mb4_0900_ai_ci | YES  |     | abc     |       | select,insert,update,references |         |
| b     | char(1)      | utf8mb4_0900_ai_ci | YES  |     | 0       |       | select,insert,update,references |         |
| c     | varchar(100) | utf8mb4_0900_ai_ci | YES  |     | abc'd   |       | select,insert,update,references |         |
+-------+--------------+--------------------+------+-----+---------+-------+---------------------------------+---------+
3 rows in set (0.00 sec)

修改:区分show columns(desc)与show create table的default值

@daviszhen daviszhen requested a review from m-schen as a code owner October 28, 2024 10:29
@matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label Oct 28, 2024
@mergify mergify bot requested a review from sukki37 October 28, 2024 10:29
@mergify mergify bot added the kind/bug Something isn't working label Oct 28, 2024
@matrix-meow matrix-meow added size/M Denotes a PR that changes [100,499] lines and removed size/XS Denotes a PR that changes [1, 9] lines labels Oct 28, 2024
@matrix-meow matrix-meow added size/XL Denotes a PR that changes [1000, 1999] lines and removed size/M Denotes a PR that changes [100,499] lines labels Oct 29, 2024
@sukki37 sukki37 merged commit 93f50d3 into matrixorigin:1.2.3-tmp-shulian Oct 30, 2024
16 checks passed
sukki37 pushed a commit that referenced this pull request Oct 31, 2024
sukki37 pushed a commit that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working size/XL Denotes a PR that changes [1000, 1999] lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants