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

feat(tianmu): support 'ALTER TABLE t1 CHARACTER SET = ...' clause #848

Closed
lujiashun opened this issue Oct 31, 2022 · 3 comments · Fixed by #865
Closed

feat(tianmu): support 'ALTER TABLE t1 CHARACTER SET = ...' clause #848

lujiashun opened this issue Oct 31, 2022 · 3 comments · Fixed by #865
Assignees
Labels
A-feature feature with good idea C-stonedb-5.7 associated with stonedb 5.7

Comments

@lujiashun
Copy link

lujiashun commented Oct 31, 2022

Is your feature request related to a problem? Please describe.

Enable the sql to change the default table character set,such as :
ALTER TABLE t1 CHARACTER SET = utf8;
Describe the solution you'd like

Describe alternatives you've considered

Additional context

@lujiashun lujiashun added A-feature feature with good idea C-stonedb-5.7 associated with stonedb 5.7 labels Oct 31, 2022
@lujiashun lujiashun self-assigned this Oct 31, 2022
@lujiashun
Copy link
Author

innodb 'alter table t1 character set = ...' flow

four handler function as below should to be implemented
check_if_supported_inplace_alter
prepare_inplace_alter_table
inplace_alter_table
commit_inplace_alter_table

| >dispatch_command                                                                sql_parse.cc:  1226
| | query                                                                          sql_parse.cc:  1483
| | | >lex_start                                                                     sql_lex.cc:   505
| | | <lex_start 518                                                                 sql_lex.cc:   518

| | | >parse_sql                                                                   sql_parse.cc:  7109
| | | <parse_sql 7276                                                              sql_parse.cc:  7276

| | | | >stmt_causes_implicit_commit                                               sql_parse.cc:   278
| | | | <stmt_causes_implicit_commit 300                                           sql_parse.cc:   300
| | | | >trans_commit_implicit                                                   transaction.cc:   294
| | | | | | >ha_commit_low                                                           handler.cc:  1905
| | | | | | <ha_commit_low 1966                                                      handler.cc:  1966
| | | | <trans_commit_implicit 339                                               transaction.cc:   339

| | | | >open_temporary_tables                                                      sql_base.cc:  7318
| | | | <open_temporary_tables 7334                                                 sql_base.cc:  7334

| | | | >Sql_cmd_alter_table                                                       sql_alter.cc:   220

| | | | | | >open_tables                                                            sql_base.cc:  5794
| | | | | | | >open_and_process_table                                               sql_base.cc:  5121
| | | | | | | <open_and_process_table 5392                                          sql_base.cc:  5392
| | | | | | <open_tables 6089                                                       sql_base.cc:  6089

| | | | | | >prep_alter_part_table                                             sql_partition.cc:  4965
| | | | | | <prep_alter_part_table 6032                                        sql_partition.cc:  6032
| | | | | | >is_inplace_alter_impossible                                           sql_table.cc:  7292
| | | | | | <is_inplace_alter_impossible 7372                                      sql_table.cc:  7372

| | | | | | >create_table_impl                                                     sql_table.cc:  4865
| | | | | | <create_table_impl 5435                                                sql_table.cc:  5435
| | | | | | >fill_alter_inplace_info                                               sql_table.cc:  6479
| | | | | | <fill_alter_inplace_info 6953                                          sql_table.cc:  6953

| | | | | | >open_table_uncached                                                    sql_base.cc:  7035
| | | | | | | >open_table_def                                                          table.cc:   702
| | | | | | | | >open_binary_frm                                                       table.cc:  1682
| | | | | | | | <open_binary_frm 2697                                                  table.cc:  2697
| | | | | | | <open_table_def 847                                                      table.cc:   847
| | | | | | | >open_table_from_share                                                   table.cc:  3118
| | | | | | | <open_table_from_share 3483                                              table.cc:  3483
| | | | | | <open_table_uncached 7142                                               sql_base.cc:  7142

| | | | | | >check_if_supported_inplace_alter                                  handler0alter.cc:   564
| | | | | | <check_if_supported_inplace_alter 927                              handler0alter.cc:   927

| | | | | | | >lock_tables                                                          sql_base.cc:  6746
| | | | | | | <lock_tables 6944                                                     sql_base.cc:  6944
| | | | | | | >prepare_inplace_alter_table                                     handler0alter.cc:  5518
| | | | | | | <prepare_inplace_alter_table 6101                                handler0alter.cc:  6101
| | | | | | | >inplace_alter_table                                             handler0alter.cc:  6333
| | | | | | | <inplace_alter_table 6344                                        handler0alter.cc:  6344

| | | | | | | >wait_while_table_is_used                                             sql_base.cc:  2590
| | | | | | | <wait_while_table_is_used 2605                                        sql_base.cc:  2605

| | | | | | | >commit_inplace_alter_table                                      handler0alter.cc:  8294
| | | | | | | <commit_inplace_alter_table 9024                                 handler0alter.cc:  9024

| | | | | | | >close_thread_table                                                   sql_base.cc:  1758
| | | | | | | | >intern_close_table                                                 sql_base.cc:  1128
| | | | | | | | | >closefrm                                                            table.cc:  3516
| | | | | | | | | <closefrm 3550                                                       table.cc:  3550
| | | | | | | | <intern_close_table 1139                                            sql_base.cc:  1139
| | | | | | | <close_thread_table 1805                                              sql_base.cc:  1805

| | | | | | | >close_temporary_table                                                sql_base.cc:  2479
| | | | | | | | >close_temporary                                                    sql_base.cc:  2528
| | | | | | | | <close_temporary 2541                                               sql_base.cc:  2541
| | | | | | | <close_temporary_table 2513                                           sql_base.cc:  2513

| | | | | | | >open_table                                                           sql_base.cc:  3036
| | | | | | | | >open_table_from_share                                                 table.cc:  3118
| | | | | | | | <open_table_from_share 3483                                            table.cc:  3483
| | | | | | | <open_table 3730                                                      sql_base.cc:  3730

| | | | | | | >close_thread_table                                                   sql_base.cc:  1758
| | | | | | | <close_thread_table 1805                                              sql_base.cc:  1805

| | | | <Sql_cmd_alter_table                                                       sql_alter.cc:   339

| | | | >trans_commit_stmt                                                       transaction.cc:   445
| | | | | | | | | >ha_commit_low                                                     handler.cc:  1905
| | | | | | | | | | >innobase_commit                                               ha_innodb.cc:  4379
| | | | | | | | | | <innobase_commit 4515                                          ha_innodb.cc:  4515
| | | | | | | | | <ha_commit_low 1966                                                handler.cc:  1966
| | | | <trans_commit_stmt 481                                                   transaction.cc:   481

| | | | >close_thread_tables                                                        sql_base.cc:  1583
| | | | <close_thread_tables 1749                                                   sql_base.cc:  1749

| | | | >stmt_causes_implicit_commit                                               sql_parse.cc:   278
| | | | <stmt_causes_implicit_commit 300                                           sql_parse.cc:   300
| | | | >trans_commit_implicit                                                   transaction.cc:   294
| | | | | | >ha_commit_low                                                           handler.cc:  1905
| | | | | | <ha_commit_low 1966                                                      handler.cc:  1966
| | | | <trans_commit_implicit 339                                               transaction.cc:   339

| | | >lex_end                                                                       sql_lex.cc:   528
| | | <lex_end 537                                                                   sql_lex.cc:   537

| | >send_statement_status                                                         sql_class.cc:  4770

@lujiashun
Copy link
Author

lujiashun commented Nov 1, 2022

SQL for debug and test

CREATE TABLE `test_alter_table_option_charset` (
 `c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint',
  `c_smallint` smallint DEFAULT NULL COMMENT 'smallint',
  `c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint',
  `c_int` int DEFAULT NULL COMMENT 'int',
  `c_bigint` bigint DEFAULT NULL COMMENT 'bigint',
  `c_float` float DEFAULT NULL COMMENT 'float',
  `c_double` double DEFAULT NULL COMMENT 'double',
  `c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal',
  `c_date` date DEFAULT NULL COMMENT 'date',
  `c_datetime` datetime DEFAULT NULL COMMENT 'datetime',
  `c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp',
  `c_time` time DEFAULT NULL COMMENT 'time',
  `c_char` char(10) DEFAULT NULL COMMENT 'char',
  `c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar',
  `c_blob` blob COMMENT 'blob',
  `c_text` text COMMENT 'text',
  `c_longblob` longblob COMMENT 'longblob'
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


ALTER TABLE test_alter_table_option_charset DEFAULT CHARACTER SET gbk;

alter table test_alter_table_option_charset  add column ex_column char(10);

CREATE TABLE `test_alter_table_option_charset_innodb` (
 `c_tinyint` tinyint DEFAULT NULL COMMENT 'tinyint',
  `c_smallint` smallint DEFAULT NULL COMMENT 'smallint',
  `c_mediumint` mediumint DEFAULT NULL COMMENT 'mediumint',
  `c_int` int DEFAULT NULL COMMENT 'int',
  `c_bigint` bigint DEFAULT NULL COMMENT 'bigint',
  `c_float` float DEFAULT NULL COMMENT 'float',
  `c_double` double DEFAULT NULL COMMENT 'double',
  `c_decimal` decimal(10,5) DEFAULT NULL COMMENT 'decimal',
  `c_date` date DEFAULT NULL COMMENT 'date',
  `c_datetime` datetime DEFAULT NULL COMMENT 'datetime',
  `c_timestamp` timestamp NULL DEFAULT NULL COMMENT 'timestamp',
  `c_time` time DEFAULT NULL COMMENT 'time',
  `c_char` char(10) DEFAULT NULL COMMENT 'char',
  `c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar',
  `c_blob` blob COMMENT 'blob',
  `c_text` text COMMENT 'text',
  `c_longblob` longblob COMMENT 'longblob'
) ENGINE=innodb DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


ALTER TABLE test_alter_table_option_charset_innodb DEFAULT CHARACTER SET gbk;

alter table test_alter_table_option_charset_innodb  add column ex_column char(10);

@lujiashun lujiashun moved this from Todo to In Progress in StoneDB for MySQL 5.7 Nov 1, 2022
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 1, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter;
2 add implement in inplace_alter_table;
3 add implement in commit_inplace_alter_table;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 1, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter;
2 add implement in inplace_alter_table;
3 add implement in commit_inplace_alter_table;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 1, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter;
2 add implement in inplace_alter_table;
3 add implement in commit_inplace_alter_table;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 1, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter;
2 add implement in inplace_alter_table;
3 add implement in commit_inplace_alter_table;
@lujiashun lujiashun changed the title feat(tianmu): support ‘ALTER TABLE t1 CHARACTER SET = ...’ clause feat(tianmu): support 'ALTER TABLE t1 CHARACTER SET = ...' clause Nov 1, 2022
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 1, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter;
2 add implement in inplace_alter_table;
3 add implement in commit_inplace_alter_table;
@lujiashun
Copy link
Author

lujiashun commented Nov 2, 2022

mysqld57.trace.alter_modify.log

tianmu_handler.cpp:       714: | | | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::open(const char*, int, uint)
ianmu_handler.cpp:        657: | | | | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::info(uint)
tianmu_handler.cpp:       698: | | | | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::info(uint) 698
tianmu_handler.cpp:       748: | | | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::open(const char*, int, uint) 748
tianmu_handler.cpp:      1134: | | | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1134: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1134: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1503: | | | | | | >virtual enum_alter_inplace_result Tianmu::handler::ha_tianmu::check_if_supported_inplace_alter(TABLE*, Alter_inplace_info*)
tianmu_handler.cpp:      1508: | | | | | | <virtual enum_alter_inplace_result Tianmu::handler::ha_tianmu::check_if_supported_inplace_alter(TABLE*, Alter_inplace_info*) 1508
tianmu_handler.cpp:       244: | | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int)
tianmu_handler.cpp:       299: | | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int) 299
tianmu_handler.cpp:      1231: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::create(const char*, TABLE*, HA_CREATE_INFO*)
tianmu_handler.cpp:      1241: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::create(const char*, TABLE*, HA_CREATE_INFO*) 1241
tianmu_handler.cpp:       714: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::open(const char*, int, uint)
tianmu_handler.cpp:       657: | | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::info(uint)
tianmu_handler.cpp:       698: | | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::info(uint) 698
tianmu_handler.cpp:       748: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::open(const char*, int, uint) 748
tianmu_handler.cpp:      1134: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:       244: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int)
tianmu_handler.cpp:       299: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int) 299
tianmu_handler.cpp:       657: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::info(uint)
tianmu_handler.cpp:       698: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::info(uint) 698
tianmu_handler.cpp:       967: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::rnd_init(bool)
tianmu_handler.cpp:      1024: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::rnd_init(bool) 1024
tianmu_handler.cpp:      1134: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1043: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::rnd_next(uchar*)
tianmu_handler.cpp:      1061: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::rnd_next(uchar*) 1061
tianmu_handler.cpp:       422: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::write_row(uchar*)
tianmu_handler.cpp:      1042: | | | | | | | | | info: interm.: 105.08300
tianmu_handler.cpp:      1046: | | | | | | | | | info: result: 105.083000
tianmu_handler.cpp:       455: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::write_row(uchar*) 455
tianmu_handler.cpp:      1043: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::rnd_next(uchar*)
tianmu_handler.cpp:      1050: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::rnd_next(uchar*) 1050
tianmu_handler.cpp:      1134: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1028: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::rnd_end()
tianmu_handler.cpp:      1477: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::reset()
tianmu_handler.cpp:      1498: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::reset() 1498
tianmu_handler.cpp:      1030: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::rnd_end() 1030
tianmu_handler_com.cpp:   120: | | | | | | | | | | | | >int Tianmu::handler::rcbase_commit(handlerton*, THD*, bool)
tianmu_handler_com.cpp:   162: | | | | | | | | | | | | <int Tianmu::handler::rcbase_commit(handlerton*, THD*, bool) 162
tianmu_handler.cpp:       244: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int)
tianmu_handler.cpp:       299: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int) 299
tianmu_handler.cpp:      1134: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:       767: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::close()
tianmu_handler.cpp:       768: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::close() 768
tianmu_handler.cpp:      1134: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:       244: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int)
tianmu_handler.cpp:       299: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::external_lock(THD*, int) 299
tianmu_handler.cpp:      1134: | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1134: | | | | | | | >virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function)
tianmu_handler.cpp:      1142: | | | | | | | <virtual int Tianmu::handler::ha_tianmu::extra(ha_extra_function) 1142
tianmu_handler.cpp:      1477: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::reset()
tianmu_handler.cpp:      1498: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::reset() 1498
tianmu_handler.cpp:       767: | | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::close()
tianmu_handler.cpp:       768: | | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::close() 768
tianmu_handler.cpp:      1191: | | | | | | | | >virtual int Tianmu::handler::ha_tianmu::delete_table(const char*)
tianmu_handler.cpp:      1204: | | | | | | | | <virtual int Tianmu::handler::ha_tianmu::delete_table(const char*) 1204

lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 3, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter of tianmu handler;
2 add implement in inplace_alter_table of tianmu handler;
3 add implement in commit_inplace_alter_table of tianmu handler;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 3, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter of tianmu handler;
2 add implement in inplace_alter_table of tianmu handler;
3 add implement in commit_inplace_alter_table of tianmu handler;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Nov 3, 2022
…toneatom#848)

[summary]
1 add implement in check_if_supported_inplace_alter of tianmu handler;
2 add implement in inplace_alter_table of tianmu handler;
3 add implement in commit_inplace_alter_table of tianmu handler;
mergify bot pushed a commit that referenced this issue Nov 3, 2022
)

[summary]
1 add implement in check_if_supported_inplace_alter of tianmu handler;
2 add implement in inplace_alter_table of tianmu handler;
3 add implement in commit_inplace_alter_table of tianmu handler;
@mergify mergify bot closed this as completed in #865 Nov 3, 2022
Repository owner moved this from In Progress to Done in StoneDB for MySQL 5.7 Nov 3, 2022
@Nliver Nliver added this to the StoneDB_5.7_v1.0.2 milestone Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-feature feature with good idea C-stonedb-5.7 associated with stonedb 5.7
Projects
Development

Successfully merging a pull request may close this issue.

2 participants