Skip to content

Commit

Permalink
Schema: replace invalid default value to zero value under not strict …
Browse files Browse the repository at this point in the history
…sql mode (pingcap#8850)

close pingcap#8803
  • Loading branch information
Lloyd-Pottiger authored and ti-chi-bot committed Jul 29, 2024
1 parent 77c88f2 commit f159855
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/fullstack-test2/variables/set_sql_mode_ansi.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright 2024 PingCAP, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# use an empty string as the default value for decimal column
mysql> set sql_mode='ansi'; CREATE TABLE test.t (id int, i int default '1.1', f float default 'a', d decimal(10,2) default 'b', y year default 'f');

mysql> set sql_mode='ansi'; insert into test.t (id) values (1),(2),(3),(4);
mysql> alter table test.t set tiflash replica 1;

func> wait_table test t

mysql> set sql_mode='ansi'; insert into test.t (id) values (5),(6),(7),(8);
mysql> set sql_mode='ansi'; set session tidb_isolation_read_engines='tikv'; select * from test.t;
+------+------+------+------+------+
| id | i | f | d | y |
+------+------+------+------+------+
| 1 | 1 | 0 | 0.00 | 0000 |
| 2 | 1 | 0 | 0.00 | 0000 |
| 3 | 1 | 0 | 0.00 | 0000 |
| 4 | 1 | 0 | 0.00 | 0000 |
| 5 | 1 | 0 | 0.00 | 0000 |
| 6 | 1 | 0 | 0.00 | 0000 |
| 7 | 1 | 0 | 0.00 | 0000 |
| 8 | 1 | 0 | 0.00 | 0000 |
+------+------+------+------+------+
mysql> set sql_mode='ansi'; set session tidb_isolation_read_engines='tiflash'; select * from test.t;
+------+------+------+------+------+
| id | i | f | d | y |
+------+------+------+------+------+
| 1 | 1 | 0 | 0.00 | 0000 |
| 2 | 1 | 0 | 0.00 | 0000 |
| 3 | 1 | 0 | 0.00 | 0000 |
| 4 | 1 | 0 | 0.00 | 0000 |
| 5 | 1 | 0 | 0.00 | 0000 |
| 6 | 1 | 0 | 0.00 | 0000 |
| 7 | 1 | 0 | 0.00 | 0000 |
| 8 | 1 | 0 | 0.00 | 0000 |
+------+------+------+------+------+

mysql> drop table test.t;

0 comments on commit f159855

Please sign in to comment.