matrixone icon indicating copy to clipboard operation
matrixone copied to clipboard

[Feature Request]: Create table with comment

Open dengn opened this issue 3 years ago • 2 comments

Is there an existing issue for the same feature request?

  • [X] I have checked the existing issues.

Is your feature request related to a problem?

Our parser accepts comment for now. But it doesn't work as expected.

mysql> create table t2 (a int, b int) comment = "事实表";
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t2;
+-------+------------------------------------------------------------------+
| Table | Create Table                                                     |
+-------+------------------------------------------------------------------+
| t2    | CREATE TABLE `t2` (
`a` INT DEFAULT NULL,
`b` INT DEFAULT NULL
) |
+-------+------------------------------------------------------------------+
1 row in set (0.00 sec)

Describe the feature you'd like

A comment for a column can be specified with the COMMENT option, up to 1024 characters long. The comment is displayed by the [SHOW CREATE TABLE]. There must also be somewhere in the catalog that we need to get this comment.

MySQL example: mysql> create table t1(a int, b int) comment = "事实表"; Query OK, 0 rows affected (0.05 sec)

mysql> show create table t1; +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE t1 ( a int DEFAULT NULL, b int DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='事实表' | +-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.01 sec)

Describe implementation you've considered

No response

Documentation, Adoption, Use Case, Migration Strategy

No response

Additional information

No response

dengn avatar Jul 01 '22 03:07 dengn

For the following table definitions: create table emp( empno int unsigned auto_increment COMMENT 'employee number', ename varchar(15) COMMENT 'employee name', job varchar(10) COMMENT 'employee position', primary key(empno) ) COMMENT='employee table';

Table attribute comment need to be stored in the catalog table mo_columns's att_comment, and the table comment should be stored in the catalog table mo_tables's rel_comment

qingxinhome avatar Jul 12 '22 08:07 qingxinhome

This feature request has been fixed, unit test and client test have been completed, and now request acceptance test, please know! @dengn @florashi181 @fengttt

qingxinhome avatar Jul 25 '22 03:07 qingxinhome