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

bug: (Primary/Secondary)After an integer column is added,InnoDB defaults to 0, but tianmu defaults to null. #1187

Closed
3 tasks done
haitaoguan opened this issue Jan 3, 2023 · 6 comments
Assignees
Labels
A-bug Something isn't working B-DDL DDL related issues B-master-replica master/replica sync, replay B-storage data type, data storage, insert,update,delete, transactions prio: high High priority

Comments

@haitaoguan
Copy link
Collaborator

haitaoguan commented Jan 3, 2023

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

###MASTER
create table ttt(id int,name varchar(5));
insert into ttt values(1,'AAA'),(2,'BBB');
alter table ttt add column age int not null;

mysql> show create table ttt\G
*************************** 1. row ***************************
       Table: ttt
Create Table: CREATE TABLE `ttt` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(5) DEFAULT NULL,
  `age` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

mysql> select * from ttt;
+------+------+-----+
| id   | name | age |
+------+------+-----+
|    1 | AAA  |   0 |
|    2 | BBB  |   0 |
+------+------+-----+
2 rows in set (0.00 sec)


###SLAVE
mysql> show create table ttt\G
*************************** 1. row ***************************
       Table: ttt
Create Table: CREATE TABLE `ttt` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(5) DEFAULT NULL,
  `age` int(11) NOT NULL
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4
1 row in set (0.00 sec)

mysql> select * from ttt;
+------+------+-----+
| id   | name | age |
+------+------+-----+
|    1 | AAA  | NULL |
|    2 | BBB  | NULL |
+------+------+-----+
2 rows in set (0.00 sec)

Expected behavior

mysql> select * from ttt;
+------+------+-----+
| id   | name | age |
+------+------+-----+
|    1 | AAA  |   0 |
|    2 | BBB  |   0 |
+------+------+-----+
2 rows in set (0.00 sec)

How To Reproduce

No response

Environment

./mysqld Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
Branch name: stonedb-5.7-dev
Last commit ID: 0bc2cbe
Last commit time: Date: Fri Dec 30 17:46:55 2022 +0800
Build time: Date: Tue Jan 3 09:59:43 CST 2023

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@haitaoguan haitaoguan added the A-bug Something isn't working label Jan 3, 2023
@RingsC RingsC added this to the stonedb_5.7_v1.0.2 milestone Jan 6, 2023
@RingsC RingsC added the prio: high High priority label Jan 6, 2023
@lujiashun
Copy link

ACK

@wisehead
Copy link
Collaborator

wisehead commented Jan 9, 2023

I move this issue to 1.0.3 in order not to blocking 1.0.2 release. but this bug has a big imapct on SQL result, please fix it ASAP.

@lujiashun
Copy link

It seems "MANDATORY_TIANMU" of SQL_mode effects the result.

If SQL_mode is 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION', the result is:

mysql> select * from ttt;
+------+------+-----+
| id   | name | age |
+------+------+-----+
|    1 | AAA  | NULL |
|    2 | BBB  | NULL |
+------+------+-----+
2 rows in set (0.00 sec)

If SQL_MODE add "MANDATORY_TIANMU" , "STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU", the result is :

mysql> select * from ttt;
+------+------+-----+
| id   | name | age |
+------+------+-----+
|    1 | AAA  |   0 |
|    2 | BBB  |   0 |
+------+------+-----+
2 rows in set (0.01 sec)

@konghaiya
Copy link
Collaborator

This problem looks like #1074

@lujiashun
Copy link

lujiashun commented Jan 9, 2023

in function enum_alter_inplace_result ha_tianmu::check_if_supported_inplace_alter
1 if MANDATORY_TIANMU is added, ha_alter_info->handler_flags is 0x2000000080;
return value is HA_ALTER_INPLACE_NOT_SUPPORTED,
and SQL layer dealed with it (use copy mode), slow but the result is correct;
2 if MANDATORY_TIANMU is not added, ha_alter_info->handler_flags is 0x80,
return value is HA_ALTER_INPLACE_EXCLUSIVE_LOCK,
and tianmu layer will deal with it(use inplace mode), quic but the result is not correct,
3 What we should to do is
3.1 to remove the 0x200000000 flags(RECREATE_TABLE) even in MANDATORY_TIANMU mode;
3.2 to fix the bug that the tianmu mode does not support the NOT NULL value;

@wisehead wisehead added B-DDL DDL related issues B-master-replica master/replica sync, replay labels Jan 9, 2023
@lujiashun
Copy link

lujiashun commented Jan 10, 2023

1 For the scenario to add interger column not default NULL, We can modify the TianmuAttr::Create to fix the bug;
2 But If we want to enhance the feature to support add string column not defaut NULL ,We had to find another way to support it;
3 For now,Only to deal with interger, because it‘s the most frequency scenario, but implementation seems to be avaialble now;
4 If in the future, we need support string column not default null , implementation for interger need not to be adjusted.

lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 10, 2023
…InnoDB defaults to 0, but tianmu defaults to null. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 11, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 11, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 11, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 12, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 12, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 12, 2023
…e. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1. if field is integer type but not real type;
2. if field is integer type and also real type;
3. if field is not integer type;
@haitaoguan haitaoguan changed the title bug: between master/slave, after an integer column is added,InnoDB defaults to 0, but tianmu defaults to null bug: Primary/Secondary, after an integer column is added,InnoDB defaults to 0, but tianmu defaults to null Jan 12, 2023
@haitaoguan haitaoguan changed the title bug: Primary/Secondary, after an integer column is added,InnoDB defaults to 0, but tianmu defaults to null bug: (Primary/Secondary)After an integer column is added,InnoDB defaults to 0, but tianmu defaults to null. Jan 12, 2023
@hustjieke hustjieke added the B-storage data type, data storage, insert,update,delete, transactions label Jan 30, 2023
lujiashun pushed a commit to lujiashun/stonedb that referenced this issue Jan 31, 2023
…ue. (stoneatom#1187)

[summary]
check the default value of field,please see tianmu_attr.cpp for details:
1 if field is integer type but not real type;
2 if field is integer type and also real type;
2if field is not integer type;
@hustjieke hustjieke reopened this Apr 18, 2023
@hustjieke hustjieke self-assigned this Apr 18, 2023
@hustjieke hustjieke removed this from the StoneDB_5.7_v1.0.3 milestone Apr 18, 2023
@hustjieke hustjieke added this to the StoneDB_5.7_v1.0.4 milestone Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working B-DDL DDL related issues B-master-replica master/replica sync, replay B-storage data type, data storage, insert,update,delete, transactions prio: high High priority
Projects
Development

Successfully merging a pull request may close this issue.

6 participants