# Copyright 2023 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.

mysql> drop table if exists test.t1;
mysql> create table test.t1(c1 bigint);
mysql> insert into test.t1 values(0);
mysql> insert into test.t1 values(1);
mysql> insert into test.t1 values(44);
mysql> insert into test.t1 values(100);
mysql> insert into test.t1 values(-9223372036854775808);
mysql> insert into test.t1 values(9223372036854775807);
mysql> insert into test.t1 values(NULL);
mysql> alter table test.t1 set tiflash replica 1;
mysql> drop table if exists test.t2;
mysql> create table test.t2(c1 bigint unsigned);
mysql> insert into test.t2 values(0);
mysql> insert into test.t2 values(1);
mysql> insert into test.t2 values(44);
mysql> insert into test.t2 values(100);
mysql> insert into test.t2 values(18446744073709551615);
mysql> insert into test.t2 values(NULL);
mysql> alter table test.t2 set tiflash replica 1;

func> wait_table test t1
func> wait_table test t2

mysql> set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp = 1; select bin(c1) from test.t1;
+------------------------------------------------------------------+
| bin(c1)                                                          |
+------------------------------------------------------------------+
| 0                                                                |
| 1                                                                |
| 101100                                                           |
| 1100100                                                          |
| 1000000000000000000000000000000000000000000000000000000000000000 |
| 111111111111111111111111111111111111111111111111111111111111111  |
| NULL                                                             |
+------------------------------------------------------------------+
mysql> set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp = 1; select bin(c1) from test.t2;
+------------------------------------------------------------------+
| bin(c1)                                                          |
+------------------------------------------------------------------+
| 0                                                                |
| 1                                                                |
| 101100                                                           |
| 1100100                                                          |
| 1111111111111111111111111111111111111111111111111111111111111111 |
| NULL                                                             |
+------------------------------------------------------------------+

