pingcap / tidb

TiDB is an open-source, cloud-native, distributed, MySQL-Compatible database for elastic scale and real-time analytics. Try AI-powered Chat2Query free at : https://tidbcloud.com/free-trial
https://pingcap.com
Apache License 2.0
36.27k stars 5.72k forks source link

ddl: fix the issue about create columns with wrong default when sql_mode is empty. (#52988) #53002

Closed ti-chi-bot closed 2 weeks ago

ti-chi-bot commented 2 weeks ago

This is an automated cherry-pick of #52988

What problem does this PR solve?

Issue Number: close https://github.com/pingcap/tidb/issues/52972, close https://github.com/pingcap/tidb/issues/51320

Problem Summary: Case1:

set @@sql_mode='STRICT_TRANS_TABLES';
drop table if exists t1;
create table t1(a int);
insert into t1 values(1);
alter table t1 add column(b tinyint default '11111111');

Case2:

set @@sql_mode='';
drop table if exists t1;
create table t1(a int);
insert into t1 values(1);
alter table t1 add column(b tinyint default '11111111');

Now the TiDB behaviors:

Now the MySQL(MySQL 5.7.44 and 8.0.18 MySQL) behaviors:

What changed and how does it work?

Check List

Tests

Side effects

Documentation

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None
ti-chi-bot[bot] commented 2 weeks ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, tangenta

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/pingcap/tidb/blob/release-8.1/OWNERS)~~ [Defined2014,tangenta] - ~~[pkg/ddl/OWNERS](https://github.com/pingcap/tidb/blob/release-8.1/pkg/ddl/OWNERS)~~ [tangenta] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
ti-chi-bot[bot] commented 2 weeks ago

[LGTM Timeline notifier]

Timeline: