diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 000000000..5f7e03d87
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,13 @@
+# These are supported funding model platforms
+
+github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
+patreon: # Replace with a single Patreon username
+open_collective: stonedb
+ko_fi: # Replace with a single Ko-fi username
+tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
+community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
+liberapay: # Replace with a single Liberapay username
+issuehunt: # Replace with a single IssueHunt username
+otechie: # Replace with a single Otechie username
+lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
+custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml
index 8f721c7d6..fae9c5ac9 100644
--- a/.github/workflows/nightly.yml
+++ b/.github/workflows/nightly.yml
@@ -53,9 +53,7 @@ jobs:
-DDOWNLOAD_BOOST=0 \
-DWITH_BOOST=/usr/local/stonedb-boost/ \
-DDOWNLOAD_ROCKSDB=0 \
- -DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb/ \
-DWITH_MARISA=/usr/local/stonedb-marisa/ \
- -DDOWNLOAD_ROCKSDB=0 \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb && make -j`nproc` && make -j`nproc` install
tar -zcPvf ../pkg_outdir/stonedb57_nightly-`date +%y%m%d%H%M`.tar.gz /stonedb57/
@@ -68,21 +66,22 @@ jobs:
cd /stonedb57/install/mysql-test
./mysql-test-run.pl --suite=tianmu --nowarnings --force --nocheck-testcases --retry=0
- - name: output some vars
- id: vars
- env:
- SHA_EXT: sha256sum.txt
- run: |
- find pkg_outdir -type f \( -iname \*.deb -o -iname \*.rpm -o -iname \*.tar.gz \) -exec bash -c "sha256sum {} > {}.sha256sum.txt" \;
- subdir=$(date -u +%Y.%m.%d)
- echo "::set-output name=subdir::$subdir"
-
- - name: copy file via ssh password
- uses: appleboy/scp-action@master
- with:
- host: ${{ secrets.FILE_SERVER_HOST }}
- username: ${{ secrets.FILE_SERVER_USERNAME }}
- password: ${{ secrets.FILE_SERVER_PASSWORD }}
- port: ${{ secrets.FILE_SERVER_PORT }}
- source: "pkg_outdir/*"
- target: "${{ secrets.FILE_SERVER_DIR }}"
\ No newline at end of file
+ # TODO(): physical machine has been removed, we restart this funcion again in the future.
+ #- name: output some vars
+ # id: vars
+ # env:
+ # SHA_EXT: sha256sum.txt
+ # run: |
+ # find pkg_outdir -type f \( -iname \*.deb -o -iname \*.rpm -o -iname \*.tar.gz \) -exec bash -c "sha256sum {} > {}.sha256sum.txt" \;
+ # subdir=$(date -u +%Y.%m.%d)
+ # echo "::set-output name=subdir::$subdir"
+ #
+ #- name: copy file via ssh password
+ # uses: appleboy/scp-action@master
+ # with:
+ # host: ${{ secrets.FILE_SERVER_HOST }}
+ # username: ${{ secrets.FILE_SERVER_USERNAME }}
+ # password: ${{ secrets.FILE_SERVER_PASSWORD }}
+ # port: ${{ secrets.FILE_SERVER_PORT }}
+ # source: "pkg_outdir/*"
+ # target: "${{ secrets.FILE_SERVER_DIR }}"
diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml
index e4341ff96..cabfc9cac 100644
--- a/.github/workflows/pull_requests.yml
+++ b/.github/workflows/pull_requests.yml
@@ -82,21 +82,21 @@ jobs:
image: stoneatom/stonedb_buildenv:${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- with:
- ssh-strict: 'false'
- - name: compile stonedb
- id: compile
- run: |
+ - run: |
case ${{ matrix.os }} in
debian10_1.0.3)
- apt-get update && apt-get install curl lcov bc libssl-dev -y
+ apt-get --allow-releaseinfo-change update && apt-get install curl lcov bc libssl-dev -y
;;
centos7_1.0.3)
yum install curl lcov.noarch bc.x86_64 -y
rm -rf /usr/bin/gcc && ln -s /opt/rh/devtoolset-9/root/bin/gcc /usr/bin/gcc
;;
esac
-
+ #with:
+ # ssh-strict: 'false'
+ - name: compile stonedb
+ id: compile
+ run: |
mkdir build && cd build
git config --global --add safe.directory /__w/stonedb/stonedb
git fetch --tags
@@ -119,9 +119,7 @@ jobs:
-DDOWNLOAD_BOOST=0 \
-DWITH_BOOST=/usr/local/stonedb-boost/ \
-DDOWNLOAD_ROCKSDB=0 \
- -DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb/ \
-DWITH_MARISA=/usr/local/stonedb-marisa/ \
- -DDOWNLOAD_ROCKSDB=0 \
-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb -DENABLE_GCOV=1 && make -j`nproc` && make -j`nproc` install
- name: mtr test
@@ -130,13 +128,15 @@ jobs:
groupadd mysql && useradd -g mysql mysql
chown -R mysql:mysql /stonedb57 && chown -R mysql:mysql ./build
cd /stonedb57/install/mysql-test
- ./mysql-test-run.pl --suite=innodb --nowarnings --force --nocheck-testcases --retry=0 --defaults-file=/stonedb57/install/mysql-test/suite/innodb/include/my_innodb.cnf --do-test-list=/stonedb57/install/mysql-test/suite/innodb/include/innodb_testlist
+ ./mysql-test-run.pl --suite=innodb,main --mysqld=--default-storage-engine=innodb --nowarnings --force --nocheck-testcases --retry=0 --do-test-list=./suite/innodb/include/innodb_testlist --parallel=15
./mysql-test-run.pl --suite=tianmu --nowarnings --force --nocheck-testcases --retry=0 --parallel=10
- name: create coverage.info
run: |
+ cat codecov.yml | curl --data-binary @- https://codecov.io/validate
cd build
- lcov --capture --directory . --output-file coverage.info --test-name coverage
+ lcov --capture --directory . --output-file coverage.info --test-name coverage
- name: Codecov
- uses: codecov/codecov-action@v3.1.1
+ uses: codecov/codecov-action@v3.1.4
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f2826acef..56fd20b12 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,7 +12,7 @@ Check if `git` has been installed. If not, install it first.
1. Issue report: Open a regular [StoneDB issue](https://github.com/stoneatom/stonedb/issues/new/choose) to bind your pull request.
For more details about creating github issue concepts, see: [create an github issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/creating-an-issue)
2. Fork [StoneDB repo](https://github.com/stoneatom/stonedb) to your own account.
3. After add you own code, add unit test
-4. Do *make mtr test*
+4. Do *make mtr test* [How to add mtr test](https://stonedb.io/docs/getting-started/quick-add-mtr-test/)
5. After all test passed, use *clang-format* to formate your code according to [google c++ styleguide](https://google.github.io/styleguide/cppguide.html)
6. Submit a [Draft Pull Requests](https://github.blog/2019-02-14-introducing-draft-pull-requests/) and [write your PR description](https://github.com/stoneatom/stonedb/blob/stonedb-5.7/.github/pull_request_template.md)
For more details about pr concepts, see [creating-a-pull-request-from-a-fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork)
For more detail about draft pr concepts, see [draft-pull-request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests)
7. After all CI tests are passed, change the status to “Ready for review”.
diff --git a/Docs/02-getting-started/quick-add-mtr-test.md b/Docs/02-getting-started/quick-add-mtr-test.md
new file mode 100644
index 000000000..9725e4586
--- /dev/null
+++ b/Docs/02-getting-started/quick-add-mtr-test.md
@@ -0,0 +1,103 @@
+---
+id: quick-add-mtr-test
+sidebar_position: 3.6
+---
+
+# Qucik Add MTR Test
+
+## Add and Run a MTR test
+
+When you contribute your code into StoneDB, test your code in the meantime.
+
+Test cases are in the path \${StoneDB-Source-DIR}/mysql-test/suite/tianmu/.
+
+:::info
+`${StoneDB-Source-DIR}` is your StoneDB source code directory.
+
+`${TEST-PATH}=${StoneDB-Source-DIR}/mysql-test/suite/tianmu/` in the following context.
+:::
+
+### Step 1. Write your test file and result file
+
+Put your test file in the `${TEST-PATH}/t/` and result file in the `${TEST-PATH}/r/`.
+
+You can write your test cases like this.
+
+issue736.test
+```sql
+--source include/have_tianmu.inc
+use test;
+CREATE TABLE t1(col1 INT, col2 CHAR(5))ENGINE=tianmu;
+INSERT INTO t1 VALUES(NULL,''),(1,'a'),(1,'b'),(1,'c'),(2,'dd'),(3,'eee');
+INSERT INTO t1 VALUES(8,UNHEX('CEB2'));
+SELECT COUNT(DISTINCT col2) FROM t1;
+SELECT COUNT(DISTINCT col1) FROM t1;
+DROP TABLE t1;
+```
+
+Issue736.result
+```sql
+use test;
+CREATE TABLE t1(col1 INT, col2 CHAR(5))ENGINE=tianmu;
+INSERT INTO t1 VALUES(NULL,''),(1,'a'),(1,'b'),(1,'c'),(2,'dd'),(3,'eee');
+INSERT INTO t1 VALUES(8,UNHEX('CEB2'));
+SELECT COUNT(DISTINCT col2) FROM t1;
+COUNT(DISTINCT col2)
+7
+SELECT COUNT(DISTINCT col1) FROM t1;
+COUNT(DISTINCT col1)
+4
+DROP TABLE t1;
+
+```
+
+### Step 2. Compile your StoneDB.
+
+In this example, I compile my StoneDB in `${StoneDB-Source-DIR}/build/mysql8/` and install in `${StoneDB-Source-DIR}/build/install8/`
+
+ ```shell
+cd stonedb/build
+mkdir mysql8 install8
+# build your stonedb
+.........
+ ```
+
+### Step 3. Run your test.
+
+After installation, test cases will be moved into your installation directory.In this example, the path is `${StoneDB-Source-DIR}/build/install8/mysql-test`
+
+``` shell
+cd install8/mysql-test
+# run your test case. issue736 is my testcase.
+# run one case.
+./mtr --suite=tianmu testcase
+# run all cases.
+./mysql-test-run.pl --suite=tianmu --nowarnings --force --nocheck-testcases --parallel=10
+
+### Execute the test in this example.
+root@htap-dev-64-2:/stonedb/build/install8/mysql-test# ./mtr --suite=tianmu issue736
+Logging: ./mtr --suite=tianmu issue736
+MySQL Version 8.0.30
+Checking supported features
+ - Binaries are debug compiled
+Collecting tests
+Checking leftover processes
+Removing old var directory
+Creating var directory '/stonedb/build/install8/mysql-test/var'
+Installing system database
+Using parallel: 1
+
+==============================================================================
+ TEST NAME RESULT TIME (ms) COMMENT
+------------------------------------------------------------------------------
+worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
+[ 50%] tianmu.issue736 [ pass ] 78
+[100%] shutdown_report [ pass ]
+------------------------------------------------------------------------------
+The servers were restarted 0 times
+The servers were reinitialized 0 times
+Spent 0.078 of 35 seconds executing testcases
+
+Completed: All 2 tests were successful.
+
+```
\ No newline at end of file
diff --git a/Docs/02-getting-started/quick-deploy-in-docker.md b/Docs/02-getting-started/quick-deploy-in-docker.md
index 3953d5d18..5f7543a46 100644
--- a/Docs/02-getting-started/quick-deploy-in-docker.md
+++ b/Docs/02-getting-started/quick-deploy-in-docker.md
@@ -5,25 +5,30 @@ sidebar_position: 3.2
# Quick Deployment in a Docker Container
## Prerequisites
-The image of StoneDB is downloaded from Docker Hub.
-
+The image of StoneDB is downloaded from Docker Hub. You can read the Dockerhub documentation, which must be up to date.
[Docker Hub](https://hub.docker.com/r/stoneatom/stonedb)
## Procedure
-The username and password for login are **root** and **stonedb123**.
+The username and password for login are **root**. The **password** is customized by yourself.
+
+Make sure your CPU supports AVX
+
+```bash
+cat /proc/cpuinfo |grep avx
+```
### 1. Pull the image
Run the following command:
```bash
-docker pull stoneatom/stonedb:v1.0.2
+docker pull stoneatom/stonedb:v1.0.3
```
### 2. Run the image
Run the following command:
```bash
-docker run -p 13306:3306 -v $stonedb_volumn_dir/data/:/stonedb56/install/data/ -it -d stoneatom/stonedb:v0.1 /bin/bash
+docker run -p 3306:3306 -itd -v $YOU_DATA_DIR:/opt -e MYSQL_ROOT_PASSWORD='$YOU_PASSWORD' stoneatom/stonedb:v1.0.3
```
Altenatively, run the following command:
```bash
-docker run -p 13306:3306 -it -d stoneatom/stonedb:v0.1 /bin/bash
+docker run -p 3306:3306 -itd -e MYSQL_ROOT_PASSWORD='$YOU_PASSWORD' stoneatom/stonedb:v1.0.3
```
Parameter description:
@@ -32,16 +37,17 @@ Parameter description:
- **-i**: the interaction.
- **-t**: the terminal.
- **-d**: Do not enter the container upon startup. If you want to enter the container upon startup, run the docker exec command.
-### **3. Log in to StoneDB in the container**
+### 3. Log in to StoneDB in the container
```bash
# Obtain the Docker container ID.
docker ps
# Use the "cocker ps" command to obtain the container ID and enter the Docker container.
docker exec -it bash
-$ /stonedb56/install/bin/mysql -uroot -pstonedb123
+
+$ /opt/stonedb57/install/bin/mysql -uroot -p$YOU_PASSWORD
```
### **4. Log in to StoneDB using a third-party tool**
You can log in to StoneDB by using third-party tools such as mysql, Navicat, and DBeaver. The following code uses mysql as an example.
```shell
-mysql -h -uroot -pstonedb123 -P
+mysql -h -uroot -p$YOU_PASSWORD -P
```
\ No newline at end of file
diff --git a/Docs/02-getting-started/quick-deployment/deploy-stonedb-with-deb.md b/Docs/02-getting-started/quick-deployment/deploy-stonedb-with-deb.md
index 0c75f572c..c1021eb11 100644
--- a/Docs/02-getting-started/quick-deployment/deploy-stonedb-with-deb.md
+++ b/Docs/02-getting-started/quick-deployment/deploy-stonedb-with-deb.md
@@ -7,12 +7,12 @@ sidebar_position: 3.14
## Step 1. Install StoneDB
1. Download the StoneDB software package.
```sql
-wget https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.2-GA/stonedb-ce-5.7_v1.0.2.ubuntu.amd64.deb
+wget https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7_v1.0.3.ubuntu.amd64.deb
```
2. Use the DPKG command to install the DEB package.
```sql
-dpkg -i stonedb-ce-5.7_v1.0.2.ubuntu.amd64.deb
+dpkg -i stonedb-ce-5.7_v1.0.3.ubuntu.amd64.deb
```
:::info
If this step fails, run `ldd /opt/stonedb57/install/bin/mysqld | grep 'not found'` to check whether any dependent libraries are missing. If yes, run `source /opt/stonedb57/install/bin/sourceenv` and then retry this step.
diff --git a/Docs/02-getting-started/quick-deployment/quick-deployment-57.md b/Docs/02-getting-started/quick-deployment/quick-deployment-57.md
index 4f6711a32..5a753e6af 100644
--- a/Docs/02-getting-started/quick-deployment/quick-deployment-57.md
+++ b/Docs/02-getting-started/quick-deployment/quick-deployment-57.md
@@ -5,7 +5,10 @@ sidebar_position: 3.12
# Quick Deploy StoneDB-5.7
## 1. Download the installation package
-Click [here](https://static.stoneatom.com/custom/stonedb-ce-5.7-v1.0.3.el7.x86_64.tar.gz) to download the latest installation package of StoneDB.
+
+Click [Github](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7-v1.0.3.el7.x86_64.tar.gz) or [Gitee](https://gitee.com/StoneDB/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7-v1.0.3.el7.x86_64.tar.gz) to download the latest installation package of StoneDB.
+
+
:::info
To simplify deployment, the installation package provided here is pre-compiled to include all required dependencies.
:::
@@ -31,6 +34,8 @@ Users can start StoneDB in two ways: manual installation and automatic installat
```shell
groupadd mysql
useradd -g mysql mysql
+
+# Here are the optional execution statements
passwd mysql
```
### 4.2 Manually install StoneDB
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-56.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-56.md
index e3d370943..e2cd54095 100644
--- a/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-56.md
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-56.md
@@ -1,6 +1,6 @@
---
-id: compile-using-centos7-foe-56
-sidebar_position: 5.122
+id: compile-using-centos7-for-56
+sidebar_position: 5.123
---
# Compile StoneDB for MySQL5.6 on CentOS 7
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-57.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-57.md
index 627dbbe57..43a51c712 100644
--- a/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-57.md
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-57.md
@@ -1,6 +1,6 @@
---
id: compile-using-centos7-for-57
-sidebar_position: 5.121
+sidebar_position: 5.122
---
# Compile StoneDB for MySQL5.7 on CentOS 7
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-80.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-80.md
new file mode 100644
index 000000000..7a29c5c86
--- /dev/null
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-centos7/compile-using-centos7-for-80.md
@@ -0,0 +1,457 @@
+---
+id: compile-using-centos7-for-80
+sidebar_position: 5.121
+---
+
+# Compile StoneDB for MySQL8.0 on CentOS 7
+
+This topic describes how to compile StoneDB for MySQL8.0 on CentOS 7.
+
+## Precautions
+
+Ensure that the tools and third-party libraries used in your environment meet the following version requirements:
+
+ - GCC 11.2.0
+ - Make 3.82 or later
+ - CMake 3.7.2 or later
+ - marisa 0.77
+ - rocksdb 6.12.6
+ - boost 1.77
+
+ ## Procedure
+
+:::info
+Permission issues may occur when executing the following commands. You are advised to run the commands with the administrator permission
+:::
+
+:::tip
+All commands in this article are run under root privileges by default
+:::
+
+### Step 1. Install the dependencies
+
+```bash
+yum install -y tree
+yum install -y gcc
+yum install -y gcc-c++
+yum install -y libzstd-devel
+yum install -y make
+yum install -y ncurses
+yum install -y ncurses-devel
+yum install -y bison
+yum install -y libaio
+yum install -y perl
+yum install -y perl-DBI
+yum install -y perl-DBD-MySQL
+yum install -y perl-Time-HiRes
+yum install -y readline-devel
+yum install -y numactl
+yum install -y zlib
+yum install -y zlib-devel
+yum install -y openssl
+yum install -y openssl-devel
+yum install -y redhat-lsb-core
+yum install -y git
+yum install -y autoconf
+yum install -y automake
+yum install -y libtool
+yum install -y lrzsz
+yum install -y lz4
+yum install -y lz4-devel
+yum install -y snappy
+yum install -y snappy-devel
+yum install -y bzip2
+yum install -y bzip2-devel
+yum install -y zstd
+yum install -y libedit
+yum install -y libedit-devel
+yum install -y libaio-devel
+yum install -y libicu
+yum install -y libicu-devel
+yum install -y jemalloc-devel
+```
+
+:::info
+If your current yum source cannot find the required package, configure another epel source, the command is as follows:
+```bash
+yum install -y epel-release
+```
+:::
+
+### Step 2. Install GCC 11.2.0
+
+Before performing the follow-up steps, you must ensure the GCC version is 11.2.0.You can run the following command to check the GCC version.
+
+```bash
+gcc --version
+```
+
+If the version is earlier than 11.0.0, perform the following steps to upgrade GCC.
+
+#### 1. Install the SCL utility.
+
+```bash
+yum install centos-release-scl scl-utils-build -y
+```
+
+#### 2. Install GCC, GCC-C++, or BINUTILS of version 11.2.0.
+
+```bash
+yum install devtoolset-11-gcc devtoolset-11-gcc-c++ devtoolset-11-binutils -y
+```
+
+#### 3. Switch the version to 11.2.0.
+
+```bash
+scl enable devtoolset-11 bash
+```
+
+#### 4. Check that the version is switched to 11.2.0.
+
+```bash
+gcc --version
+```
+
+### Step 3. Install third-party libraries
+
+StoneDB is dependent on marisa, rocksdb, and boost. You are advised to specify paths for saving these libraries when you install them, instead of using the default paths.
+
+#### 1. Install cmake
+
+Check if the current cmake version meets the installation requirements.
+
+```bash
+cmake --version
+```
+
+If your cmake version >= 3.7.2, you don’t need to install cmake, otherwise follow the steps below to compile and install the appropriate version of cmake.
+
+```bash
+wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
+tar -zxvf cmake-3.7.2.tar.gz
+cd cmake-3.7.2
+./bootstrap && make && make install
+/usr/local/bin/cmake --version
+rm -rf /usr/bin/cmake
+ln -s /usr/local/bin/cmake /usr/bin/cmake
+cmake --version
+```
+
+:::info
+GCC11 will report a compilation error when compiling cmake-3.7.2. You can add `#include ` in the beginning of `cmake-3.7.2/Source/cmServerProtocol.cxx` to solve it.
+```c++
+#include
+#include
+#include
+#include
+```
+:::
+
+#### 2. Install make
+
+Check if the current make version meets the installation requirements.
+
+```bash
+make --version
+```
+
+If your make version >= 3.82, you don’t need to install make, otherwise follow the steps below to compile and install the appropriate version of make.
+
+```bash
+wget http://mirrors.ustc.edu.cn/gnu/make/make-4.3.tar.gz
+tar -zxvf make-4.3.tar.gz
+cd make-4.3
+./configure --prefix=/usr/local/make
+make && make install
+/usr/local/make/bin/make --version
+rm -rf /usr/bin/make
+ln -s /usr/local/make/bin/make /usr/bin/make
+make --version
+```
+
+#### 3. Install marisa
+
+```bash
+git clone https://github.com/s-yata/marisa-trie.git
+cd marisa-trie
+autoreconf -i
+./configure --enable-native-code --prefix=/usr/local/stonedb-marisa
+sudo make && make install
+```
+
+The installation directory of marisa in the example is `/usr/local/stonedb-marisa`. You can change it based on your actual conditions. After compiling and installing, the following directories and files are generated in `/usr/local/stonedb-marisa/lib`.
+
+```bash
+[root@localhost /usr/local/stonedb-marisa/lib]#ll
+total 6768
+-rw-r--r--. 1 root root 4977788 May 5 07:33 libmarisa.a
+-rwxr-xr-x. 1 root root 946 May 5 07:33 libmarisa.la
+lrwxrwxrwx. 1 root root 18 May 5 07:33 libmarisa.so -> libmarisa.so.0.0.0
+lrwxrwxrwx. 1 root root 18 May 5 07:33 libmarisa.so.0 -> libmarisa.so.0.0.0
+-rwxr-xr-x. 1 root root 1945584 May 5 07:33 libmarisa.so.0.0.0
+drwxr-xr-x. 2 root root 23 May 5 07:33 pkgconfig
+```
+
+#### 4. Install rocksdb
+
+```bash
+wget https://github.com/facebook/rocksdb/archive/refs/tags/v6.12.6.tar.gz
+tar -zxvf v6.12.6.tar.gz
+cd rocksdb-6.12.6
+
+cmake ./ \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr/local/stonedb-gcc-rocksdb \
+ -DCMAKE_INSTALL_LIBDIR=/usr/local/stonedb-gcc-rocksdb \
+ -DWITH_JEMALLOC=ON \
+ -DWITH_SNAPPY=ON \
+ -DWITH_LZ4=ON \
+ -DWITH_ZLIB=ON \
+ -DWITH_ZSTD=ON \
+ -DUSE_RTTI=ON \
+ -DROCKSDB_BUILD_SHARED=ON \
+ -DWITH_GFLAGS=OFF \
+ -DWITH_TOOLS=OFF \
+ -DWITH_BENCHMARK_TOOLS=OFF \
+ -DWITH_CORE_TOOLS=OFF
+
+make -j`nproc`
+make install -j`nproc`
+```
+
+The installation directory of rocksdb in the example is `/usr/local/stonedb-gcc-rocksdb`. You can change it based on your actual conditions. After compiling and installing, the following directories and files are generated in `/usr/local/stonedb-gcc-rocksdb`.
+
+```bash
+[root@localhost /usr/local/stonedb-gcc-rocksdb]#ll
+total 28736
+drwxr-xr-x. 3 root root 21 May 5 07:39 cmake
+drwxr-xr-x. 3 root root 21 May 5 07:39 include
+-rw-r--r--. 1 root root 20332942 May 5 07:38 librocksdb.a
+lrwxrwxrwx. 1 root root 15 May 5 07:39 librocksdb.so -> librocksdb.so.6
+lrwxrwxrwx. 1 root root 20 May 5 07:39 librocksdb.so.6 -> librocksdb.so.6.12.6
+-rwxr-xr-x. 1 root root 9086272 May 5 07:39 librocksdb.so.6.12.6
+```
+
+#### 5. Install boost
+
+```bash
+wget https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.gz
+tar -zxvf boost_1_77_0.tar.gz
+cd boost_1_77_0
+./bootstrap.sh --prefix=/usr/local/stonedb-boost177
+./b2 install --with=all
+```
+
+The installation directory of boost in the example is `/usr/local/stonedb-boost177`. You can change it based on your actual conditions. After compiling and installing, the following directories and files are generated in `/usr/local/stonedb-boost177/lib`.
+
+```bash
+[root@localhost /usr/local/stonedb-boost177/lib]#ll
+total 43412
+drwxr-xr-x. 50 root root 4096 May 5 08:34 cmake
+-rw-r--r--. 1 root root 14152 May 5 08:33 libboost_atomic.a
+lrwxrwxrwx. 1 root root 25 May 5 08:34 libboost_atomic.so -> libboost_atomic.so.1.77.0
+-rwxr-xr-x. 1 root root 27632 May 5 08:34 libboost_atomic.so.1.77.0
+-rw-r--r--. 1 root root 182964 May 5 08:33 libboost_chrono.a
+lrwxrwxrwx. 1 root root 25 May 5 08:34 libboost_chrono.so -> libboost_chrono.so.1.77.0
+-rwxr-xr-x. 1 root root 161408 May 5 08:34 libboost_chrono.so.1.77.0
+-rw-r--r--. 1 root root 172262 May 5 08:33 libboost_container.a
+lrwxrwxrwx. 1 root root 28 May 5 08:34 libboost_container.so -> libboost_container.so.1.77.0
+-rwxr-xr-x. 1 root root 116424 May 5 08:34 libboost_container.so.1.77.0
+-rw-r--r--. 1 root root 7202 May 5 08:33 libboost_context.a
+lrwxrwxrwx. 1 root root 26 May 5 08:34 libboost_context.so -> libboost_context.so.1.77.0
+-rwxr-xr-x. 1 root root 17024 May 5 08:34 libboost_context.so.1.77.0
+-rw-r--r--. 1 root root 284652 May 5 08:33 libboost_contract.a
+lrwxrwxrwx. 1 root root 27 May 5 08:34 libboost_contract.so -> libboost_contract.so.1.77.0
+-rwxr-xr-x. 1 root root 254408 May 5 08:34 libboost_contract.so.1.77.0
+-rw-r--r--. 1 root root 196532 May 5 08:33 libboost_coroutine.a
+lrwxrwxrwx. 1 root root 28 May 5 08:34 libboost_coroutine.so -> libboost_coroutine.so.1.77.0
+-rwxr-xr-x. 1 root root 84592 May 5 08:34 libboost_coroutine.so.1.77.0
+-rw-r--r--. 1 root root 1466 May 5 08:33 libboost_date_time.a
+lrwxrwxrwx. 1 root root 28 May 5 08:34 libboost_date_time.so -> libboost_date_time.so.1.77.0
+-rwxr-xr-x. 1 root root 15832 May 5 08:34 libboost_date_time.so.1.77.0
+-rw-r--r--. 1 root root 1662 May 5 08:34 libboost_exception.a
+-rw-r--r--. 1 root root 255586 May 5 08:33 libboost_fiber.a
+lrwxrwxrwx. 1 root root 24 May 5 08:32 libboost_fiber.so -> libboost_fiber.so.1.77.0
+-rwxr-xr-x. 1 root root 108704 May 5 08:32 libboost_fiber.so.1.77.0
+-rw-r--r--. 1 root root 520624 May 5 08:33 libboost_filesystem.a
+lrwxrwxrwx. 1 root root 29 May 5 08:32 libboost_filesystem.so -> libboost_filesystem.so.1.77.0
+-rwxr-xr-x. 1 root root 271120 May 5 08:32 libboost_filesystem.so.1.77.0
+-rw-r--r--. 1 root root 1039814 May 5 08:33 libboost_graph.a
+lrwxrwxrwx. 1 root root 24 May 5 08:32 libboost_graph.so -> libboost_graph.so.1.77.0
+-rwxr-xr-x. 1 root root 504312 May 5 08:32 libboost_graph.so.1.77.0
+-rw-r--r--. 1 root root 263000 May 5 08:33 libboost_iostreams.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_iostreams.so -> libboost_iostreams.so.1.77.0
+-rwxr-xr-x. 1 root root 124640 May 5 08:32 libboost_iostreams.so.1.77.0
+-rw-r--r--. 1 root root 491206 May 5 08:33 libboost_json.a
+lrwxrwxrwx. 1 root root 23 May 5 08:32 libboost_json.so -> libboost_json.so.1.77.0
+-rwxr-xr-x. 1 root root 426856 May 5 08:32 libboost_json.so.1.77.0
+-rw-r--r--. 1 root root 3221762 May 5 08:33 libboost_locale.a
+lrwxrwxrwx. 1 root root 25 May 5 08:32 libboost_locale.so -> libboost_locale.so.1.77.0
+-rwxr-xr-x. 1 root root 1088632 May 5 08:32 libboost_locale.so.1.77.0
+-rw-r--r--. 1 root root 3715884 May 5 08:33 libboost_log.a
+-rw-r--r--. 1 root root 3141980 May 5 08:33 libboost_log_setup.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_log_setup.so -> libboost_log_setup.so.1.77.0
+-rwxr-xr-x. 1 root root 1363320 May 5 08:32 libboost_log_setup.so.1.77.0
+lrwxrwxrwx. 1 root root 22 May 5 08:32 libboost_log.so -> libboost_log.so.1.77.0
+-rwxr-xr-x. 1 root root 1325072 May 5 08:32 libboost_log.so.1.77.0
+-rw-r--r--. 1 root root 201806 May 5 08:33 libboost_math_c99.a
+-rw-r--r--. 1 root root 185294 May 5 08:33 libboost_math_c99f.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_math_c99f.so -> libboost_math_c99f.so.1.77.0
+-rwxr-xr-x. 1 root root 71888 May 5 08:32 libboost_math_c99f.so.1.77.0
+-rw-r--r--. 1 root root 184610 May 5 08:33 libboost_math_c99l.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_math_c99l.so -> libboost_math_c99l.so.1.77.0
+-rwxr-xr-x. 1 root root 70640 May 5 08:32 libboost_math_c99l.so.1.77.0
+lrwxrwxrwx. 1 root root 27 May 5 08:32 libboost_math_c99.so -> libboost_math_c99.so.1.77.0
+-rwxr-xr-x. 1 root root 73640 May 5 08:32 libboost_math_c99.so.1.77.0
+-rw-r--r--. 1 root root 1168442 May 5 08:33 libboost_math_tr1.a
+-rw-r--r--. 1 root root 1190212 May 5 08:33 libboost_math_tr1f.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_math_tr1f.so -> libboost_math_tr1f.so.1.77.0
+-rwxr-xr-x. 1 root root 278584 May 5 08:32 libboost_math_tr1f.so.1.77.0
+-rw-r--r--. 1 root root 1137874 May 5 08:33 libboost_math_tr1l.a
+lrwxrwxrwx. 1 root root 28 May 5 08:32 libboost_math_tr1l.so -> libboost_math_tr1l.so.1.77.0
+-rwxr-xr-x. 1 root root 289168 May 5 08:32 libboost_math_tr1l.so.1.77.0
+lrwxrwxrwx. 1 root root 27 May 5 08:32 libboost_math_tr1.so -> libboost_math_tr1.so.1.77.0
+-rwxr-xr-x. 1 root root 294848 May 5 08:32 libboost_math_tr1.so.1.77.0
+-rw-r--r--. 1 root root 22466 May 5 08:33 libboost_nowide.a
+lrwxrwxrwx. 1 root root 25 May 5 08:32 libboost_nowide.so -> libboost_nowide.so.1.77.0
+-rwxr-xr-x. 1 root root 24712 May 5 08:32 libboost_nowide.so.1.77.0
+-rw-r--r--. 1 root root 176758 May 5 08:34 libboost_prg_exec_monitor.a
+lrwxrwxrwx. 1 root root 35 May 5 08:32 libboost_prg_exec_monitor.so -> libboost_prg_exec_monitor.so.1.77.0
+-rwxr-xr-x. 1 root root 195640 May 5 08:32 libboost_prg_exec_monitor.so.1.77.0
+-rw-r--r--. 1 root root 1319422 May 5 08:33 libboost_program_options.a
+lrwxrwxrwx. 1 root root 34 May 5 08:32 libboost_program_options.so -> libboost_program_options.so.1.77.0
+-rwxr-xr-x. 1 root root 651768 May 5 08:32 libboost_program_options.so.1.77.0
+-rw-r--r--. 1 root root 63270 May 5 08:33 libboost_random.a
+lrwxrwxrwx. 1 root root 25 May 5 08:32 libboost_random.so -> libboost_random.so.1.77.0
+-rwxr-xr-x. 1 root root 152064 May 5 08:32 libboost_random.so.1.77.0
+-rw-r--r--. 1 root root 797262 May 5 08:33 libboost_regex.a
+lrwxrwxrwx. 1 root root 24 May 5 08:32 libboost_regex.so -> libboost_regex.so.1.77.0
+-rwxr-xr-x. 1 root root 473968 May 5 08:32 libboost_regex.so.1.77.0
+-rw-r--r--. 1 root root 1177984 May 5 08:34 libboost_serialization.a
+lrwxrwxrwx. 1 root root 32 May 5 08:32 libboost_serialization.so -> libboost_serialization.so.1.77.0
+-rwxr-xr-x. 1 root root 457280 May 5 08:32 libboost_serialization.so.1.77.0
+-rw-r--r--. 1 root root 23484 May 5 08:34 libboost_stacktrace_addr2line.a
+lrwxrwxrwx. 1 root root 39 May 5 08:32 libboost_stacktrace_addr2line.so -> libboost_stacktrace_addr2line.so.1.77.0
+-rwxr-xr-x. 1 root root 125792 May 5 08:32 libboost_stacktrace_addr2line.so.1.77.0
+-rw-r--r--. 1 root root 13906 May 5 08:34 libboost_stacktrace_basic.a
+lrwxrwxrwx. 1 root root 35 May 5 08:32 libboost_stacktrace_basic.so -> libboost_stacktrace_basic.so.1.77.0
+-rwxr-xr-x. 1 root root 22456 May 5 08:32 libboost_stacktrace_basic.so.1.77.0
+-rw-r--r--. 1 root root 2938 May 5 08:33 libboost_stacktrace_noop.a
+lrwxrwxrwx. 1 root root 34 May 5 08:32 libboost_stacktrace_noop.so -> libboost_stacktrace_noop.so.1.77.0
+-rwxr-xr-x. 1 root root 16376 May 5 08:32 libboost_stacktrace_noop.so.1.77.0
+-rw-r--r--. 1 root root 1436 May 5 08:33 libboost_system.a
+lrwxrwxrwx. 1 root root 25 May 5 08:32 libboost_system.so -> libboost_system.so.1.77.0
+-rwxr-xr-x. 1 root root 15816 May 5 08:32 libboost_system.so.1.77.0
+-rw-r--r--. 1 root root 2331082 May 5 08:33 libboost_test_exec_monitor.a
+-rw-r--r--. 1 root root 322240 May 5 08:33 libboost_thread.a
+lrwxrwxrwx. 1 root root 25 May 5 08:34 libboost_thread.so -> libboost_thread.so.1.77.0
+-rwxr-xr-x. 1 root root 260920 May 5 08:34 libboost_thread.so.1.77.0
+-rw-r--r--. 1 root root 53892 May 5 08:34 libboost_timer.a
+lrwxrwxrwx. 1 root root 24 May 5 08:33 libboost_timer.so -> libboost_timer.so.1.77.0
+-rwxr-xr-x. 1 root root 45472 May 5 08:33 libboost_timer.so.1.77.0
+-rw-r--r--. 1 root root 123412 May 5 08:34 libboost_type_erasure.a
+lrwxrwxrwx. 1 root root 31 May 5 08:33 libboost_type_erasure.so -> libboost_type_erasure.so.1.77.0
+-rwxr-xr-x. 1 root root 76952 May 5 08:33 libboost_type_erasure.so.1.77.0
+-rw-r--r--. 1 root root 2312932 May 5 08:34 libboost_unit_test_framework.a
+lrwxrwxrwx. 1 root root 38 May 5 08:33 libboost_unit_test_framework.so -> libboost_unit_test_framework.so.1.77.0
+-rwxr-xr-x. 1 root root 1028120 May 5 08:33 libboost_unit_test_framework.so.1.77.0
+-rw-r--r--. 1 root root 4746706 May 5 08:34 libboost_wave.a
+lrwxrwxrwx. 1 root root 23 May 5 08:33 libboost_wave.so -> libboost_wave.so.1.77.0
+-rwxr-xr-x. 1 root root 1599392 May 5 08:33 libboost_wave.so.1.77.0
+-rw-r--r--. 1 root root 779892 May 5 08:34 libboost_wserialization.a
+lrwxrwxrwx. 1 root root 33 May 5 08:33 libboost_wserialization.so -> libboost_wserialization.so.1.77.0
+-rwxr-xr-x. 1 root root 320040 May 5 08:33 libboost_wserialization.so.1.77.0
+```
+
+#### 6. Install gtest
+
+```bash
+git clone https://github.com/google/googletest.git -b release-1.12.0
+cd googletest
+mkdir build
+cd build
+cmake .. -DBUILD_GMOCK=OFF
+make
+make install
+```
+
+Install in `/usr/local/` by default.
+
+```bash
+ls /usr/local/include/
+...... gtest
+ls /usr/local/lib/ # 32-bit os
+ls /usr/local/lib64/ # 64-bit os
+...... cmake libgtest.a libgtest_main.a
+```
+
+### Step 4. Compile StoneDB
+
+Currently, StoneDB has three branches: StoneDB-5.6 (for MySQL 5.6)、 StoneDB-5.7 (for MySQL 5.7) and StoneDB-8.0 (for MySQL 8.0). The link provided in this topic is to the source code package of StoneDB-8.0. In the following example, the source code package is saved to the root directory.
+
+```bash
+cd /
+git clone -b stonedb-8.0-dev https://github.com/stoneatom/stonedb.git
+```
+
+Before compilation, modify the compilation script as follows:
+
+:::info
+You cna change the installation directory of StoneDB based on your actual conditions. In this example, `/stonedb/`is used. Remember to change the installation directories of marisa, rocksdb, and boost based on your actual conditions.
+:::
+
+```bash
+cd stonedb
+mkdir build
+cd build
+mkdir install8 mysql8
+cd mysql8
+cmake ../../ \
+-DCMAKE_BUILD_TYPE=Debug \
+-DCMAKE_INSTALL_PREFIX=/stonedb/build/install8 \
+-DMYSQL_DATADIR=/stonedb/build/install8/data \
+-DSYSCONFDIR=/stonedb/build/install8 \
+-DMYSQL_UNIX_ADDR=/stonedb/build/install8/tmp/mysql.sock \
+-DWITH_BOOST=/usr/local/stonedb-boost177 \
+-DWITH_MARISA=/usr/local/stonedb-marisa \
+-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb \
+-DDOWNLOAD_BOOST=0
+make -j`nproc`
+make install -j`nproc`
+```
+
+### Step 5. Start StoneDB
+
+You need to manually create directories, and then initialize and start StoneDB. You also need to configure parameters in file my.cnf, including the installation directories and port.
+
+```bash
+cd ../install8
+
+### Create directories.
+mkdir data binlog log tmp redolog undolog
+
+### Configure parameters in my.cnf.
+cp ../../scripts/my.cnf.sample my.cnf
+sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf
+
+### Initialize StoneDB.
+./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
+
+### Start StoneDB.
+./bin/mysqld --user=root &
+
+### Stop StoneDB
+./bin/mysqladmin -uroot shutdown
+```
+
+### Step 6. Login to StoneDB
+
+```bash
+./bin/mysql -uroot
+### set the password of user root to stonedb123
+mysql> alter user 'root'@'localhost' identified by 'stonedb123';
+Query OK, 0 rows affected
+### allow remote access
+mysql> update user set host='%' where user='root';
+```
+
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/_category_.json b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/_category_.json
new file mode 100644
index 000000000..355c6e68a
--- /dev/null
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/_category_.json
@@ -0,0 +1,5 @@
+{
+ "position": 5.16,
+ "label": "Compile StoneDB in Docker",
+ "collapsible": true
+}
\ No newline at end of file
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-docker.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-56-57.md
similarity index 70%
rename from Docs/04-developer-guide/00-compiling-methods/compile-using-docker.md
rename to Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-56-57.md
index bab1768b3..45dbd5c66 100644
--- a/Docs/04-developer-guide/00-compiling-methods/compile-using-docker.md
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-56-57.md
@@ -1,9 +1,9 @@
---
-id: compile-using-docker
-sidebar_position: 5.15
+id: compile-using-docker-for-56-57
+sidebar_position: 5.161
---
-# Compile StoneDB in a Docker Container
+# Compile StoneDB 5.7 in a Docker Container
## Introduction
Compiling StoneDB on a physical server requires installation of third-party repositories, which is complicated. In addition, if the OS in your environment is Fedora or Ubuntu, you also need to install many dependencies. We recommend that you compile StoneDB in a Docker container. After StoneDB is compiled, you can directly run StoneDB in the container or copy the compilation files to your environment.
## Prerequisites
@@ -159,72 +159,80 @@ After the `make` commands are successful, you can choose either to compress the
### Compress compilation files to a TAR file
```bash
# Compress the 'home' folder to a TAR file and mount the TAR file to a directory outside the container.
-[root@06f1f385d3b3 build]# tar -zcPvf /home/stonedb56.tar.gz /stonedb56/
+[root@06f1f385d3b3 build]# tar -zcPvf /home/stonedb57.tar.gz /stonedb57/
```
### Directly use StoneDB in the container
-You can refer to [Quick Deployment](.../../../../02-getting-started/quick-deployment/quick-deployment-56.md) or the following code to deploy and use StoneDB in the container.
-```bash
-[root@06f1f385d3b3 build]# cd /stonedb56/install/
-
-[root@06f1f385d3b3 install]# groupadd mysql
-
-[root@06f1f385d3b3 install]# useradd -g mysql mysql
-
-[root@06f1f385d3b3 install]# ll
-total 180
--rw-r--r--. 1 root root 17987 Jun 8 03:41 COPYING
--rw-r--r--. 1 root root 102986 Jun 8 03:41 INSTALL-BINARY
--rw-r--r--. 1 root root 2615 Jun 8 03:41 README
-drwxr-xr-x. 2 root root 4096 Jun 8 06:16 bin
-drwxr-xr-x. 3 root root 18 Jun 8 06:16 data
-drwxr-xr-x. 2 root root 55 Jun 8 06:16 docs
-drwxr-xr-x. 3 root root 4096 Jun 8 06:16 include
--rwxr-xr-x. 1 root root 267 Jun 8 03:41 install.sh
-drwxr-xr-x. 3 root root 272 Jun 8 06:16 lib
-drwxr-xr-x. 4 root root 30 Jun 8 06:16 man
-drwxr-xr-x. 10 root root 4096 Jun 8 06:16 mysql-test
--rwxr-xr-x. 1 root root 12516 Jun 8 03:41 mysql_server
--rwxr-xr-x. 1 root root 764 Jun 8 03:41 reinstall.sh
-drwxr-xr-x. 2 root root 57 Jun 8 06:16 scripts
-drwxr-xr-x. 28 root root 4096 Jun 8 06:16 share
-drwxr-xr-x. 4 root root 4096 Jun 8 06:16 sql-bench
--rw-r--r--. 1 root root 5526 Jun 8 03:41 stonedb.cnf
-drwxr-xr-x. 2 root root 136 Jun 8 06:16 support-files
-[root@06f1f385d3b3 install]# ./reinstall.sh
-
-...
-
-# If the following information is returned, StoneDB is started.
-+ log_success_msg
-+ /etc/redhat-lsb/lsb_log_message success
-/etc/redhat-lsb/lsb_log_message: line 3: /etc/init.d/functions: No such file or directory
-/etc/redhat-lsb/lsb_log_message: line 11: success: command not found
-
-+ return 0
-+ return_value=0
-+ test -w /var/lock/subsys
-+ touch /var/lock/subsys/mysql
-+ exit 0
-
-
-# Reset the password of local user 'root'.
-[root@06f1f385d3b3 install]# /stonedb56/install/bin/mysqladmin flush-privileges -u root password "*******"
-Warning: Using a password on the command line interface can be insecure.
-# Create a username and password for remote connection.
-[root@06f1f385d3b3 install]# /stonedb56/install/bin/mysql -uroot -p*******
-Warning: Using a password on the command line interface can be insecure.
-Welcome to the MySQL monitor. Commands end with ; or \g.
-Your MySQL connection id is 5
-Server version: 5.6.24-StoneDB-log build-
+You can refer to [Quick Deployment](.../../../../02-getting-started/quick-deployment/quick-deployment-57.md) or the following code to deploy and use StoneDB in the container.
+### 1. Create an account
+```shell
+groupadd mysql
+useradd -g mysql mysql
+
+# Here are the optional execution statements
+passwd mysql
+```
+### 2. Manually install StoneDB
+You need to manually create directories, configure the parameter file, and then initialize and start StoneDB.
+```shell
+### Create directories.
+mkdir -p /stonedb57/install/data
+mkdir -p /stonedb57/install/binlog
+mkdir -p /stonedb57/install/log
+mkdir -p /stonedb57/install/tmp
+mkdir -p /stonedb57/install/redolog
+mkdir -p /stonedb57/install/undolog
+chown -R mysql:mysql /stonedb57
+
+### Configure my.cnf.
+mv my.cnf my.cnf.bak
+vim /stonedb57/install/my.cnf
+[mysqld]
+port = 3306
+socket = /stonedb57/install/tmp/mysql.sock
+basedir = /stonedb57/install
+datadir = /stonedb57/install/data
+pid_file = /stonedb57/install/data/mysqld.pid
+log_error = /stonedb57/install/log/mysqld.log
+innodb_log_group_home_dir = /stonedb57/install/redolog/
+innodb_undo_directory = /stonedb57/install/undolog/
+
+chown -R mysql:mysql /stonedb57/install/my.cnf
+
+### Initialize StoneDB.
+/stonedb57/install/bin/mysqld --defaults-file=/stonedb57/install/my.cnf --initialize --user=mysql
+
+### Start StoneDB.
+/stonedb57/install/bin/mysqld_safe --defaults-file=/stonedb57/install/my.cnf --user=mysql &
+```
+### 3. Automatically install StoneDB
+The process of executing the **reinstall.sh** script is to initialize and start the StoneDB.
+```shell
+cd /stonedb57/install
+./reinstall.sh
+```
+:::info
+Differences between **reinstall.sh** and **install.sh**:
-Copyright (c) 2000, 2022 StoneAtom Group Holding Limited
-Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+- **reinstall.sh** is the script for automatic installation. When the script is being executed, directories are created, and StoneDB is initialized and started. Therefore, do not execute the script unless for the initial startup of StoneDB. Otherwise, all directories will be deleted and StoneDB will be initialized again.
+- **install.sh** is the script for manual installation. You can specify the installation directories based on your needs and then execute the script. Same as reinstall.sh, when the script is being executed, directories are created, and StoneDB is initialized and started. Therefore, do not execute the script unless for the initial startup. Otherwise, all directories will be deleted and StoneDB will be initialized again.
+ :::
-mysql> grant all ON *.* to root@'%' identified by '********';
-Query OK, 0 rows affected (0.00 sec)
+### 4. Log in to StoneDB
+```shell
+cat /stonedb57/install/log/mysqld.log |grep password
+[Note] A temporary password is generated for root@localhost: ceMuEuj6l4+!
-mysql> flush privileges;
-Query OK, 0 rows affected (0.00 sec)
+/stonedb57/install/bin/mysql -uroot -p -S /stonedb57/install/tmp/mysql.sock
+mysql: [Warning] Using a password on the command line interface can be insecure.
+Welcome to the MySQL monitor. Commands end with ; or \g.
+Your MySQL connection id is 2
+Server version: 5.7.36-StoneDB-debug-log build-
-```
-After you start StoneDB in the container, you can log in to and use StoneDB or run the `docker run -p ` command to connect to StoneDB.
+Copyright (c) 2021, 2022 StoneAtom Group Holding Limited
+Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
+
+mysql> alter user 'root'@'localhost' identified by 'stonedb123';
+# Allow root user to log in remotely
+mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'stonedb123' WITH GRANT OPTION;
+mysql> FLUSH PRIVILEGES;
+```
\ No newline at end of file
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-80.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-80.md
new file mode 100644
index 000000000..7b9bd2f4e
--- /dev/null
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-docker/compile-using-docker-for-80.md
@@ -0,0 +1,83 @@
+---
+id: compile-using-docker-for-80
+sidebar_position: 5.162
+---
+
+# Compile StoneDB 8.0 in a Docker Container
+## Introduction
+Compiling StoneDB on a physical server requires installation of third-party repositories, which is complicated. In addition, if the OS in your environment is Fedora or Ubuntu, you also need to install many dependencies. We recommend that you compile StoneDB in a Docker container. After StoneDB is compiled, you can directly run StoneDB in the container or copy the compilation files to your environment.
+
+## Prerequisites
+Docker has been installed. For information about how to install Docker, visit [https://docs.docker.com/engine/install/ubuntu/](https://docs.docker.com/engine/install/ubuntu/).
+
+## Procedure
+The url of our image:[stoneatom/stonedb80_buildenv](https://hub.docker.com/r/stoneatom/stonedb80_buildenv)
+
+### Pull image from dockerhub
+```bash
+$ docker pull stoneatom/stonedb80_buildenv
+# show all images
+$ docker images
+REPOSITORY TAG IMAGE ID CREATED SIZE
+stoneatom/stonedb80_buildenv latest cc644347ffed 7 months ago 771MB
+```
+
+### Launch a container & Get into it
+```bash
+# docker run parameter description
+# -v Directory mounting. Specify the directory on the host first and then the directory in the container.
+# -p Port mapping. Specify the port on the host first and then the port in the container.It can allow connection
+# from outside the container.
+$ docker run -v /home/src/:/home/ -p 23306:3306 -it stoneatom/stonedb80_buildenv /bin/bash
+```
+### Create an account
+```bash
+groupadd mysql
+useradd -g mysql mysql
+passwd mysql
+```
+### Download source code & Compile and Install
+```bash
+root@71a1384e5ee3:/home# git clone -b stonedb-8.0-dev https://github.com/stoneatom/stonedb.git
+
+root@fb0bf0c54de0:/home# cd stonedb
+root@fb0bf0c54de0:/home/stonedb# mkdir build
+root@fb0bf0c54de0:/home/stonedb# cd build
+# The intall directory here is /stonedb8/install,you can change it by yourself
+root@fb0bf0c54de0:/home/stonedb/build# cmake .. \
+-DCMAKE_BUILD_TYPE=Release \
+-DCMAKE_INSTALL_PREFIX=/stonedb8/install \
+-DMYSQL_DATADIR=/stonedb8/install/data \
+-DSYSCONFDIR=/stonedb8/install \
+-DMYSQL_UNIX_ADDR=/stonedb8/install/tmp/mysql.sock \
+-DWITH_BOOST=/usr/local/stonedb-boost \
+-DWITH_MARISA=/usr/local/stonedb-marisa \
+-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb
+
+root@fb0bf0c54de0:/home/stonedb/build# make -j `nproc` && make install -j`nproc`
+```
+
+### Initialize & Start StoneDB
+```bash
+root@fb0bf0c54de0:/home/stonedb/build# cd /stonedb8/install
+# Create directories
+root@fb0bf0c54de0:/stonedb8/install# mkdir data binlog log tmp redolog undolog
+# Configure parameters in my.cnf
+root@fb0bf0c54de0:/stonedb8/install# cp /home/stonedb/scripts/my.cnf.sample my.cnf
+root@fb0bf0c54de0:/stonedb8/install# sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf
+# Initialize StoneDB.
+root@fb0bf0c54de0:/stonedb8/install# chown -R mysql:mysql /stonedb8/install
+root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure --user=mysql
+# Start StoneDB
+root@fb0bf0c54de0:/stonedb8/install# ./bin/mysqld --user=mysql &
+```
+
+### Login StoneDB
+```bash
+root@fb0bf0c54de0:/stonedb8/install# ./bin/mysql -uroot
+# Set the password of user root to stonedb123
+mysql> alter user 'root'@'localhost' identified by 'stonedb123';
+# Allow remote access
+mysql> use mysql;
+mysql> update user set host='%' where user='root';
+```
\ No newline at end of file
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-56.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-56.md
index f07c4cc80..ed5edf338 100644
--- a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-56.md
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-56.md
@@ -50,7 +50,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
-sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-57.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-57.md
index f5d099168..ea1139da2 100644
--- a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-57.md
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2004/compile-using-ubuntu2004-for-57.md
@@ -51,7 +51,6 @@ sudo apt install -y libaio-dev
sudo apt install -y libncurses5-dev
sudo apt install -y libreadline-dev
sudo apt install -y libpam0g-dev
-sudo apt install -y zlib1g-dev
sudo apt install -y libicu-dev
sudo apt install -y libboost-dev
sudo apt install -y libgflags-dev
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/_category_.json b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/_category_.json
new file mode 100644
index 000000000..1becabb50
--- /dev/null
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/_category_.json
@@ -0,0 +1,5 @@
+{
+ "position": 5.15,
+ "label": "Compile StoneDB 8.0 on Ubuntu22.04",
+ "collapsible": true
+}
\ No newline at end of file
diff --git a/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/compile-using-ubuntu2204-for-80.md b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/compile-using-ubuntu2204-for-80.md
new file mode 100644
index 000000000..eb90eb299
--- /dev/null
+++ b/Docs/04-developer-guide/00-compiling-methods/compile-using-ubuntu2204/compile-using-ubuntu2204-for-80.md
@@ -0,0 +1,335 @@
+---
+id: compile-using-ubuntu22.04-for-80
+sidebar_position: 5.151
+---
+
+# Compile StoneDB for MySQL8.0 on Ubuntu 22.04
+
+This topic describes how to compile StoneDB for MySQL8.0 on Ubuntu 22.04.
+
+## Precautions
+
+Ensure that the tools and third-party libraries used in your environment meet the following version requirements:
+* GCC 9.4.0
+* Make 3.82 or later
+* CMake 3.7.2 or later
+* marisa 0.77
+* RocksDB 6.12.6
+* Boost 1.77
+
+## Procedure
+:::info
+When executing following commands, you may run into peimission issues, so using 'sudo' is a good idea.
+:::
+### Step 1. Install the dependencies
+
+```bash
+sudo apt install -y gcc
+sudo apt install -y g++
+sudo apt install -y make
+sudo apt install -y cmake
+sudo apt install -y build-essential
+sudo apt install -y autoconf
+sudo apt install -y tree
+sudo apt install -y bison
+sudo apt install -y git
+sudo apt install -y libtool
+sudo apt install -y numactl
+sudo apt install -y python3-dev
+sudo apt install -y openssl
+sudo apt install -y perl
+sudo apt install -y binutils
+sudo apt install -y libgmp-dev
+sudo apt install -y libmpfr-dev
+sudo apt install -y libmpc-dev
+sudo apt install -y libisl-dev
+sudo apt install -y zlib1g-dev
+sudo apt install -y liblz4-dev
+sudo apt install -y libbz2-dev
+sudo apt install -y libzstd-dev
+sudo apt install -y zstd
+sudo apt install -y lz4
+sudo apt install -y ncurses-dev
+sudo apt install -y libsnappy-dev
+sudo apt install -y libedit-dev
+sudo apt install -y libaio-dev
+sudo apt install -y libncurses5-dev
+sudo apt install -y libreadline-dev
+sudo apt install -y libpam0g-dev
+sudo apt install -y libicu-dev
+sudo apt install -y libboost-dev
+sudo apt install -y libgflags-dev
+sudo apt install -y libjemalloc-dev
+sudo apt install -y libssl-dev
+sudo apt install -y pkg-config
+```
+:::info
+libssl-dev may cannot install use apt, you can install it use aptitude.
+```bash
+sudo apt install aptitude
+sudo aptitude install libssl-dev
+...
+# type n y y
+```
+:::
+
+### Step 2. Install third-party dependencies
+StoneDB is dependent on marisa, RocksDB, and Boost. You are advised to specify paths for saving these libraries when you install them, instead of using the default paths.
+#### 1. Install cmake
+Check your CMake version first. If your cmake version < 3.72, install cmake
+```bash
+wget https://cmake.org/files/v3.7/cmake-3.7.2.tar.gz
+tar -zxvf cmake-3.7.2.tar.gz
+cd cmake-3.7.2
+./bootstrap && make && make install
+/usr/local/bin/cmake --version
+apt remove cmake -y
+ln -s /usr/local/bin/cmake /usr/bin/
+cmake --version
+```
+
+:::info
+If your gcc version too high, it may cause the compilation to fail. You can add `#include ` in the beginning of `cmake-3.72/Source/cmServerProtocal.cxx` to solve it.
+```c++
+#include
+#include
+#include
+#include
+```
+:::
+
+#### 2. Install make
+If your make version < 3.82, install make
+
+```bash
+wget http://mirrors.ustc.edu.cn/gnu/make/make-3.82.tar.gz
+tar -zxvf make-3.82.tar.gz
+cd make-3.82
+./configure --prefix=/usr/local/make
+make && make install
+rm -rf /usr/local/bin/make
+ln -s /usr/local/make/bin/make /usr/local/bin/make
+make --version
+```
+
+#### 3. Install marisa
+
+```bash
+git clone https://github.com/s-yata/marisa-trie.git
+cd marisa-trie
+autoreconf -i
+./configure --enable-native-code --prefix=/usr/local/stonedb-marisa
+sudo make && make install
+```
+
+The installation directory of marisa in the example is `/usr/local/stonedb-marisa`. You can change it based on your actual conditions. In this step, the following directories and files are generated in `/usr/local/stonedb-marisa/lib`.
+
+```bash
+root@htap-dev-64-2:/usr/local/stonedb-marisa/lib$ ls -l
+total 4136
+-rw-r--r-- 1 root root 2947618 Mar 20 16:25 libmarisa.a
+-rwxr-xr-x 1 root root 967 Mar 20 16:25 libmarisa.la
+lrwxrwxrwx 1 root root 18 Mar 20 16:25 libmarisa.so -> libmarisa.so.0.0.0
+lrwxrwxrwx 1 root root 18 Mar 20 16:25 libmarisa.so.0 -> libmarisa.so.0.0.0
+-rwxr-xr-x 1 root root 1273936 Mar 20 16:25 libmarisa.so.0.0.0
+drwxrwxr-x 2 root root 4096 Mar 20 16:25 pkgconfig
+```
+
+#### 4. Install RocksDB
+
+```bash
+wget https://github.com/facebook/rocksdb/archive/refs/tags/v6.12.6.tar.gz
+tar -zxvf v6.12.6.tar.gz
+cd rocksdb-6.12.6
+
+sudo cmake ./ \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX=/usr/local/stonedb-gcc-rocksdb \
+ -DCMAKE_INSTALL_LIBDIR=/usr/local/stonedb-gcc-rocksdb \
+ -DWITH_JEMALLOC=ON \
+ -DWITH_SNAPPY=ON \
+ -DWITH_LZ4=ON \
+ -DWITH_ZLIB=ON \
+ -DWITH_ZSTD=ON \
+ -DUSE_RTTI=ON \
+ -DROCKSDB_BUILD_SHARED=ON \
+ -DWITH_GFLAGS=OFF \
+ -DWITH_TOOLS=OFF \
+ -DWITH_BENCHMARK_TOOLS=OFF \
+ -DWITH_CORE_TOOLS=OFF
+
+sudo make -j`nproc`
+sudo make install -j`nproc`
+```
+
+:::info
+Your gcc version may too high, modify your CMakeLists.txt row#310-317 like this.
+```shell
+if(FAIL_ON_WARNINGS)
+ if(MSVC)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
+ else() # assume GCC
+ # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+ endif()
+endif()
+```
+:::
+
+The installation directory of RocksDB in the example is `/usr/local/stonedb-gcc-rocksdb`. You can change it based on your actual conditions. In this step, the following directories and files are generated in `/usr/local/stonedb-gcc-rocksdb`
+
+```bash
+root@htap-dev-64-2:/usr/local/stonedb-gcc-rocksdb$ ls -l
+total 29352
+drwxr-xr-x 3 root root 4096 Mar 20 17:12 cmake
+drwxr-xr-x 3 root root 4096 Mar 20 17:12 include
+-rw-r--r-- 1 root root 20555728 Mar 20 17:11 librocksdb.a
+lrwxrwxrwx 1 root root 15 Mar 20 17:12 librocksdb.so -> librocksdb.so.6
+lrwxrwxrwx 1 root root 20 Mar 20 17:12 librocksdb.so.6 -> librocksdb.so.6.12.6
+-rw-r--r-- 1 root root 9490272 Mar 20 17:12 librocksdb.so.6.12.6
+```
+
+#### 5. Install Boost
+
+```bash
+wget https://sourceforge.net/projects/boost/files/boost/1.77.0/boost_1_77_0.tar.gz
+tar -zxvf boost_1_77_0.tar.gz
+cd boost_1_77_0
+./bootstrap.sh --prefix=/usr/local/stonedb-boost177
+./b2 install --with=all
+```
+
+The installation directory of Boost in the example is `/usr/local/stonedb-boost`. You can change it based on your actual conditions. In this step, the following directories and files are generated in `/usr/local/stonedb-boost/lib`.
+
+```bash
+root@htap-dev-64-2:/usr/local/stonedb-boost177/lib$ ls -l
+total 41612
+drwxrwxr-x 49 root root 4096 Mar 20 18:57 cmake
+-rw-rw-r-- 1 root root 14648 Mar 20 18:56 libboost_atomic.a
+lrwxrwxrwx 1 root root 25 Mar 20 18:57 libboost_atomic.so -> libboost_atomic.so.1.77.0
+-rwxrwxr-x 1 root root 22248 Mar 20 18:57 libboost_atomic.so.1.77.0
+-rw-rw-r-- 1 root root 181638 Mar 20 18:56 libboost_chrono.a
+lrwxrwxrwx 1 root root 25 Mar 20 18:57 libboost_chrono.so -> libboost_chrono.so.1.77.0
+-rwxrwxr-x 1 root root 55000 Mar 20 18:57 libboost_chrono.so.1.77.0
+-rw-rw-r-- 1 root root 166894 Mar 20 18:56 libboost_container.a
+lrwxrwxrwx 1 root root 28 Mar 20 18:57 libboost_container.so -> libboost_container.so.1.77.0
+-rwxrwxr-x 1 root root 111912 Mar 20 18:57 libboost_container.so.1.77.0
+-rw-rw-r-- 1 root root 6874 Mar 20 18:56 libboost_context.a
+lrwxrwxrwx 1 root root 26 Mar 20 18:57 libboost_context.so -> libboost_context.so.1.77.0
+-rwxrwxr-x 1 root root 16584 Mar 20 18:57 libboost_context.so.1.77.0
+-rw-rw-r-- 1 root root 275376 Mar 20 18:56 libboost_contract.a
+lrwxrwxrwx 1 root root 27 Mar 20 18:57 libboost_contract.so -> libboost_contract.so.1.77.0
+-rwxrwxr-x 1 root root 148672 Mar 20 18:57 libboost_contract.so.1.77.0
+-rw-rw-r-- 1 root root 178370 Mar 20 18:56 libboost_coroutine.a
+lrwxrwxrwx 1 root root 28 Mar 20 18:57 libboost_coroutine.so -> libboost_coroutine.so.1.77.0
+-rwxrwxr-x 1 root root 84440 Mar 20 18:57 libboost_coroutine.so.1.77.0
+-rw-rw-r-- 1 root root 1458 Mar 20 18:56 libboost_date_time.a
+lrwxrwxrwx 1 root root 28 Mar 20 18:57 libboost_date_time.so -> libboost_date_time.so.1.77.0
+-rwxrwxr-x 1 root root 15184 Mar 20 18:57 libboost_date_time.so.1.77.0
+-rw-rw-r-- 1 root root 1654 Mar 20 18:57 libboost_exception.a
+-rw-rw-r-- 1 root root 249818 Mar 20 18:56 libboost_fiber.a
+lrwxrwxrwx 1 root root 24 Mar 20 18:56 libboost_fiber.so -> libboost_fiber.so.1.77.0
+-rwxrwxr-x 1 root root 107648 Mar 20 18:56 libboost_fiber.so.1.77.0
+-rw-rw-r-- 1 root root 520738 Mar 20 18:56 libboost_filesystem.a
+lrwxrwxrwx 1 root root 29 Mar 20 18:56 libboost_filesystem.so -> libboost_filesystem.so.1.77.0
+-rwxrwxr-x 1 root root 178288 Mar 20 18:56 libboost_filesystem.so.1.77.0
+-rw-rw-r-- 1 root root 1015048 Mar 20 18:57 libboost_graph.a
+lrwxrwxrwx 1 root root 24 Mar 20 18:56 libboost_graph.so -> libboost_graph.so.1.77.0
+-rwxrwxr-x 1 root root 525440 Mar 20 18:56 libboost_graph.so.1.77.0
+-rw-rw-r-- 1 root root 250402 Mar 20 18:56 libboost_iostreams.a
+lrwxrwxrwx 1 root root 28 Mar 20 18:56 libboost_iostreams.so -> libboost_iostreams.so.1.77.0
+-rwxrwxr-x 1 root root 129440 Mar 20 18:56 libboost_iostreams.so.1.77.0
+-rw-rw-r-- 1 root root 478396 Mar 20 18:57 libboost_json.a
+lrwxrwxrwx 1 root root 23 Mar 20 18:56 libboost_json.so -> libboost_json.so.1.77.0
+-rwxrwxr-x 1 root root 329512 Mar 20 18:56 libboost_json.so.1.77.0
+-rw-rw-r-- 1 root root 3158276 Mar 20 18:57 libboost_locale.a
+lrwxrwxrwx 1 root root 25 Mar 20 18:56 libboost_locale.so -> libboost_locale.so.1.77.0
+-rwxrwxr-x 1 root root 1177200 Mar 20 18:56 libboost_locale.so.1.77.0
+```
+
+#### 6.Install Gtest
+
+```bash
+sudo git clone https://github.com/google/googletest.git -b release-1.12.0
+cd googletest
+sudo mkdir build
+cd build
+sudo cmake .. -DBUILD_GMOCK=OFF
+sudo make
+sudo make install
+```
+
+Install in `/usr/local/` by default.
+
+```bash
+ls /usr/local/include/
+...... gtest
+ls /usr/local/lib/ # 32-bit os
+ls /usr/local/lib64/ # 64-bit os
+...... cmake libgtest.a libgtest_main.a
+```
+
+### Step 3. Compile StoneDB
+
+Currently, StoneDB has three branches: StoneDB-5.6 (for MySQL 5.6)、 StoneDB-5.7 (for MySQL 5.7) and StoneDB-8.0 (for MySQL 8.0). The link provided in this topic is to the source code package of StoneDB-8.0. In the following example, the source code package is saved to the root directory.
+
+```bash
+cd /
+git clone https://github.com/stoneatom/stonedb.git
+```
+
+Before compilation, modify the compilation script as follows:
+:::info
+You cna change the installation directory of StoneDB based on your actual conditions. In this example, `/stonedb/`is used. Remember to change the installation directories of marisa, RocksDB, and Boost based on your actual conditions.
+:::
+```bash
+cd stonedb
+git checkout -b 8.0 origin/stonedb-8.0-dev
+mkdir build
+cd build
+mkdir install8 mysql8
+cd mysql8
+cmake ../../ \
+-DCMAKE_BUILD_TYPE=Debug \
+-DCMAKE_INSTALL_PREFIX=/stonedb/build/install8 \
+-DMYSQL_DATADIR=/stonedb/build/install8/data \
+-DSYSCONFDIR=/stonedb/build/install8 \
+-DMYSQL_UNIX_ADDR=/stonedb/build/install8/tmp/mysql.sock \
+-DWITH_BOOST=/usr/local/stonedb-boost177 \
+-DWITH_MARISA=/usr/local/stonedb-marisa \
+-DWITH_ROCKSDB=/usr/local/stonedb-gcc-rocksdb \
+-DDOWNLOAD_BOOST=0
+make -j`nproc`
+make install -j`nproc`
+```
+
+### Step 4. Start StoneDB
+
+You need to manually create directories, and then initialize and start StoneDB. You also need to configure parameters in file my.cnf, including the installation directories and port.
+
+```bash
+cd ../install8
+### Create directories.
+sudo mkdir data binlog log tmp redolog undolog
+
+### Configure parameters in my.cnf.
+sudo cp ../../scripts/my.cnf.sample my.cnf
+sudo sed -i "s|YOUR_ABS_PATH|$(pwd)|g" my.cnf
+
+### Initialize StoneDB.
+sudo ./bin/mysqld --defaults-file=./my.cnf --initialize-insecure
+
+### Start StoneDB.
+sudo ./bin/mysqld --user=root &
+```
+
+### Step 5.Login to StoneDB
+
+```bash
+./bin/mysql -uroot
+### set the password of user root to stonedb123
+mysql> alter user 'root'@'localhost' identified by 'stonedb123';
+Query OK, 0 rows affected
+### allow remote access
+mysql> use mysql;
+mysql> update user set host='%' where user='root';
+```
diff --git a/Docs/download.md b/Docs/download.md
index c1d0cb3b7..aea18c50a 100644
--- a/Docs/download.md
+++ b/Docs/download.md
@@ -15,5 +15,6 @@ Click here to download the latest installation package of StoneDB.
| [5.7-v1.0.0](https://github.com/stoneatom/stonedb/releases/tag/5.7-v1.0.0-GA) | 2022-8-31 | [Download](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.0-GA/stonedb-ce-5.7-v1.0.0.el7.x86_64.tar.gz) | e23593b80b50e0118f59627216613a2f | \ |
| [5.7-v1.0.1](https://github.com/stoneatom/stonedb/releases/tag/5.7-v1.0.1-GA) | 2022-10-24 | [Download](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.1-GA/stonedb-ce-5.7-v1.0.1.el7.x86_64.tar.gz) | 73911e56ac89af5f568dd7e9de9e9af5 | You can [download the DEB package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.1-GA/stonedb-ce-5.7-v1.0.1.debain.x86_64.tar.gz);If you run into a lack of dependencies when compiling the installation, you can go to Github and [download the related dependency package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.1-GA/stonedb-lib.tar.gz) |
| [5.7-v1.0.2](https://github.com/stoneatom/stonedb/releases/tag/5.7-v1.0.2-GA) | 2023-01-15 | [Download](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.2-GA/stonedb-ce-5.7-v1.0.2.el7.x86_64.tar.gz) | be54d4ebb74517bf09fbfe1806f6e2ab | 1.You can [download the DEB package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.2-GA/stonedb-ce-5.7_v1.0.2.ubuntu.amd64.deb);2.You can [download the RPM package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.2-GA/stonedb-ce-5.7-v1.0.2.el7.x86_64.rpm) and experience StoneDB installation in two minutes;3.You can [download the Shell script](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.2-GA/shell.for.deploy.stonedb.as.replic.tar.gz)|
+| [5.7-v1.0.3](https://github.com/stoneatom/stonedb/releases/tag/5.7-v1.0.3-GA) | 2023-03-20 | [Download](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7-v1.0.3.el7.x86_64.tar.gz) | 679491c2a154b2b00de534c47dea507b | 1.You can [download the DEB package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7-v1.0.3.ubuntu.amd64.deb);2.You can [download the RPM package](https://github.com/stoneatom/stonedb/releases/download/5.7-v1.0.3-GA/stonedb-ce-5.7-v1.0.3.el7.x86_64.rpm) |
| Next Version | Coming soon~ | Coming soon~ | Coming soon~ | \ |
diff --git a/Docs/release-notes.md b/Docs/release-notes.md
index aaaecc98d..75dc9099b 100644
--- a/Docs/release-notes.md
+++ b/Docs/release-notes.md
@@ -6,7 +6,7 @@ sidebar_position: 11.0
# Release Notes
## StoneDB-5.7-V1.0.3
-Release date: March 15,2023
+Release date: March 20,2023
- Reconstructed the binlog mechanism to filter out DDL statements that are not supported by the Tianmu storage engine.
- Added an argument named **NO_KEY_ERROR** for SQL mode to directly skip DDL statements that are not supported by the SQL layer, instead of reporting errors.
diff --git a/Docs/stonedb_wecaht_group.png b/Docs/stonedb_wecaht_group.png
index 2d0384d96..fbd962888 100644
Binary files a/Docs/stonedb_wecaht_group.png and b/Docs/stonedb_wecaht_group.png differ
diff --git a/README.md b/README.md
index fbe1aa02a..31cc625d5 100644
--- a/README.md
+++ b/README.md
@@ -19,20 +19,20 @@
- [What is StoneDB](#what-is-stonedb)
-- [Contribution](#contribution)
- [Getting Started](#getting-started)
- [Supported Platform](#supported-platform)
+ - [Build StoneDB from Source Code in a Docker Container](#build-stonedb-from-source-code-in-a-docker-container)
- [Build StoneDB from the Source Code](#build-stonedb-from-the-source-code)
- [On Ubuntu 20.04](#on-ubuntu-2004)
- [On CentOS 7.X](#on-centos-7x)
- [On RedHat 7.X](#on-redhat-7x)
- - [Build StoneDB from Source Code in a Docker Container](#build-stonedb-from-source-code-in-a-docker-container)
- [Configure StoneDB](#configure-stonedb)
- [Initialize the Database](#initialize-the-database)
- [Start the Database Instance](#start-the-database-instance)
- [Create a StoneDB Table](#create-a-stonedb-table)
- [Switch from MySQL to StoneDB in Production](#switch-from-mysql-to-stonedb-in-production)
- [Documentation](#documentation)
+- [Contribution](#contribution)
- [Discussion](#discussion)
- [Join StoneDB Wechat Group](#join-stonedb-wechat-group)
- [Code of Conduct](#code-of-conduct)
@@ -55,10 +55,6 @@ StoneDB is a MySQL-compatible high-performance hybrid transaction/analytical pro
For more information about StoneDB, see [stonedb.io](https://stonedb.io/).
-# Contribution
-
-StoneDB welcomes all kinds of contributions, such as contributing code to the code base, sharing your experience on how to use StoneDB, and providing insights in the community on the Forums, or contributing to projects that make StoneDB a better project. For more specifics, see the [contributing guide](https://github.com/stoneatom/stonedb/blob/stonedb-5.7-dev/CONTRIBUTING.md) for more specifics.
-
# Getting Started
The Getting Started part provides information about StoneDB supported platforms, installation (including creating your first table), and migrating from the running MySQL databases to StoneDB.
@@ -83,6 +79,12 @@ The following packages we verify our builds with:
- RocksDB 6.12.6
- Boost 1.66
+## Build StoneDB from Source Code in a Docker Container
+
+For more information, see [Compile StoneDB in a Docker Container](https://stonedb.io/docs/developer-guide/compiling-methods/compile-using-docker).
+
+Of course, you can also quickly install and deploy StoneDB directly from [Dockershub](https://hub.docker.com/r/stoneatom/stonedb) in just two minutes. See our [documentation](https://stonedb.io/docs/getting-started/quick-deploy-in-docker) for details.
+
## Build StoneDB from the Source Code
### On Ubuntu 20.04
@@ -95,9 +97,6 @@ For more information, see [Compile StoneDB on CentOS 7.x](https://stonedb.io/doc
### On RedHat 7.X
For more information, see [Compile StoneDB on RedHat 7.x](https://stonedb.io/docs/developer-guide/compiling-methods/compile-using-redhat7/compile-using-redhat7-for-57/).
-## Build StoneDB from Source Code in a Docker Container
-
-For more information, see [Compile StoneDB in a Docker Container](https://stonedb.io/docs/developer-guide/compiling-methods/compile-using-docker).
## Configure StoneDB
After StoneDB is installed, you need to configure at least the following parameters in the **my.cnf** file:
@@ -174,6 +173,10 @@ Online migration tools to move data between storage engines are not currently de
Documentation can be found online at [https://stonedb.io](https://stonedb.io/docs/about-stonedb/intro). The documentation provides you with StoneDB basics, extensive examples of using StoneDB, as well as other information that you may need during your usage of StoneDB.
+# Contribution
+
+StoneDB welcomes all kinds of contributions, such as contributing code to the code base, sharing your experience on how to use StoneDB, and providing insights in the community on the Forums, or contributing to projects that make StoneDB a better project. For more specifics, see the [contributing guide](https://github.com/stoneatom/stonedb/blob/stonedb-5.7-dev/CONTRIBUTING.md) for more specifics.
+
# Discussion
The [GitHub Discussions](https://github.com/stoneatom/stonedb/discussions) is the home for most discussions and communications about the StoneDB project. We welcome your participation. Every single opinion or suggestion of yours is welcomed and valued. We anticipate StoneDB to be an open and influential project.
diff --git a/README_zh-hans.md b/README_zh-hans.md
index b66eae76b..f3826dc3c 100644
--- a/README_zh-hans.md
+++ b/README_zh-hans.md
@@ -22,11 +22,11 @@
- [贡献指南](#贡献指南)
- [快速开始](#快速开始)
- [支持平台](#支持平台)
+ - [在 Docker 容器中通过源码编译 StoneDB](#在-docker-容器中通过源码编译-stonedb)
- [通过源码编译 StoneDB](#通过源码编译-stonedb)
- [Ubuntu 20.04 下编译 StoneDB](#ubuntu-2004-下编译-stonedb)
- [CentOS 7.x 下编译 StoneDB](#centos-7x-下编译-stonedb)
- [RedHat 7.x 下编译 StoneDB](#redhat-7x-下编译-stonedb)
- - [在 Docker 容器中通过源码编译 StoneDB](#在-docker-容器中通过源码编译-stonedb)
- [配置 StoneDB](#配置-stonedb)
- [初始化数据库](#初始化数据库)
- [启动数据库实例](#启动数据库实例)
@@ -84,6 +84,12 @@ StoneDB 社区欢迎各种各样的贡献,如为代码库贡献代码,分享
- RocksDB 6.12.6
- Boost 1.66
+## 在 Docker 容器中通过源码编译 StoneDB
+
+更多信息,可以查看 [Compile StoneDB in a Docker Container](https://stonedb.io/zh/docs/developer-guide/compiling-methods/compile-using-docker)。
+
+当然,您也可以直接通过 [Dockershub](https://hub.docker.com/r/stoneatom/stonedb) 来快速安装部署 StoneDB,只要两分钟,详情可以看[官网文档](https://stonedb.io/zh/docs/getting-started/quick-deploy-in-docker)。
+
## 通过源码编译 StoneDB
### Ubuntu 20.04 下编译 StoneDB
@@ -97,9 +103,6 @@ StoneDB 社区欢迎各种各样的贡献,如为代码库贡献代码,分享
### RedHat 7.x 下编译 StoneDB
更多信息,可以查看 [Compile StoneDB on RHEL 7](https://stonedb.io/zh/docs/developer-guide/compiling-methods/compile-using-redhat7/compile-using-redhat7-for-57)。
-## 在 Docker 容器中通过源码编译 StoneDB
-
-更多信息,可以查看 [Compile StoneDB in a Docker Container](https://stonedb.io/zh/docs/developer-guide/compiling-methods/compile-using-docker)。
## 配置 StoneDB
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 000000000..45337d73b
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,3 @@
+ignore:
+- "include/boost_1_66_0"
+- "extra"
\ No newline at end of file
diff --git a/include/mysqld_error.h b/include/mysqld_error.h
index 7451e3970..41a0ab13a 100644
--- a/include/mysqld_error.h
+++ b/include/mysqld_error.h
@@ -4,7 +4,7 @@
#define MYSQLD_ERROR_INCLUDED
static const int errmsg_section_start[] = { 1000, 3000 };
-static const int errmsg_section_size[] = { 889, 234 };
+static const int errmsg_section_size[] = { 889, 244 };
#define ER_HASHCHK 1000
#define ER_NISAMCHK 1001
diff --git a/mysql-test/r/mysql_config_editor.result b/mysql-test/r/mysql_config_editor.result
index a0cd95d9e..e91b52752 100644
--- a/mysql-test/r/mysql_config_editor.result
+++ b/mysql-test/r/mysql_config_editor.result
@@ -100,7 +100,7 @@ user = test_user4
##############################################
# Tests for mysql_config_editor's help command
##############################################
-Copyright (c) 2021, 2022 StoneAtom Group Holding Limited
+Copyright (c) 2021-Right Now, StoneAtom Group Holding Limited
MySQL Configuration Utility.
-?, --help Display this help and exit.
-v, --verbose Write more information.
diff --git a/mysql-test/suite/innodb/include/innodb_testlist b/mysql-test/suite/innodb/include/innodb_testlist
index fd8bdd865..ac3d26641 100644
--- a/mysql-test/suite/innodb/include/innodb_testlist
+++ b/mysql-test/suite/innodb/include/innodb_testlist
@@ -1,80 +1,55 @@
-innodb.check_sector_size
innodb.innodb_bug53674
-innodb.innodb
-innodb.innodb_misc1
innodb.innodb_ctype_ldml
+innodb.innodb_misc1
+innodb.check_sector_size
innodb.innodb-autoinc-44030
+innodb.innodb
innodb.innodb_autoinc_lock_mode_zero
innodb.update_time
+innodb.table_encryption
innodb.events-merge-tmp-path
innodb.file_format_defaults
innodb.innodb_bug39438
+innodb.innodb-autoinc
+innodb.table_encrypt_2
innodb.blob_redo
-innodb.innodb-index
+innodb.innodb_buffer_pool_load_now
innodb.innodb-autoinc-56228
innodb.innodb_bug30919
+innodb.innodb-index
innodb.innodb_bug42101-nonzero
+innodb.innodb_stats_flag_global_off
+innodb.innodb_stats_flag_global_on
innodb.create_isl_with_direct
-innodb.innodb_mysql_rbk
+innodb.innodb_bug60049
innodb.innodb_timeout_rollback
-innodb.innodb-consistent
innodb.alter_table_stage_progress
-innodb.innodb_bug47167
-innodb.innodb_file_format
-innodb.alter_page_size
-innodb.alter_rename_existing
-innodb.alter_row_format
-innodb.alter_table_redundant
-innodb.check_ibd_filesize_16k
-innodb.checksum
-innodb.create-index
-innodb.create_tablespace_partition
+innodb.innodb-consistent
+innodb.innodb_mysql_rbk
+innodb.innodb_buffer_pool_load
innodb.deadlock_detect
innodb.default_row_format
+innodb.innodb_bug47167
+innodb.innodb_file_format
+innodb.add_foreign_key
+innodb.default_row_format_16k
innodb.default_row_format_compatibility
-innodb.default_row_format_tablespace
-innodb.deprecate_part_in_shared_ts
-innodb.dropdb
-innodb.foreign_key
-innodb.import
-innodb.import_tablespace_schema_missmatch
-innodb.import_update_stats
-innodb.index-online-norebuild
-innodb.index_length
-innodb.index_tree_operation
+innodb.innodb-semi-consistent
innodb.innodb-alter-autoinc
innodb.innodb-alter-nullable
+innodb.default_row_format_tablespace
innodb.innodb-alter-wl6554
innodb.innodb-analyze
innodb.innodb-autoinc-18274
innodb.innodb-autoinc-optimize
+innodb.deprecate_part_in_shared_ts
+innodb.dropdb
innodb.innodb-bug-14068765
innodb.innodb-bug-14084530
+innodb.innodb_lock_wait_timeout_1
+innodb.innodb-lock
innodb.innodb-bug12552164
innodb.innodb-bug14219515
-innodb.innodb-import-partition
-innodb.innodb-index_ucs2
-innodb.innodb-isolation
-innodb.innodb-large-prefix
-innodb.innodb-lock
-innodb.innodb-timeout
-innodb.innodb-truncate
-innodb.innodb-ucs2
-innodb.innodb-update-insert
-innodb.innodb-wl5522-1
-innodb.innodb_buffer_pool_dump_pct
-innodb.innodb_bug11789106
-innodb.innodb_bug11933790
-innodb.innodb_bug12429573
-innodb.innodb_bug12661768
-innodb.innodb_bug14169459
-innodb.innodb_bug21704
-innodb.innodb_bug34053
-innodb.innodb_bug34300
-innodb.innodb_bug35220
-innodb.innodb_bug38231
-innodb.innodb_bug40360
-innodb.innodb_bug40565
innodb.innodb_bug41904
innodb.innodb_bug42101
innodb.innodb_bug42419
@@ -86,8 +61,14 @@ innodb.innodb_bug46000
innodb.innodb_bug46676
innodb.innodb_bug47621
innodb.innodb_bug47622
+innodb.table_encrypt_5
innodb.innodb_bug47777
innodb.innodb_bug48024
+innodb.innodb_i_s_innodb_trx
+innodb.innodb_information_schema_buffer
+innodb.innodb_io_pf
+innodb.innodb_multi_update
+innodb.innodb_notembedded
innodb.innodb_bug49164
innodb.innodb_bug51378
innodb.innodb_bug51920
@@ -95,30 +76,18 @@ innodb.innodb_bug52199
innodb.innodb_bug53046
innodb.innodb_bug53592
innodb.innodb_bug54044
+innodb.innodb-wl6045-1
+innodb.innodb-import-partition
+innodb.file_format_upgrade_16k
+innodb.innodb-index_ucs2
innodb.innodb_bug56143
innodb.innodb_bug56716
+innodb.alter_missing_tablespace
innodb.innodb_bug57252
+innodb.alter_page_size
innodb.innodb_bug57255
-innodb.innodb_bug57904
-innodb.innodb_bug59307
-innodb.innodb_bug59410
-innodb.innodb_bug59733
-innodb.innodb_bug60229
-innodb.innodb_bulk_create_index_small
-innodb.innodb_i_s_innodb_locks
-innodb.innodb_i_s_innodb_trx
-innodb.innodb_information_schema_buffer
-innodb.innodb_io_pf
-innodb.innodb_multi_update
-innodb.innodb_notembedded
-innodb.innodb_prefix_index_check
-innodb.innodb_rename_index
-innodb.innodb_stats
-innodb.innodb_stats_auto_recalc_ddl
-innodb.innodb_stats_auto_recalc_lots
-innodb.innodb_stats_auto_recalc_on_nonexistent
-innodb.innodb_stats_create_on_corrupted
-innodb.innodb_stats_create_table
+innodb.alter_rename_existing
+innodb.alter_row_format
innodb.innodb_stats_drop_locked
innodb.innodb_stats_external_pages
innodb.innodb_stats_fetch
@@ -127,32 +96,666 @@ innodb.innodb_stats_fetch_nonexistent
innodb.innodb_stats_rename_table
innodb.innodb_stats_rename_table_if_exists
innodb.innodb_stats_sample_pages
-innodb.innodb_sys_var_valgrind
-innodb.innodb_tablespace
-innodb.innodb_tablespace_zip
-innodb.innodb_trx_weight
-innodb.innodb_wl6469_1
+innodb.innodb_bug57904
+innodb.innodb_bug59307
+innodb.innodb_bug59410
+innodb.innodb_prefix_index_check
+innodb.innodb-isolation
+innodb.innodb-multiple-tablespaces
+innodb.innodb-large-prefix
innodb.innodb_wl6470
+innodb.foreign_key
+innodb.alter_table_redundant
+innodb.innodb_stats
+innodb.innodb-timeout
+innodb.innodb-truncate
+innodb.innodb-ucs2
+innodb.innodb_bug59641
+innodb.innodb-update-insert
+innodb.innodb_bug59733
+innodb.innodb_bug60229
+innodb.innodb_bulk_create_index_small
+innodb.help_verbose
+innodb.innodb_bug-13628249
+innodb.innodb_bug11789106
+innodb.import
+innodb.import_tablespace_schema_missmatch
+innodb.import_update_stats
+innodb.index-online-norebuild
+innodb.innodb_bug11933790
+innodb.innodb_stats_auto_recalc
+innodb.innodb_stats_auto_recalc_ddl
+innodb.innodb_bug12429573
+innodb.innodb_bug12661768
+innodb.innodb_bug14169459
+innodb.innodb-wl5522-1
+innodb.innodb_bug21704
+innodb.innodb_bug34053
+innodb.innodb_bug34300
+innodb.innodb_bug35220
+innodb.innodb_bug38231
+innodb.innodb_bug40360
+innodb.innodb_bug40565
+innodb.innodb_wl6560_1
innodb.innodb_wl6915
innodb.innodb_wl8114
+innodb.check_ibd_filesize_16k
+innodb.index_length
+innodb.index_tree_operation
+innodb.innodb_stats_auto_recalc_lots
+innodb.innodb_stats_auto_recalc_on_nonexistent
+innodb.innodb_stats_create_on_corrupted
+innodb.innodb_stats_create_table
+innodb.checksum
+innodb.create-index
innodb.iodku
-innodb.log_file_size_checkpoint
-innodb.monitor
-innodb.monitor_restart
-innodb.partition-blob
-innodb.partition
-innodb.readahead
-innodb.stored_fk
-innodb.strict_mode
+innodb.innodb_prefix_index_restart_server
innodb.tablespace_per_table
innodb.tablespace_per_table_not_windows
+innodb.innodb_rename_index
innodb.timestamp
innodb.tmpdir
+innodb.monitor_restart
+innodb.partition-blob
+innodb.innodb-wl5522
+innodb.log_file_size_checkpoint
+innodb.partition-upgrade
+innodb.create_tablespace
innodb.trx_id_future
innodb.undo
-innodb.virtual_basic
-innodb.virtual_blob
+innodb.partition
+innodb.innodb_stats_table_flag_auto_recalc
innodb.virtual_fk
+innodb.readahead
innodb.virtual_index
innodb.virtual_stats
+innodb.innodb_force_recovery
+innodb.innodb_i_s_innodb_locks
+innodb.readonly
+innodb.missing_tablespaces
+innodb.monitor
+innodb.virtual_fk_restart
+innodb.xa_recovery
+innodb.create_tablespace_partition
+innodb.create_tablespace_16k
+innodb.create_tablespace_replication
+innodb.innodb-import-partition-rpl
+innodb.innodb_bulk_create_index_replication
+innodb.rename_table
+innodb.stored_fk
+innodb.strict_mode
+innodb.innodb_buffer_pool_dump_pct
+innodb.innodb_sys_var_valgrind
+innodb.innodb_tablespace
+innodb.innodb_tablespace_zip
+innodb.innodb_trx_weight
+innodb.innodb_wl6469_1
+innodb.create_tablespace_notembedded
+innodb.innodb_stats_table_flag_sample_pages
+innodb.virtual_blob
+innodb.innodb-wl5980-discard
+innodb.update_time_wl6658
+innodb.innodb-wl6445
+innodb.innodb-wl6045-linux
+innodb.virtual_basic
+innodb.table_encrypt_kill
+innodb.table_encrypt_3
+main.plugin_load_option
+main.plugin_load
+main.plugin_auth_user_lock
+main.bug46261
+main.multi_plugin_load
+main.plugin_not_embedded
+main.plugin_auth_qa_2
+main.multi_plugin_load_add2
+main.multi_plugin_load_add
+main.plugin_auth_qa
+main.plugin_auth_expire
+main.plugin_auth_qa_3
+main.enable_cleartext_plugin
+main.plugin_auth_qa_1
+main.locking_service
+main.version_token
+main.test_security_context
+main.udf_services
+main.udf_skip_grants
+main.ctype_filesystem
+main.session_tracker
+main.signal_demo3
+main.wl6301_3
+main.bug33509
+main.fulltext_plugin
+main.validate_password_plugin_check_user
+main.lock_tables_lost_commit
+main.sp-fib
+main.version_token_bug21280801
+main.version_token_errors
+main.udf
+main.ipv4_as_ipv6
+main.validate_password_plugin
+main.wl6301_2_not_windows
+main.sp-lock
+main.sp-prelocking
+main.subselect_notembedded
+main.mix2_myisam
+main.ctype_utf16_def
+main.lowercase_utf8
+main.ctype_ucs2_def
+main.bug47671
+main.date_formats
+main.grant_alter_user_qa
+main.myisam-blob
+main.ctype_ldml
+main.disabled_storage_engines
+main.no_engine_substitution
+main.ctype_utf8mb4
+main.ctype_gb18030_binlog
+main.plugin_auth_sha256_server_default_tls
+main.wl6443_deprecation
+main.temp_table
+main.disconnect_on_expired_password_off
+main.ps_3innodb
+main.myisam_explain_non_select_none
+main.innodb_ignore_builtin
+main.ctype_utf8
+main.xa_gtid
+main.type_timestamp
+main.log_state_bug33693
+main.ctype_utf8mb4_innodb
+main.type_timestamp_explicit
+main.implicit_commit
+main.mysqldump-max
+main.init_connect
+main.innodb_disabled
+main.no_binlog_gtid_next_begin_caused_trx
+main.partition_innodb_semi_consistent
+main.mysqldump_gtid_state
+main.strict
+main.no_binlog_gtid_next_partially_failed_stmts
+main.init_file
+main.log_timestamps
+main.bug46760
+main.wl6661
+main.unsafe_binlog_innodb
+main.bug17076131
+main.events_restart
+main.events_logs_tests
+main.innodb_mysql_lock
+main.rollback
+main.concurrent_innodb_unsafelog
+main.plugin_auth_sha256
+main.plugin_auth_sha256_2
+main.plugin_auth_sha256_server_default
+main.func_encrypt
+main.skip_log_bin
+main.innodb_mrr
+main.variables-notembedded
+main.check
+main.partition_not_blackhole
+main.ps
+main.ssl_8k_key
+main.log_tables
+main.concurrent_innodb_safelog
+main.lowercase_mixed_tmpdir
+main.lowercase_table_qcache
+main.server_offline_6
+main.innodb_deadlock
+main.lowercase_view
+main.lowercase_table_grant
+main.variables
+main.merge_mmap
+main.mysql_not_windows
+main.relay_log_index_variables
+main.bug12969156
+main.innodb_mrr_cost
+main.csv
+main.cache_innodb
+main.bug58669
+main.deprecate_eof
+main.ps_2myisam
+main.select_for_update
+main.myisam_recover
+main.ps_4heap
+main.relay_log_variables
+main.disabled_replication
+main.grant3
+main.skip_grants
+main.flush2
+main.mysqldump-no-binlog
+main.table_open_cache_functionality
+main.ps_5merge
+main.query_cache_disabled
+main.mysql_ssl
+main.archive_no_symlink
+main.skip_name_resolve
+main.skip_grants_flush
+main.ssl-sha512
+main.ssl_ca
+main.ssl_crl_clients_valid
+main.ssl_crl_clients
+main.count_distinct2
+main.multi_update_tiny_hash
+main.func_misc
+main.grant_cache
+main.mysql_client_test_qcache
+main.partition_cache
+main.query_cache_size_functionality
+main.query_cache_28249
+main.ssl_crl
+main.long_tmpdir
+main.innodb_mrr_cost_icp
+main.temp_pool
+main.ssl_crl_crlpath
+main.grant_user_lock_qa
+main.ssl_cipher
+main.order_fill_sortbuf
+main.ssl_verify_identity
+main.handler_myisam
+main.partition_not_windows
+main.no-threads
+main.sysdate_is_now
+main.query_cache_notembedded
+main.func_aes_cfb128
+main.ctype_create
+main.func_aes_cfb8
+main.ctype_errors
+main.func_isnull
+main.query_cache_ps_no_prot
+main.func_op
+main.ctype_filename
+main.func_aes_misc
+main.innodb_mrr_icp
+main.func_aes_ofb
+main.query_cache_with_views
+main.func_rollback
+main.func_sapdb
+main.transaction_isolation
+main.transaction_read_only
+main.func_analyse
+main.func_set
+main.trans_read_only
+main.func_str_no_ps
+main.func_system
+main.func_bitwise_ops
+main.change_user
+main.func_timestamp
+main.session_tracker_trx_state
+main.mysql_batch_mode
+main.func_crypt
+main.mysql_comments
+main.func_date_add
+main.func_weight_string
+main.func_des_encrypt
+main.ctype_gb18030
+main.func_digest
+main.func_encrypt_ucs2
+main.func_equal
+main.func_found_rows
+main.comment_column2
+main.comment_index
+main.comment_table
+main.comments
+main.ctype_gb18030_encoding_cn
+main.commit
+main.mysqladmin
+main.fulltext2
+main.ctype_utf32
+main.compare
+main.condition_filter
+main.fulltext3
+main.func_gconcat
+main.ctype_gb18030_encoding_utf8
+main.func_group_innodb
+main.func_group_innodb_16k
+main.ctype_utf32_uca
+main.function_defaults
+main.func_if
+main.ctype_gb18030_ligatures
+main.gcc296
+main.mysqldumpslow
+main.mysqlimport
+main.get_diagnostics
+main.gis-rt-precise
+main.innodb_mrr_none
+main.not_embedded_server
+main.1st
+main.ctype_utf8mb4_heap
+main.locale
+main.alias
+main.fulltext_distinct
+main.events_scheduling
+main.group_min_max_innodb
+main.almost_full
+main.index_merge_intersect_dml
+main.gtids_anonymous_trxs_violations
+main.events_trans
+main.analyze
+main.events_trans_notembedded
+main.mysqladmin_shutdown
+main.ansi
+main.lock
+main.ctype_gb2312
+main.ctype_utf8mb4_myisam
+main.mysqlbinlog_base64_flag
+main.insert_select
+main.archive_bitfield
+main.index_merge_update
+main.mysqlbinlog_hexdump
+main.archive_gis
+main.archive_symlink
+main.ctype_utf8mb4_uca
+main.mysql_cp932
+main.information_schema_db
+main.mysql_protocols
+main.mysql_ssl_default
+main.mysql_tzinfo_to_sql
+main.query_cache_type_functionality
+main.bigint
+main.information_schema_inno
+main.information_schema_parameters
+main.information_schema_routines
+main.binary
+main.ctype_gbk
+main.insert_update
+main.mysql_tzinfo_to_sql_sys
+main.binary_to_hex
+main.blackhole
+main.ctype_hebrew
+main.bool
+main.ctype_latin2
+main.mysqlcheck
+main.mysqld--defaults-file
+main.ctype_latin2_ch
+main.no_binlog_gtid_next_single_stmt_trx_rollback
+main.ctype_many
+main.no_binlog_gtid_next_temporary_table
+main.handler_innodb
+main.odbc
+main.heap_auto_increment
+main.ctype_mb
+main.heap_btree
+main.ctype_tis620
+main.heap_hash
+main.help
+main.help_verbose
+main.mysqlpump_basic
+main.olap
+main.connect
+main.mysqlpump_bugs
+main.openssl_1
+main.installdb-bad-cipher
+main.is_deprecation
+main.opt_costmodel
+main.join_crash
+main.fulltext_update
+main.host_cache_size_functionality
+main.opt_costmodel_downgrade
+main.opt_costmodel_pfs
+main.mysqlpump_concurrency
+main.join_file_handler
+main.log_errchk
+main.mysqlpump_extended
+main.examined_rows
+main.consistent_snapshot
+main.execution_constants
+main.key
+main.constraints
+main.key_diff
+main.create_not_windows
+main.key_primary
+main.csv_alter_table
+main.mysqlpump_partial_bkp
+main.csv_not_null
+main.ctype_ascii
+main.keywords
+main.log_tables_upgrade
+main.grant_alter_user
+main.lowercase_fs_off
+main.lowercase_table5
+main.loaddata
+main.loaddata_autocom_innodb
+main.ignore_strict
+main.ctype_big5
+main.explain_json_none
+main.mysqldump-binary
+main.file_contents
+main.mysqldump-compat
+main.implicit_char_to_num_conversion
+main.mysqldump_bug29998457
+main.import_schema_mismatch
+main.ctype_uca
+main.datadir_permission
+main.sort_buffer_size_functionality
+main.filesort_merge
+main.filesort_pack
+main.loadxml
+main.parser_not_embedded
+main.parser_precedence
+main.opt_hint_timeout
+main.opt_hints_lowercase
+main.initialize_gtid
+main.opt_hints_pfs
+main.mysqlshow
+main.user_limits
+main.index_merge_insert-and-replace
+main.innodb_icp
+main.partition_index_myisam
+main.deadlock_innodb
+main.ctype_binary
+main.default
+main.grant_explain_non_select
+main.delete_all_rows
+main.order_by_limit
+main.deprecated_features
+main.ctype_collate
+main.outfile_loaddata
+main.dirty_close
+main.overflow
+main.parser_stack
+main.disconnect_on_expired_password_default
+main.ctype_cp1250_ch
+main.packet
+main.innodb_icp_all
+main.drop
+main.partition_mgm_err2
+main.empty_table
+main.partition_myisam
+main.endspace
+main.events_grant
+main.events_microsec
+main.opt_costmodel_restart
+main.partition_utf8
+main.perror
+main.plugin_auth_sha256_tls
+main.ps_10nestset
+main.opt_costmodel_tables
+main.ps_11bugs
+main.flush
+main.merge
+main.merge_innodb
+main.innodb_icp_none
+main.innodb_log_file_size_functionality
+main.multi_update_innodb
+main.innodb_pk_extension_off
+main.flush_block_commit
+main.partition_order
+main.func_aes
+main.func_aes_cfb1
+main.innodb_pk_extension_on
+main.ps_grant
+main.ps_not_windows
+main.partition_datatype
+main.partition_innodb
+main.ps_w_max_indexes_64
+main.partition_innodb_plugin
+main.read_only
+main.read_only_innodb
+main.bootstrap
+main.rename
+main.renamedb
+main.bug12427262
+main.rewrite_general_log
+main.bulk_replace
+main.partition
+main.rewrite_slow_log
+main.cast
+main.ctype_cp1251
+main.partition_archive
+main.partition_blackhole
+main.ctype_cp932
+main.mysql-bug41486
+main.ps_1general
+main.partition_bug18198
+main.round
+main.server_offline_3
+main.server_offline_4
+main.rowid_order_innodb
+main.ps_ddl1
+main.rpl_multi_source_mysqldump_slave
+main.schema
+main.server_offline_1
+main.server_offline_5
+main.server_offline_2
+main.sp-destruct
+main.partition_innodb_tablespace
+main.ctype_ucs
+main.sp-dynamic
+main.partition_column
+main.partition_list
+main.partition_column_prune
+main.parser_bug21114_innodb
+main.partition_csv
+main.sp-ucs2
+main.ctype_utf16
+main.sp-error
+main.sp-no-code
+main.sp-vars
+main.mysql-bug45236
+main.sp-security
+main.ctype_utf16_uca
+main.charset
+main.sp-threads
+main.ctype_utf16le
+main.subquery_sj_innodb_none_bka_nixbnl
+main.partition_pruning
+main.timezone2
+main.sum_distinct
+main.sp_gis
+main.system_mysql_db_refs
+main.sql_mode_default
+main.partition_range
+main.partition_rename_longfilename
+main.partition_symlink
+main.partition_truncate
+main.truncate
+main.type_binary
+main.timezone4
+main.type_bit_innodb
+main.opt_costmodel_warnings
+main.check_auto_permission
+main.symlink
+main.client_xml
+main.type_decimal
+main.comment_column
+main.subquery_sj_innodb_none
+main.synchronization
+main.type_temporal_upgrade
+main.partition_locking_4
+main.sp_stress_case
+main.type_enum
+main.system_mysql_db
+main.type_nchar
+main.view_alias
+main.subquery_sj_innodb_none_bka
+main.mysqlslap
+main.no_binlog
+main.wl6219-csv
+main.no_binlog_gtid_empty_statement
+main.no_binlog_gtid_next_partially_failed_stmts_anonymous
+main.type_time
+main.type_uint
+main.wl6219-memory
+main.wl6219-merge
+main.partition_mgm
+main.xml
+main.subselect_gis
+main.type_year
+main.partition_mgm_err
+main.type_newdecimal
+main.wl6219-upgrade
+main.wl6978
+main.type_set
+main.partition_deprecation
+main.sp_validation
+main.table_definition_cache_functionality
+main.sql_mode
+main.ssl_and_innodb
+main.status2
+main.status_bug17954
+main.strict_autoinc_2innodb
+main.user_if_exists
+main.timezone_grant
+main.wait_timeout
+main.partition_error
+main.warnings_engine_disabled
+main.trigger-compat
+main.wl5928
+main.server_uuid
+main.show_processlist_state
+main.events_and_binlog
+main.show_profile
+main.show_variables
+main.xa
+main.flush_block_commit_notembedded
+main.utility_warnings
+main.trigger-trans
+main.shutdown
+main.create_select_tmp
+main.ctype_cp932_binlog_row
+main.ctype_gbk_binlog
+main.signal
+main.mysql_binary_mode
+main.signal_demo1
+main.signal_demo2
+main.signal_sqlmode
+main.partition_exchange
+main.innodb_mysql_lock2
+main.partition_innodb_stmt
+main.tablelock
+main.temporal_literal
+main.sp-big
+main.sp-bugs
+main.mysqlbinlog_mixed_or_statment
+main.mysqldump_restore
+main.strict_autoinc_1myisam
+main.strict_autoinc_3heap
+main.partition_binlog
+main.partition_binlog_stmt
+main.user_lock
+main.partition_explicit_prune
+main.variables_community
+main.sp_trans_log
+main.archive
+main.partition_grant
+main.auth_rpl
+main.sp_trans
+main.commit_1innodb
+main.trigger_wl3253
+main.partition_hash
+main.partition_index_innodb
+main.mysqlbinlog_raw_mode
+main.wl3836
+main.timezone
+main.myisam_row_rpl
+main.xa_deadlock_binlog
+main.rpl_connect_attr
+main.bug12368203
+main.rpl_mysqldump_slave
+main.myisam-system
+main.mix2_myisam_ucs2
+main.mysql_upgrade_with_session_user
+main.mysql_upgrade_ssl
+main.mysql_upgrade_slave_master_info
+main.lock_multi_bug38691
+main.lock_multi_bug38499
diff --git a/mysql-test/suite/tianmu/r/alter_table1.result b/mysql-test/suite/tianmu/r/alter_table1.result
index 8694cec97..5d2b1a3b4 100644
--- a/mysql-test/suite/tianmu/r/alter_table1.result
+++ b/mysql-test/suite/tianmu/r/alter_table1.result
@@ -9,7 +9,7 @@ CREATE TABLE st1
name VARCHAR(25),
deptId INT(11),
salary FLOAT
-);
+) engine=tianmu;
alter table st1 add column test varchar(4);
alter table st1 add column test1 varchar(4) after test;
alter table st1 add column test3 varchar(4);
@@ -36,7 +36,7 @@ CREATE TABLE st2
name VARCHAR(25),
deptId INT(11),
salary FLOAT
-);
+) engine=tianmu;
insert into st2 values(3,'haha1',45,4.5);
insert into st2 values(1,'haha2',12,1.2);
insert into st2 values(4,'haha3',31,3.2);
@@ -68,7 +68,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
ALTER TABLE st3 RENAME to st4 ;
ALTER TABLE st4 RENAME as st3 ;
ALTER TABLE st3 RENAME to st4 ;
@@ -87,7 +87,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
alter table st5 modify name varchar(20);
alter table st5 modify column name varchar(24);
alter table st5 modify column name varchar(15) after salary;
@@ -98,7 +98,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
alter table st6 rename to st7,add name1 varchar(10);
desc st7;
Field Type Null Key Default Extra
@@ -138,4 +138,9 @@ salary float YES NULL
name varchar(20) YES NULL
name2 varchar(10) YES NULL
name3 varchar(10) YES NULL
+DROP TABLE st8;
+DROP TABLE st5;
+DROP TABLE st4;
+DROP TABLE st2;
+DROP TABLE st1;
drop database alter_table1_test;
diff --git a/mysql-test/suite/tianmu/r/bigint_unsigned.result b/mysql-test/suite/tianmu/r/bigint_unsigned.result
new file mode 100644
index 000000000..b54e4cd0a
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/bigint_unsigned.result
@@ -0,0 +1,359 @@
+#
+# Test bigint unsigned
+#
+DROP DATABASE IF EXISTS bigint_unsigned_test;
+CREATE DATABASE bigint_unsigned_test;
+USE bigint_unsigned_test;
+select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
+0 256 00000000000000065536 2147483647 -2147483648 2147483648 4294967296
+0 256 65536 2147483647 -2147483648 2147483648 4294967296
+select 9223372036854775807,-009223372036854775808;
+9223372036854775807 -009223372036854775808
+9223372036854775807 -9223372036854775808
+select +9999999999999999999,-9999999999999999999;
+9999999999999999999 -9999999999999999999
+9999999999999999999 -9999999999999999999
+select cast(9223372036854775808 as unsigned)+1;
+cast(9223372036854775808 as unsigned)+1
+9223372036854775809
+select 9223372036854775808+1;
+9223372036854775808+1
+9223372036854775809
+select -(0-3),round(-(0-3)), round(9999999999999999999);
+-(0-3) round(-(0-3)) round(9999999999999999999)
+3 3 9999999999999999999
+select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001;
+1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
+1 11 101 1001 10001 100001 1000001 10000001 100000001 1000000001 10000000001 100000000001 1000000000001 10000000000001 100000000000001 1000000000000001 10000000000000001 100000000000000001 1000000000000000001 10000000000000000001
+select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001;
+-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
+-1 -11 -101 -1001 -10001 -100001 -1000001 -10000001 -100000001 -1000000001 -10000000001 -100000000001 -1000000000001 -10000000000001 -100000000000001 -1000000000000001 -10000000000000001 -100000000000000001 -1000000000000000001 -10000000000000000001
+select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16);
+conv(1,10,16) conv((1<<2)-1,10,16) conv((1<<10)-2,10,16) conv((1<<16)-3,10,16) conv((1<<25)-4,10,16) conv((1<<31)-5,10,16) conv((1<<36)-6,10,16) conv((1<<47)-7,10,16) conv((1<<48)-8,10,16) conv((1<<55)-9,10,16) conv((1<<56)-10,10,16) conv((1<<63)-11,10,16)
+1 3 3FE FFFD 1FFFFFC 7FFFFFFB FFFFFFFFA 7FFFFFFFFFF9 FFFFFFFFFFF8 7FFFFFFFFFFFF7 FFFFFFFFFFFFF6 7FFFFFFFFFFFFFF5
+create table t1 (a bigint unsigned not null, primary key(a));
+insert into t1 values (9223372036854775807), (0xFFFFFFFFFFFFFF), (9223372036854775806), (9223372036854775805);
+select * from t1 order by 1;
+a
+72057594037927935
+9223372036854775805
+9223372036854775806
+9223372036854775807
+select * from t1 where a=9223372036854775807;
+a
+9223372036854775807
+select * from t1 where a='9223372036854775807';
+a
+9223372036854775807
+delete from t1 where a=9223372036854775807;
+select * from t1 order by 1;
+a
+72057594037927935
+9223372036854775805
+9223372036854775806
+drop table t1;
+create table t1 ( a int not null default 1, big bigint );
+insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(9223372036854775805);
+select * from t1;
+a big
+1 -1
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775805
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+alter table t1 modify big bigint unsigned not null;
+ERROR 22003: Out of range value for column 'big' at row 1
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+insert into t1 (big) values (9223372036854775807);
+select * from t1;
+a big
+1 -1
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775805
+1 9223372036854775807
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+alter table t1 modify big bigint not null;
+select * from t1;
+a big
+1 -1
+1 12345678901234567
+1 9223372036854775807
+1 9223372036854775805
+1 9223372036854775807
+select min(big),max(big),max(big)-1 from t1;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+select min(big),max(big),max(big)-1 from t1 group by a;
+min(big) max(big) max(big)-1
+-1 9223372036854775807 9223372036854775806
+drop table t1;
+create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
+insert into t1 values (null,1);
+select * from t1;
+id a
+9999999999 1
+select * from t1 limit 9999999999;
+id a
+9999999999 1
+drop table t1;
+CREATE TABLE t1 (quantity decimal(18,0));
+insert into t1 values (100000000000000);
+insert into t1 values (10000000000000.0);
+insert into t1 values ('10000000000000');
+select * from t1;
+quantity
+100000000000000
+10000000000000
+10000000000000
+drop table t1;
+SELECT '0x8000000000000001'+0;
+'0x8000000000000001'+0
+0
+Warnings:
+Warning 1292 Truncated incorrect DOUBLE value: '0x8000000000000001'
+create table t1 (
+value64 bigint unsigned not null,
+value32 integer not null,
+primary key(value64, value32)
+);
+create table t2 (
+value64 bigint unsigned not null,
+value32 integer not null,
+primary key(value64, value32)
+);
+insert into t1 values(9223372036854775806, 1);
+insert into t1 values(9223372036854775807, 2);
+insert into t2 values(9223372036854775806, 3);
+insert into t2 values(9223372036854775807, 4);
+select * from t1;
+value64 value32
+9223372036854775806 1
+9223372036854775807 2
+select * from t2;
+value64 value32
+9223372036854775806 3
+9223372036854775807 4
+select * from t1, t2 where t1.value64=9223372036854775806 and t2.value64=9223372036854775806;
+value64 value32 value64 value32
+9223372036854775806 1 9223372036854775806 3
+select * from t1, t2 where t1.value64=9223372036854775806 and t2.value64=t1.value64;
+value64 value32 value64 value32
+9223372036854775806 1 9223372036854775806 3
+select * from t1, t2 where t1.value64= 9223372036854775807 and t2.value64=9223372036854775807;
+value64 value32 value64 value32
+9223372036854775807 2 9223372036854775807 4
+select * from t1, t2 where t1.value64= 9223372036854775807 and t2.value64=t1.value64;
+value64 value32 value64 value32
+9223372036854775807 2 9223372036854775807 4
+drop table t1, t2;
+create table t1 (sint64 bigint not null);
+insert into t1 values (-9223372036854775806);
+select * from t1;
+sint64
+-9223372036854775806
+drop table t1;
+create table t1 (a char(100), b varchar(100), c text, d blob);
+insert into t1 values(
+18446744073709551615,18446744073709551615,
+18446744073709551615, 18446744073709551615
+);
+insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
+select * from t1;
+a b c d
+18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+18446744073709551615 18446744073709551615 18446744073709551615 18446744073709551615
+drop table t1;
+create table t1 (quantity decimal(2) unsigned);
+insert into t1 values (50), (0), (1);
+select * from t1;
+quantity
+50
+0
+1
+drop table t1;
+select cast(9223372036854775807 as unsigned) mod 50 as result;
+result
+7
+create table t1 (c1 bigint unsigned);
+insert into t1 values (9223372036854775807);
+select c1 mod 50 as result from t1;
+result
+7
+drop table t1;
+select cast(19999999999999999999 as signed);
+cast(19999999999999999999 as signed)
+9223372036854775807
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: '19999999999999999999'
+select cast(-19999999999999999999 as signed);
+cast(-19999999999999999999 as signed)
+-9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: '-19999999999999999999'
+select -9223372036854775808;
+-9223372036854775808
+-9223372036854775808
+select -(9223372036854775808);
+-(9223372036854775808)
+-9223372036854775808
+select -((9223372036854775808));
+-((9223372036854775808))
+-9223372036854775808
+select -(-(9223372036854775808));
+-(-(9223372036854775808))
+9223372036854775808
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+--9223372036854775808 ---9223372036854775808 ----9223372036854775808
+9223372036854775808 -9223372036854775808 9223372036854775808
+select -(-9223372036854775808), -(-(-9223372036854775808));
+-(-9223372036854775808) -(-(-9223372036854775808))
+9223372036854775808 -9223372036854775808
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY,
+a BIGINT(20) UNSIGNED,
+b VARCHAR(20));
+INSERT INTO t1 (a) VALUES
+(0),
+(CAST(0x7FFFFFFFFFFFFFF AS UNSIGNED)),
+(CAST(0x800000000000000 AS UNSIGNED)),
+(CAST(0xFFFFFFFFFFFFFFF AS UNSIGNED));
+UPDATE t1 SET b = a;
+select * from t1;
+id a b
+1 0 0
+2 576460752303423487 576460752303423487
+3 576460752303423488 576460752303423488
+4 1152921504606846975 1152921504606846975
+DROP TABLE t1;
+CREATE TABLE t_bigint(id BIGINT);
+INSERT INTO t_bigint VALUES (1), (2);
+SELECT id, id >= 1.1 FROM t_bigint;
+id id >= 1.1
+1 0
+2 1
+SELECT id, 1.1 <= id FROM t_bigint;
+id 1.1 <= id
+1 0
+2 1
+SELECT id, id = 1.1 FROM t_bigint;
+id id = 1.1
+1 0
+2 0
+SELECT id, 1.1 = id FROM t_bigint;
+id 1.1 = id
+1 0
+2 0
+SELECT * from t_bigint WHERE id = 1.1;
+id
+SELECT * from t_bigint WHERE id = 1.1e0;
+id
+SELECT * from t_bigint WHERE id IN (1.1, 2.2);
+id
+SELECT * from t_bigint WHERE id IN (1.1e0, 2.2e0);
+id
+SELECT * from t_bigint WHERE id BETWEEN 1.1 AND 1.9;
+id
+SELECT * from t_bigint WHERE id BETWEEN 1.1e0 AND 1.9e0;
+id
+DROP TABLE t_bigint;
+CREATE TABLE t1 (a BIGINT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE coalesce(a) BETWEEN 0 and 0.9;
+a
+SELECT * FROM t1 WHERE coalesce(a)=0.9;
+a
+SELECT * FROM t1 WHERE coalesce(a) in (0.8,0.9);
+a
+SELECT * FROM t1 WHERE a BETWEEN 0 AND 0.9;
+a
+SELECT * FROM t1 WHERE a=0.9;
+a
+SELECT * FROM t1 WHERE a IN (0.8,0.9);
+a
+DROP TABLE t1;
+create table t (id bigint unsigned, b int);
+insert into t values(7223372036854775807,1);
+insert into t values(7223372036854775806,2);
+insert into t values(9223372036854775805,3);
+select count(*) from t
+where id>=7223372036854775806 and id <=9223372036854775807;
+count(*)
+3
+select count(*) from t
+where id between 7223372036854775806 and 9223372036854775807;
+count(*)
+3
+alter table t add primary key (id);
+select count(*) from t
+where id>=7223372036854775806 and id <=9223372036854775807;
+count(*)
+3
+select count(*) from t
+where id between 7223372036854775806 and 9223372036854775807;
+count(*)
+3
+drop table t;
+SELECT (184467440737095 BETWEEN 0 AND 18446744073709551500);
+(184467440737095 BETWEEN 0 AND 18446744073709551500)
+1
+SELECT 184467440737095 >= 0;
+184467440737095 >= 0
+1
+SELECT 0 <= 18446744073709551500;
+0 <= 18446744073709551500
+1
+SELECT CAST(100 AS UNSIGNED) BETWEEN 1 AND -1;
+CAST(100 AS UNSIGNED) BETWEEN 1 AND -1
+0
+SELECT CAST(100 AS UNSIGNED) NOT BETWEEN 1 AND -1;
+CAST(100 AS UNSIGNED) NOT BETWEEN 1 AND -1
+1
+SELECT CAST(0 AS UNSIGNED) BETWEEN 0 AND -1;
+CAST(0 AS UNSIGNED) BETWEEN 0 AND -1
+0
+SELECT CAST(0 AS UNSIGNED) NOT BETWEEN 0 AND -1;
+CAST(0 AS UNSIGNED) NOT BETWEEN 0 AND -1
+1
+select -9223372036854775808 mod 9223372036854775810 as result;
+result
+-9223372036854775808
+select bin(convert(-9223372036854775808 using ucs2));
+bin(convert(-9223372036854775808 using ucs2))
+1000000000000000000000000000000000000000000000000000000000000000
+SELECT ( 9223372036854775808 BETWEEN 9223372036854775808 AND 9223372036854775808 );
+( 9223372036854775808 BETWEEN 9223372036854775808 AND 9223372036854775808 )
+1
+SELECT ( 9223372036854775807 BETWEEN 9223372036854775808 AND 1 );
+( 9223372036854775807 BETWEEN 9223372036854775808 AND 1 )
+0
+SELECT ( -1 BETWEEN 9223372036854775808 AND 1 );
+( -1 BETWEEN 9223372036854775808 AND 1 )
+1
+SELECT ( 0 BETWEEN 9223372036854775808 AND 1 );
+( 0 BETWEEN 9223372036854775808 AND 1 )
+1
+SELECT ( 1 BETWEEN 9223372036854775808 AND 1 );
+( 1 BETWEEN 9223372036854775808 AND 1 )
+1
+drop DATABASE bigint_unsigned_test;
diff --git a/mysql-test/suite/tianmu/r/case_when.result b/mysql-test/suite/tianmu/r/case_when.result
new file mode 100644
index 000000000..fa99084b6
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/case_when.result
@@ -0,0 +1,192 @@
+#
+# test case when
+#
+DROP DATABASE IF EXISTS case_when_test;
+CREATE DATABASE case_when_test;
+USE case_when_test;
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+select CASE "b" when "a" then 1 when "b" then 2 END;
+CASE "b" when "a" then 1 when "b" then 2 END
+2
+select CASE "c" when "a" then 1 when "b" then 2 END;
+CASE "c" when "a" then 1 when "b" then 2 END
+NULL
+select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
+CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END
+3
+select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
+CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END
+ok
+select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
+CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END
+ok
+select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
+CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end
+a
+select CASE when 1=0 then "true" else "false" END;
+CASE when 1=0 then "true" else "false" END
+false
+select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
+CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END
+one
+select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
+CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END
+two
+select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
+(CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0
+2
+select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
+(CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0
+2.00
+select case 1/0 when "a" then "true" else "false" END;
+case 1/0 when "a" then "true" else "false" END
+false
+select case 1/0 when "a" then "true" END;
+case 1/0 when "a" then "true" END
+NULL
+select (case 1/0 when "a" then "true" END) | 0;
+(case 1/0 when "a" then "true" END) | 0
+NULL
+select (case 1/0 when "a" then "true" END) + 0.0;
+(case 1/0 when "a" then "true" END) + 0.0
+NULL
+select case when 1>0 then "TRUE" else "FALSE" END;
+case when 1>0 then "TRUE" else "FALSE" END
+TRUE
+select case when 1<0 then "TRUE" else "FALSE" END;
+case when 1<0 then "TRUE" else "FALSE" END
+FALSE
+create table t1 (a int);
+insert into t1 values(1),(2),(3),(4);
+select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase order by fcase;
+fcase count(*)
+0 2
+2 1
+3 1
+select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase order by fcase;
+fcase count(*)
+nothing 2
+one 1
+two 1
+drop table t1;
+create table t1 (row int not null, col int not null, val varchar(255) not null);
+insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
+select max(case col when 1 then val else null end) as color from t1 group by row;
+color
+orange
+yellow
+green
+drop table t1;
+SET NAMES latin1;
+CREATE TABLE t1 SELECT
+CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
+CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
+CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
+CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
+CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
+CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
+CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
+CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
+CASE WHEN 1 THEN 1.0 END AS c9,
+CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
+CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
+CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
+;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
+ `c2` varchar(1) CHARACTER SET latin1 COLLATE latin1_danish_ci NOT NULL DEFAULT '',
+ `c3` varchar(1) NOT NULL DEFAULT '',
+ `c4` varchar(1) NOT NULL DEFAULT '',
+ `c5` varchar(4) NOT NULL DEFAULT '',
+ `c6` varchar(4) NOT NULL DEFAULT '',
+ `c7` decimal(2,1) NOT NULL DEFAULT '0.0',
+ `c8` decimal(2,1) NOT NULL DEFAULT '0.0',
+ `c9` decimal(2,1) DEFAULT NULL,
+ `c10` double NOT NULL DEFAULT '0',
+ `c11` double NOT NULL DEFAULT '0',
+ `c12` varchar(5) NOT NULL DEFAULT ''
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SELECT CASE
+WHEN 1
+THEN _latin1'a' COLLATE latin1_danish_ci
+ELSE _latin1'a' COLLATE latin1_swedish_ci
+END;
+ERROR HY000: Illegal mix of collations (latin1_danish_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'case'
+SELECT CASE _latin1'a' COLLATE latin1_general_ci
+WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
+WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
+END;
+ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_danish_ci,EXPLICIT), (latin1_swedish_ci,EXPLICIT) for operation 'case'
+SELECT
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END;
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END
+1 2 1 2
+CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
+ERROR HY000: Illegal mix of collations (latin1_swedish_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'ifnull'
+SELECT 'case+union+test'
+UNION
+SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
+case+union+test
+case+union+test
+nobug
+SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
+CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END
+nobug
+SELECT 'case+union+test'
+UNION
+SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
+case+union+test
+case+union+test
+nobug
+create table t1(a float, b int default 3);
+insert into t1 (a) values (2), (11), (8);
+select min(a), min(case when 1=1 then a else NULL end),
+min(case when 1!=1 then NULL else a end)
+from t1 where b=3 group by b;
+min(a) min(case when 1=1 then a else NULL end) min(case when 1!=1 then NULL else a end)
+2 2 2
+drop table t1;
+CREATE TABLE t1 (EMPNUM INT);
+INSERT INTO t1 VALUES (0), (2);
+CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
+INSERT INTO t2 VALUES (0.0), (9.0);
+SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
+t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
+FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
+CEMPNUM EMPMUM1 EMPNUM2
+0.00 0 0.00
+2.00 2 NULL
+SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
+t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
+FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
+CEMPNUM EMPMUM1 EMPNUM2
+0.00 0 0.00
+2.00 2 NULL
+DROP TABLE t1,t2;
+create table t1 (a int, b bigint unsigned);
+create table t2 (c int);
+insert into t1 (a, b) values (1,457279462277), (2,1819694241997),
+(3,1114190595086);
+insert into t2 (c) values (1), (2), (3);
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+join t2 on t1.a=t2.c order by d;
+a d
+1 457279462277
+3 1114190595086
+2 1819694241997
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+join t2 on t1.a=t2.c where b=1114190595086 order by d;
+a d
+3 1114190595086
+drop table t1, t2;
+CREATE TABLE t1(a YEAR);
+SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
+1
+DROP TABLE t1;
+drop database case_when_test;
diff --git a/mysql-test/suite/tianmu/r/create_tmp.result b/mysql-test/suite/tianmu/r/create_tmp.result
new file mode 100644
index 000000000..b5b65a112
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/create_tmp.result
@@ -0,0 +1,133 @@
+#
+# Test create temporary
+#
+DROP DATABASE IF EXISTS create_tmp_test;
+CREATE DATABASE create_tmp_test;
+USE create_tmp_test;
+CREATE TEMPORARY TABLE st (
+id INT(11),
+name VARCHAR(255)
+);
+INSERT INTO st (id, name) VALUES (1, 'John');
+INSERT INTO st (id, name) VALUES (2, 'Jane');
+SELECT * FROM st;
+id name
+1 John
+2 Jane
+UPDATE st SET name = 'Johnny' WHERE id = 1;
+SELECT * FROM st;
+id name
+1 Johnny
+2 Jane
+DELETE FROM st WHERE id = 2;
+SELECT * FROM st;
+id name
+1 Johnny
+CREATE TEMPORARY TABLE st1 (
+id INT(11),
+name VARCHAR(255)
+);
+CREATE TEMPORARY TABLE st2 (
+id INT(11),
+city VARCHAR(255)
+);
+INSERT INTO st1 (id, name) VALUES (1, 'John');
+INSERT INTO st1 (id, name) VALUES (2, 'Jane');
+INSERT INTO st2 (id, city) VALUES (1, 'London');
+INSERT INTO st2 (id, city) VALUES (2, 'New York');
+SELECT st1.name, st2.city
+FROM st1 INNER JOIN st2 ON st1.id=st2.id;
+name city
+John London
+Jane New York
+create table t2 (id int(11) auto_increment primary key, score int(11), name varchar(32)) ;
+insert into t2 (score, name) values (98, 'Bob');
+select * from t2 where score > 90;
+id score name
+1 98 Bob
+create temporary table t3 like t2 ;
+insert into t3 (score, name) values (88, 'Charlie');
+select * from t3;
+id score name
+1 88 Charlie
+create table t5 (
+id int(11) unsigned auto_increment primary key,
+col1 varchar(32),
+col2 datetime,
+col3 time
+) ;
+insert into t5 (col1, col2, col3) values ('aaa', '2022-01-17 15:22:00', '12:00:00');
+insert into t5 (col1, col2, col3) values ('bbb', '2022-01-18 10:10:10', '20:00:00');
+insert into t5 (col1, col2, col3) values ('ccc', '2022-01-19 15:45:32', '18:45:00');
+select * from t5 where col1 = 'aaa';
+id col1 col2 col3
+1 aaa 2022-01-17 15:22:00 12:00:00
+create temporary table temp_t6 like t5 ;
+insert into temp_t6 (col1, col2, col3) select col1, col2, col3 from t5 where col1 between 'aaa' and 'bbb';
+select * from temp_t6 order by col2 desc;
+id col1 col2 col3
+2 bbb 2022-01-18 10:10:10 20:00:00
+1 aaa 2022-01-17 15:22:00 12:00:00
+drop temporary table if exists temp_t7;
+Warnings:
+Note 1051 Unknown table 'create_tmp_test.temp_t7'
+create temporary table temp_t7(
+id int(11)unsigned auto_increment primary key,
+col1 varchar(32)
+);
+insert into temp_t7(col1)values('apple'),('banana'),('orange'),('watermelon'),('grapefruit');
+select * from temp_t7 order by id desc;
+id col1
+5 grapefruit
+4 watermelon
+3 orange
+2 banana
+1 apple
+create temporary table temp_t8(id int(11) unsigned auto_increment primary key, col1 varchar(32), col2 datetime, status char(1)) ;
+insert into temp_t8(col1,col2,status)values('aaa','2022-02-19 09:21:40','Y'),('bbb','2022-02-20 14:15:23','N'),('ccc','2022-02-21 22:30:10','Y'),('ddd','2022-02-22 08:50:20','N'),('eee','2022-02-23 10:35:59','Y');
+select * from temp_t8;
+id col1 col2 status
+1 aaa 2022-02-19 09:21:40 Y
+2 bbb 2022-02-20 14:15:23 N
+3 ccc 2022-02-21 22:30:10 Y
+4 ddd 2022-02-22 08:50:20 N
+5 eee 2022-02-23 10:35:59 Y
+create temporary table temp_t9(id int(11) unsigned auto_increment primary key, col3 varchar(32), col4 int(11),price decimal(8,2));
+insert into temp_t9(col3, col4, price) values('code11', 10, 523.2),('code22', 20 , 2480),('code33', 30, 89.99),('code44', 40, 5200.55);
+select * from temp_t9;
+id col3 col4 price
+1 code11 10 523.20
+2 code22 20 2480.00
+3 code33 30 89.99
+4 code44 40 5200.55
+CREATE TEMPORARY TABLE temp_t10 SELECT * FROM temp_t9 LIMIT 3;
+select * from temp_t10;
+id col3 col4 price
+1 code11 10 523.20
+2 code22 20 2480.00
+3 code33 30 89.99
+drop table if exists t1,t2,t3;
+Warnings:
+Note 1051 Unknown table 'create_tmp_test.t1'
+CREATE TEMPORARY TABLE t1 (c1 DECIMAL(10,2));
+INSERT INTO t1 VALUES (10.00), (-24.53), (5936.28);
+CREATE TEMPORARY TABLE t2 (c1 DECIMAL(38,10));
+INSERT INTO t2 VALUES (1.23), (-2.78), (99.99);
+CREATE TEMPORARY TABLE t3 (c1 DECIMAL(12,5), c2 DECIMAL(20,8));
+INSERT INTO t3 VALUES (123.45678, 450.04510000), (-234.54628, 2434.87654865);
+SELECT *, LENGTH(c1) FROM t1;
+c1 LENGTH(c1)
+10.00 5
+-24.53 6
+5936.28 7
+SELECT *, LENGTH(c1) FROM t2;
+c1 LENGTH(c1)
+1.2300000000 12
+-2.7800000000 13
+99.9900000000 13
+SELECT *, LENGTH(c1), LENGTH(c2) FROM t3;
+c1 c2 LENGTH(c1) LENGTH(c2)
+123.45678 450.04510000 9 12
+-234.54628 2434.87654865 10 13
+DROP TEMPORARY TABLE t1, t2, t3;
+DROP DATABASE create_tmp_test;
diff --git a/mysql-test/suite/tianmu/r/date_formats.result b/mysql-test/suite/tianmu/r/date_formats.result
new file mode 100644
index 000000000..8898424f1
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/date_formats.result
@@ -0,0 +1,420 @@
+#
+# Test of date format functions
+#
+DROP DATABASE IF EXISTS date_formats_test;
+CREATE DATABASE date_formats_test;
+USE date_formats_test;
+select str_to_date(concat('15-01-2001',' 2:59:58.999'),
+concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
+str_to_date(concat('15-01-2001',' 2:59:58.999'),
+concat('%d-%m-%Y',' ','%H:%i:%s.%f'))
+2001-01-15 02:59:58.999000
+select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
+STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T')
+NULL
+Warnings:
+Warning 1411 Incorrect time value: '22.30.61' for function str_to_date
+Warning 1411 Incorrect datetime value: '2004.12.12 22.30.61' for function str_to_date
+SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+Warnings:
+Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
+create table t1 (date char(30), format char(30) not null);
+insert into t1 values
+('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
+('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
+#bug1495('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
+#bug1495('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
+#bug1495('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+#bug1495('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
+('10:20:10', '%H:%i:%s'),
+('10:20:10', '%h:%i:%s.%f'),
+('10:20:10', '%T'),
+('10:20:10AM', '%h:%i:%s%p'),
+('10:20:10AM', '%r'),
+#bug1495('10:20:10.44AM', '%h:%i:%s.%f%p'),
+('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
+('15 September 2001', '%d %M %Y'),
+('15 SEPTEMB 2001', '%d %M %Y'),
+('15 MAY 2001', '%d %b %Y'),
+('15th May 2001', '%D %b %Y'),
+('Sunday 15 MAY 2001', '%W %d %b %Y'),
+('Sund 15 MAY 2001', '%W %d %b %Y'),
+('Tuesday 00 2002', '%W %U %Y'),
+('Thursday 53 1998', '%W %u %Y'),
+('Sunday 01 2001', '%W %v %x'),
+('Tuesday 52 2001', '%W %V %X'),
+('060 2004', '%j %Y'),
+('4 53 1998', '%w %u %Y'),
+('15-01-2001', '%d-%m-%Y %H:%i:%S'),
+('15-01-20', '%d-%m-%y'),
+('15-2001-1', '%d-%Y-%c');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12.000000
+10:20:10 %H:%i:%s 0000-00-00 10:20:10.000000
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10.000000
+10:20:10 %T 0000-00-00 10:20:10.000000
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10.000000
+10:20:10AM %r 0000-00-00 10:20:10.000000
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58.000000
+15 September 2001 %d %M %Y 2001-09-15 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00.000000
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00.000000
+15th May 2001 %D %b %Y 2001-05-15 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00.000000
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00.000000
+Sunday 01 2001 %W %v %x 2001-01-07 00:00:00.000000
+Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00.000000
+060 2004 %j %Y 2004-02-29 00:00:00.000000
+4 53 1998 %w %u %Y 1998-12-31 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00.000000
+15-01-20 %d-%m-%y 2020-01-15 00:00:00.000000
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00.000000
+select date,format,concat('',str_to_date(date, format)) as con from t1;
+date format con
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12.000000
+10:20:10 %H:%i:%s 0000-00-00 10:20:10.000000
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10.000000
+10:20:10 %T 0000-00-00 10:20:10.000000
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10.000000
+10:20:10AM %r 0000-00-00 10:20:10.000000
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58.000000
+15 September 2001 %d %M %Y 2001-09-15 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00.000000
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00.000000
+15th May 2001 %D %b %Y 2001-05-15 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00.000000
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00.000000
+Sunday 01 2001 %W %v %x 2001-01-07 00:00:00.000000
+Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00.000000
+060 2004 %j %Y 2004-02-29 00:00:00.000000
+4 53 1998 %w %u %Y 1998-12-31 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00.000000
+15-01-20 %d-%m-%y 2020-01-15 00:00:00.000000
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00.000000
+select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
+date format datetime
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 10:11:12
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02 08:11:02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12
+10:20:10 %H:%i:%s 0000-00-00 10:20:10
+10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10
+10:20:10 %T 0000-00-00 10:20:10
+10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10
+10:20:10AM %r 0000-00-00 10:20:10
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58
+15 September 2001 %d %M %Y 2001-09-15 00:00:00
+15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00
+15 MAY 2001 %d %b %Y 2001-05-15 00:00:00
+15th May 2001 %D %b %Y 2001-05-15 00:00:00
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15 00:00:00
+Tuesday 00 2002 %W %U %Y 2002-01-01 00:00:00
+Thursday 53 1998 %W %u %Y 1998-12-31 00:00:00
+Sunday 01 2001 %W %v %x 2001-01-07 00:00:00
+Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00
+060 2004 %j %Y 2004-02-29 00:00:00
+4 53 1998 %w %u %Y 1998-12-31 00:00:00
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00
+15-01-20 %d-%m-%y 2020-01-15 00:00:00
+15-2001-1 %d-%Y-%c 2001-01-15 00:00:00
+select date,format,DATE(str_to_date(date, format)) as date2 from t1;
+date format date2
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 2003-01-02
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 2003-01-02
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02
+10:20:10 %H:%i:%s 0000-00-00
+10:20:10 %h:%i:%s.%f 0000-00-00
+10:20:10 %T 0000-00-00
+10:20:10AM %h:%i:%s%p 0000-00-00
+10:20:10AM %r 0000-00-00
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15
+15 September 2001 %d %M %Y 2001-09-15
+15 SEPTEMB 2001 %d %M %Y 2001-09-15
+15 MAY 2001 %d %b %Y 2001-05-15
+15th May 2001 %D %b %Y 2001-05-15
+Sunday 15 MAY 2001 %W %d %b %Y 2001-05-15
+Sund 15 MAY 2001 %W %d %b %Y 2001-05-15
+Tuesday 00 2002 %W %U %Y 2002-01-01
+Thursday 53 1998 %W %u %Y 1998-12-31
+Sunday 01 2001 %W %v %x 2001-01-07
+Tuesday 52 2001 %W %V %X 2002-01-01
+060 2004 %j %Y 2004-02-29
+4 53 1998 %w %u %Y 1998-12-31
+15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15
+15-01-20 %d-%m-%y 2020-01-15
+15-2001-1 %d-%Y-%c 2001-01-15
+select date,format,TIME(str_to_date(date, format)) as time from t1;
+date format time
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000
+10:20:10 %H:%i:%s 10:20:10.000000
+10:20:10 %h:%i:%s.%f 10:20:10.000000
+10:20:10 %T 10:20:10.000000
+10:20:10AM %h:%i:%s%p 10:20:10.000000
+10:20:10AM %r 10:20:10.000000
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000
+15 September 2001 %d %M %Y 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 00:00:00.000000
+15 MAY 2001 %d %b %Y 00:00:00.000000
+15th May 2001 %D %b %Y 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 00:00:00.000000
+Thursday 53 1998 %W %u %Y 00:00:00.000000
+Sunday 01 2001 %W %v %x 00:00:00.000000
+Tuesday 52 2001 %W %V %X 00:00:00.000000
+060 2004 %j %Y 00:00:00.000000
+4 53 1998 %w %u %Y 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000
+15-01-20 %d-%m-%y 00:00:00.000000
+15-2001-1 %d-%Y-%c 00:00:00.000000
+select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
+date format time2
+2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12.000000
+03-01-02 8:11:2.123456 %y-%m-%d %H:%i:%S.%# 08:11:02.000000
+03-01-02 8:11:2.123456 %Y-%m-%d %H:%i:%S.%# 08:11:02.000000
+2003-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 22:11:12.000000
+2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12.000000
+10:20:10 %H:%i:%s 10:20:10.000000
+10:20:10 %h:%i:%s.%f 10:20:10.000000
+10:20:10 %T 10:20:10.000000
+10:20:10AM %h:%i:%s%p 10:20:10.000000
+10:20:10AM %r 10:20:10.000000
+15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58.000000
+15 September 2001 %d %M %Y 00:00:00.000000
+15 SEPTEMB 2001 %d %M %Y 00:00:00.000000
+15 MAY 2001 %d %b %Y 00:00:00.000000
+15th May 2001 %D %b %Y 00:00:00.000000
+Sunday 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Sund 15 MAY 2001 %W %d %b %Y 00:00:00.000000
+Tuesday 00 2002 %W %U %Y 00:00:00.000000
+Thursday 53 1998 %W %u %Y 00:00:00.000000
+Sunday 01 2001 %W %v %x 00:00:00.000000
+Tuesday 52 2001 %W %V %X 00:00:00.000000
+060 2004 %j %Y 00:00:00.000000
+4 53 1998 %w %u %Y 00:00:00.000000
+15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00.000000
+15-01-20 %d-%m-%y 00:00:00.000000
+15-2001-1 %d-%Y-%c 00:00:00.000000
+select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
+concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'))
+2003-01-02 08:11:02.123456
+truncate table t1;
+insert into t1 values
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
+('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
+('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
+('10:20:10AM', '%H:%i:%s%p'),
+('15 Septembei 2001', '%d %M %Y'),
+('15 Ju 2001', '%d %M %Y'),
+('Sund 15 MA', '%W %d %b %Y'),
+('Thursdai 12 1998', '%W %u %Y'),
+('Sunday 01 2001', '%W %v %X'),
+('Tuesday 52 2001', '%W %V %x'),
+('Tuesday 52 2001', '%W %V %Y'),
+('Tuesday 52 2001', '%W %u %x'),
+('7 53 1998', '%w %u %Y'),
+(NULL, get_format(DATE,'USA'));
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
+2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
+2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
+2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
+2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
+10:20:10AM %H:%i:%s%p NULL
+15 Septembei 2001 %d %M %Y NULL
+15 Ju 2001 %d %M %Y NULL
+Sund 15 MA %W %d %b %Y NULL
+Thursdai 12 1998 %W %u %Y NULL
+Sunday 01 2001 %W %v %X NULL
+Tuesday 52 2001 %W %V %x NULL
+Tuesday 52 2001 %W %V %Y NULL
+Tuesday 52 2001 %W %u %x NULL
+7 53 1998 %w %u %Y NULL
+NULL %m.%d.%Y NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
+Warning 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
+Warning 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+date format con
+2003-01-02 10:11:12 PM %Y-%m-%d %H:%i:%S %p NULL
+2003-01-02 10:11:12.123456 %Y-%m-%d %h:%i:%S %p NULL
+2003-01-02 10:11:12AM %Y-%m-%d %h:%i:%S.%f %p NULL
+2003-01-02 10:11:12AN %Y-%m-%d %h:%i:%S%p NULL
+2003-01-02 10:11:12 PM %y-%m-%d %H:%i:%S %p NULL
+10:20:10AM %H:%i:%s%p NULL
+15 Septembei 2001 %d %M %Y NULL
+15 Ju 2001 %d %M %Y NULL
+Sund 15 MA %W %d %b %Y NULL
+Thursdai 12 1998 %W %u %Y NULL
+Sunday 01 2001 %W %v %X NULL
+Tuesday 52 2001 %W %V %x NULL
+Tuesday 52 2001 %W %V %Y NULL
+Tuesday 52 2001 %W %u %x NULL
+7 53 1998 %w %u %Y NULL
+NULL %m.%d.%Y NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12.123456' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AM' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12AN' for function str_to_date
+Warning 1411 Incorrect datetime value: '2003-01-02 10:11:12 PM' for function str_to_date
+Warning 1411 Incorrect datetime value: '10:20:10AM' for function str_to_date
+Warning 1411 Incorrect datetime value: '15 Septembei 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: '15 Ju 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Sund 15 MA' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Thursdai 12 1998' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Sunday 01 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: 'Tuesday 52 2001' for function str_to_date
+Warning 1411 Incorrect datetime value: '7 53 1998' for function str_to_date
+truncate table t1;
+insert into t1 values
+('10:20:10AM', '%h:%i:%s'),
+('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
+('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
+select date,format,str_to_date(date, format) as str_to_date from t1;
+date format str_to_date
+10:20:10AM %h:%i:%s 0000-00-00 10:20:10.000000
+2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12.000000
+03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+date format con
+10:20:10AM %h:%i:%s 0000-00-00 10:20:10.000000
+2003-01-02 10:11:12 %Y-%m-%d %h:%i:%S 2003-01-02 10:11:12.000000
+03-01-02 10:11:12 PM %Y-%m-%d %h:%i:%S %p 2003-01-02 22:11:12.000000
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '10:20:10AM'
+drop table t1;
+create table t1 (d date);
+insert into t1 values ('2004-07-14'),('2005-07-14');
+select date_format(d,"%d") from t1 order by 1;
+date_format(d,"%d")
+14
+14
+drop table t1;
+select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
+a
+2003-01-02 10:11:12.001200
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+Warnings:
+Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
+select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
+str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
+str_to_date("2003-01-02", "%Y-%m-%d") as f3,
+str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
+str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
+str_to_date("02 10", "%d %f") as f6;
+f1 f2 f3 f4 f5 f6
+2003-01-02 10:11:12.001200 2003-01-02 10:11:12 2003-01-02 58:11:12.000000 58:11:12 48:00:00.100000
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012'
+select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
+addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
+microsecond("1997-12-31 23:59:59.01XXXX") as f3;
+f1 f2 f3
+2003-01-02 10:11:12.001200 -25:01:00.110000 10000
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012ABCD'
+Warning 1292 Truncated incorrect time value: '-01:01:01.01 GGG'
+Warning 1292 Truncated incorrect time value: '1997-12-31 23:59:59.01XXXX'
+select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
+str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
+f1 f2
+2003-04-05 2003-04-05 10:11:12.101010
+Warnings:
+Warning 1292 Truncated incorrect date value: '2003-04-05 g'
+Warning 1292 Truncated incorrect datetime value: '2003-04-05 10:11:12.101010234567'
+create table t1 (f1 datetime);
+insert into t1 (f1) values ("2005-01-01");
+insert into t1 (f1) values ("2005-02-01");
+select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M");
+d1 d2
+02 February
+01 January
+drop table t1;
+CREATE TABLE t1 (a varchar(10), PRIMARY KEY (a));
+CREATE TABLE t2 (a varchar(10), b date, PRIMARY KEY(a,b));
+CREATE TABLE t3 (a varchar(10), b TIME, PRIMARY KEY(a,b));
+INSERT INTO t1 VALUES ('test1');
+INSERT INTO t2 VALUES
+('test1','2016-12-13'),('test1','2016-12-14'),('test1','2016-12-15');
+INSERT INTO t3 VALUES
+('test1','11:13:14'), ('test1','12:13:14'), ('test1','10:13:14');
+SELECT *
+FROM t1 LEFT JOIN t2
+ON t2.a = 'test1' AND t2.b = '20161213'
+WHERE t1.a = 'test1';
+a a b
+test1 test1 2016-12-13
+SELECT *
+FROM t1 LEFT JOIN t2 IGNORE INDEX(PRIMARY)
+ON t2.a = 'test1' AND t2.b = '20161213'
+WHERE t1.a = 'test1';
+a a b
+test1 test1 2016-12-13
+SELECT b, b = '20161213',
+CASE b WHEN '20161213' then 'found' ELSE 'not found' END FROM t2;
+b b = '20161213' CASE b WHEN '20161213' then 'found' ELSE 'not found' END
+2016-12-13 1 found
+2016-12-14 0 not found
+2016-12-15 0 not found
+SELECT b, b IN ('20161213'), b in ('20161213', 0) FROM t2;
+b b IN ('20161213') b in ('20161213', 0)
+2016-12-13 1 1
+2016-12-14 0 0
+2016-12-15 0 0
+SELECT b, b = '121314',
+CASE b WHEN '121314' then 'found' ELSE 'not found' END FROM t3 order by 1;
+b b = '121314' CASE b WHEN '121314' then 'found' ELSE 'not found' END
+10:13:14 0 not found
+11:13:14 0 not found
+12:13:14 1 found
+SELECT b, b in ('121314'), b in ('121314', 0) FROM t3 order by 1;
+b b in ('121314') b in ('121314', 0)
+10:13:14 0 0
+11:13:14 0 0
+12:13:14 1 1
+drop database date_formats_test;
diff --git a/mysql-test/suite/tianmu/r/double_float.result b/mysql-test/suite/tianmu/r/double_float.result
index 875beb8c2..8eb3d57c7 100644
--- a/mysql-test/suite/tianmu/r/double_float.result
+++ b/mysql-test/suite/tianmu/r/double_float.result
@@ -9,11 +9,13 @@ SET default_storage_engine=tianmu;
SELECT @@default_storage_engine;
@@default_storage_engine
TIANMU
-set autocommit=0;
CREATE TABLE test1 (dkey int);
INSERT INTO test1 VALUES (1), (2), (3);
SELECT test1.dkey FROM test1 ORDER BY test1.dkey;
dkey
+1
+2
+3
CREATE TABLE qatabledouble (col DOUBLE) ;
CREATE TABLE qatablefloat (col float) ;
INSERT INTO qatabledouble VALUES (-2.225073858507201E-307);
@@ -23,23 +25,50 @@ INSERT INTO qatabledouble VALUES (1.993777023789432E+21);
INSERT INTO qatabledouble VALUES (1.797693134862315E+38);
INSERT INTO qatabledouble VALUES (-19937770237894323221);
INSERT INTO qatabledouble VALUES (17976931348623158);
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
col
+-1.9937770237894324e19
+-1.807302187774382e-127
+-2.225073858507201e-307
+0
+1.7976931348623158e16
+1.993777023789432e21
+1.797693134862315e38
INSERT INTO qatabledouble VALUES (null);
INSERT INTO qatabledouble VALUES (null);
INSERT INTO qatabledouble VALUES (null);
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
col
+NULL
+NULL
+NULL
+-1.9937770237894324e19
+-1.807302187774382e-127
+-2.225073858507201e-307
+0
+1.7976931348623158e16
+1.993777023789432e21
+1.797693134862315e38
INSERT INTO qatablefloat VALUES (null);
INSERT INTO qatablefloat VALUES (null);
INSERT INTO qatablefloat VALUES (null);
-SELECT * FROM qatablefloat;
+SELECT * FROM qatablefloat order by col;
col
+NULL
+NULL
+NULL
DELETE FROM qatabledouble WHERE col IS NULL;
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
col
+-1.9937770237894324e19
+-1.807302187774382e-127
+-2.225073858507201e-307
+0
+1.7976931348623158e16
+1.993777023789432e21
+1.797693134862315e38
delete FROM qatablefloat WHERE col IS NULL;
-SELECT * FROM qatablefloat;
+SELECT * FROM qatablefloat order by col;
col
CREATE TABLE qatabledouble_v2 (col1 DOUBLE, col2 DOUBLE, col3 DOUBLE) ;
INSERT INTO qatabledouble_v2 VALUES (-0.50, -0.50, -0.50);
@@ -67,8 +96,33 @@ INSERT INTO qatabledouble_v2 VALUES (0.0,0.0,0.0);
INSERT INTO qatabledouble_v2 VALUES (.50,.50,.50);
INSERT INTO qatabledouble_v2 VALUES (.49,.49,.49);
INSERT INTO qatabledouble_v2 VALUES (.0,.0,.0);
-SELECT * FROM qatabledouble_v2;
+SELECT * FROM qatabledouble_v2 order by col1;
col1 col2 col3
+-8 -8 -8
+-0.5 -0.5 -0.5
+-0.5 -0.5 -0.5
+-0.5 -0.5 -0.5
+-0.49 -0.49 -0.49
+-0.49 -0.49 -0.49
+-0.49 -0.49 -0.49
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+8 8 8
+8 8 8
CREATE TABLE qatablefloat_v3 (col1 float, col2 float, col3 float) ;
INSERT INTO qatablefloat_v3 VALUES (-0.50, -0.50, -0.50);
INSERT INTO qatablefloat_v3 VALUES (-0.49, -0.49, -0.49);
@@ -95,6 +149,31 @@ INSERT INTO qatablefloat_v3 VALUES (0.0,0.0,0.0);
INSERT INTO qatablefloat_v3 VALUES (.50,.50,.50);
INSERT INTO qatablefloat_v3 VALUES (.49,.49,.49);
INSERT INTO qatablefloat_v3 VALUES (.0,.0,.0);
-SELECT * FROM qatablefloat_v3;
+SELECT * FROM qatablefloat_v3 order by col1;
col1 col2 col3
+-8 -8 -8
+-0.5 -0.5 -0.5
+-0.5 -0.5 -0.5
+-0.5 -0.5 -0.5
+-0.49 -0.49 -0.49
+-0.49 -0.49 -0.49
+-0.49 -0.49 -0.49
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0 0 0
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.49 0.49 0.49
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+0.5 0.5 0.5
+8 8 8
+8 8 8
DROP DATABASE `double_float`;
diff --git a/mysql-test/suite/tianmu/r/drop_index.result b/mysql-test/suite/tianmu/r/drop_index.result
index ced3ddefc..8be386d0f 100644
--- a/mysql-test/suite/tianmu/r/drop_index.result
+++ b/mysql-test/suite/tianmu/r/drop_index.result
@@ -24,9 +24,7 @@ UNIQUE KEY `idx_uk` (`copy_id`),
KEY `idx_firstname` (`first_name`),
FULLTEXT KEY `idx_lastname` (`last_name`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
-set session sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
-Warnings:
-Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
+set session tianmu_no_key_error=OFF;
drop index idx_id on t1;
ERROR HY000: Tianmu engine does not support unique index.
drop index idx_name on t2;
diff --git a/mysql-test/suite/tianmu/r/drop_restric.result b/mysql-test/suite/tianmu/r/drop_restric.result
new file mode 100644
index 000000000..fd4c1aafd
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/drop_restric.result
@@ -0,0 +1,25 @@
+#
+# DROP TABLE RESTRICT
+# The RESTRICT clause limits the table to being dropped in the front end only.
+# This could be useful when the table has been dropped on one user module,
+# and needs to be synced to others.
+#
+DROP DATABASE IF EXISTS drop_restric_test;
+CREATE DATABASE drop_restric_test;
+USE drop_restric_test;
+CREATE TABLE t1 (id INT, name CHAR(25));
+INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five');
+SELECT * FROM t1 ORDER BY id;
+id name
+1 one
+2 two
+3 three
+4 four
+5 five
+SELECT COUNT(*) FROM t1;
+COUNT(*)
+5
+DROP TABLE IF EXISTS t1 RESTRICT;
+DROP TABLE t1;
+ERROR 42S02: Unknown table 'drop_restric_test.t1'
+DROP DATABASE IF EXISTS drop_restric_test;
diff --git a/mysql-test/suite/tianmu/r/empty_string_not_null.result b/mysql-test/suite/tianmu/r/empty_string_not_null.result
new file mode 100644
index 000000000..8730baf66
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/empty_string_not_null.result
@@ -0,0 +1,80 @@
+#
+# tests updates that sets invalid range when we set value at max boundary that is less than max.
+#
+DROP DATABASE IF EXISTS empty_string_not_null;
+CREATE DATABASE empty_string_not_null;
+USE empty_string_not_null;
+CREATE TABLE t(s text);
+INSERT INTO t(s) VALUES (''), (NULL);
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+COUNT(*)
+1
+SELECT COUNT(*) FROM t WHERE s IS NOT NULL;
+COUNT(*)
+1
+SELECT * FROM t;
+s
+
+NULL
+DROP TABLE t;
+CREATE TABLE t(s text);
+INSERT INTO t(s) VALUES ('');
+INSERT INTO t(s) VALUES (NULL);
+SELECT * FROM t;
+s
+
+NULL
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+COUNT(*)
+1
+DROP TABLE t;
+CREATE TABLE t(s text) ;
+INSERT INTO t(s) VALUES ('_CpNuLl_'),(''), (NULL);
+SELECT * FROM t;
+s
+_CpNuLl_
+
+NULL
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+COUNT(*)
+1
+DROP TABLE t;
+CREATE TABLE t(c6 CHAR(6)) ;
+INSERT INTO t(c6) VALUES ('a'), ('b'), ('c');
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= '');
+2 COUNT(*)
+2 2
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b');
+2 COUNT(*)
+2 2
+SELECT 0, COUNT(*) FROM t WHERE (c6 <= '');
+0 COUNT(*)
+0 0
+SELECT 0, COUNT(*) FROM t WHERE (c6 <= ' ');
+0 COUNT(*)
+0 0
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= ' ');
+2 COUNT(*)
+2 2
+SELECT 0, COUNT(*) FROM t WHERE (c6 < '');
+0 COUNT(*)
+0 0
+SELECT 0, COUNT(*) FROM t WHERE (c6 < ' ');
+0 COUNT(*)
+0 0
+DROP TABLE IF EXISTS t;
+CREATE TABLE t(a CHAR(10));
+INSERT INTO t(a) VALUES (''), (NULL), (' '), (' a ');
+SELECT LTRIM(a) FROM t;
+LTRIM(a)
+
+NULL
+
+a
+SELECT RTRIM(a) FROM t;
+RTRIM(a)
+
+NULL
+
+ a
+DROP DATABASE empty_string_not_null;
diff --git a/mysql-test/suite/tianmu/r/escape.result b/mysql-test/suite/tianmu/r/escape.result
index 8d7aeb4f1..5fce58bf3 100644
--- a/mysql-test/suite/tianmu/r/escape.result
+++ b/mysql-test/suite/tianmu/r/escape.result
@@ -62,6 +62,9 @@ id name uid
SELECT * FROM st1 WHERE NAME LIKE "a%a" ESCAPE "a" ;
id name uid
4 %a world
+SELECT * FROM st1 WHERE NAME LIKE "a%a_" ESCAPE "a";
+id name uid
+5 %_ world
drop table st1;
CREATE TABLE `st1` (
`id` BIGINT(20) NOT NULL AUTO_INCREMENT,
@@ -91,6 +94,9 @@ id name uid
select * from st1 where name like 'hello12_';
id name uid
3 hello123 world
+select * from st1 where name like '/_hello' escape '/';
+id name uid
+4 _hello world
create table st2(id int ,column_2 varchar(10),column_3 varchar(10));
insert into st2 values(1,'_a\\\\','111111');
insert into st2 values(2,'12%','%12%');
@@ -118,4 +124,12 @@ id column_2 column_3
1 _a\\ 111111
3 a_a a%
4 _a\ _12%
+select * from st2 where column_2 like '%?_a\\%';
+id column_2 column_3
+select * from st2 where column_2 like '%\_a\\%';
+id column_2 column_3
+select * from st2 where column_2 like '%?_a?\%';
+id column_2 column_3
+select * from st2 where column_2 like '%\_a\\%';
+id column_2 column_3
DROP DATABASE escape_test;
diff --git a/mysql-test/suite/tianmu/r/hash_join.result b/mysql-test/suite/tianmu/r/hash_join.result
new file mode 100644
index 000000000..a0d8c9e74
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/hash_join.result
@@ -0,0 +1,100 @@
+DROP DATABASE IF EXISTS hash_join_test;
+CREATE DATABASE hash_join_test;
+USE hash_join_test;
+CREATE TABLE `test1` (
+`id` varchar(64) NOT NULL COMMENT 'ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `test2` (
+`user_id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+CREATE TABLE `test3` (
+`id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+CREATE TABLE `test4` (
+`id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+insert test1 values('aaa');
+insert test1 values('bbb');
+insert test1 values('ccc');
+insert test1 values('eee');
+insert test2 values('aaa');
+insert test2 values('bbb');
+insert test2 values('ccc');
+insert test2 values('fff');
+insert test3 values('aaa');
+insert test3 values('bbb');
+insert test3 values('ccc');
+insert test3 values('ddd');
+insert test4 values('aaa');
+insert test4 values('bbb');
+insert test4 values('ccc');
+insert test4 values('hhh');
+insert test4 values('ggg');
+select test1.id,test2.user_id from test2,test1 where test2.user_id = test1.id ;
+id user_id
+aaa aaa
+bbb bbb
+ccc ccc
+select test1.id,test2.user_id,test3.id from test2,test1,test3 where test2.user_id = test1.id and test2.user_id = test3.id;
+id user_id id
+aaa aaa aaa
+bbb bbb bbb
+ccc ccc ccc
+select test1.id,test2.user_id,test3.id,test4.id from test2,test1,test3,test4 where test2.user_id = test1.id and test2.user_id = test3.id and test3.id = test4.id;
+id user_id id id
+aaa aaa aaa aaa
+bbb bbb bbb bbb
+ccc ccc ccc ccc
+CREATE TABLE `t1` (
+`id` int NOT NULL COMMENT 'ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `t2` (
+`user_id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+CREATE TABLE `t3` (
+`id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+CREATE TABLE `t4` (
+`id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+insert t1 values(101);
+insert t1 values(103);
+insert t1 values(103);
+insert t1 values(201);
+insert t2 values(101);
+insert t2 values(102);
+insert t2 values(103);
+insert t2 values(202);
+insert t3 values(101);
+insert t3 values(102);
+insert t3 values(103);
+insert t3 values(203);
+insert t4 values(101);
+insert t4 values(102);
+insert t4 values(103);
+insert t4 values(204);
+insert t4 values(205);
+select t1.id,t2.user_id from t2,t1 where t2.user_id = t1.id ;
+id user_id
+101 101
+103 103
+103 103
+select t1.id,t2.user_id,t3.id from t2,t1,t3 where t2.user_id = t1.id and t2.user_id = t3.id;
+id user_id id
+101 101 101
+103 103 103
+103 103 103
+select t1.id,t2.user_id,t3.id,t4.id from t2,t1,t3,t4 where t2.user_id = t1.id and t2.user_id = t3.id and t3.id = t4.id;
+id user_id id id
+101 101 101 101
+103 103 103 103
+103 103 103 103
+drop table test1;
+drop table test2;
+drop table test3;
+drop table test4;
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+DROP DATABASE hash_join_test;
diff --git a/mysql-test/suite/tianmu/r/in_withpk.result b/mysql-test/suite/tianmu/r/in_withpk.result
new file mode 100644
index 000000000..3fff29264
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/in_withpk.result
@@ -0,0 +1,182 @@
+#
+# Test in subquery with pk
+#
+DROP DATABASE IF EXISTS in_withpk_test;
+CREATE DATABASE in_withpk_test;
+USE in_withpk_test;
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (
+a int,
+b int,
+primary key(a)
+) ;
+insert into t1 values (1,1),(3,3),(2,2);
+create table t2 (
+a int,
+b int
+) ;
+insert into t2 select a, a/2 from t0;
+select * from t1 order by 1;
+a b
+1 1
+2 2
+3 3
+select * from t2;
+a b
+0 0
+1 1
+2 1
+3 2
+4 2
+5 3
+6 3
+7 4
+8 4
+9 5
+select * from t2 where b in (select a from t1);
+a b
+1 1
+2 1
+3 2
+4 2
+5 3
+6 3
+create table t3 (
+a int,
+b int,
+pk1 char(50), pk2 char(50), pk3 char(50),
+primary key(pk1, pk2, pk3)
+) ;
+insert into t3 select a,a, a,a,a from t0;
+select * from t3 where b in (select a from t1);
+a b pk1 pk2 pk3
+1 1 1 1 1
+2 2 2 2 2
+3 3 3 3 3
+drop table t3;
+create table t3 (
+a int,
+b int,
+pk1 char(100), pk2 char(100),
+primary key(pk1, pk2)
+) ;
+insert into t3 select
+A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
+from t0 A, t0 B where B.a <5;
+select * from t3 where b in (select a from t0);
+a b pk1 pk2
+0 0 0 0
+1 1 1 1
+2 2 2 2
+3 3 3 3
+4 4 4 4
+5 5 5 5
+6 6 6 6
+7 7 7 7
+8 8 8 8
+9 9 9 9
+select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5) order by a,b;
+a b pk1 pk2
+0 0 0 0
+1 1 1 1
+2 2 2 2
+3 3 3 3
+4 4 4 4
+5 5 5 5
+6 6 6 6
+7 7 7 7
+8 8 8 8
+9 9 9 9
+10 10 10 10
+11 11 11 11
+12 12 12 12
+13 13 13 13
+select * from t1 where a in (select b from t2) order by a;
+a b
+1 1
+2 2
+3 3
+drop table t0, t1, t2, t3;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a char(50), b char(50), c char(50), primary key (a,b,c)) ;
+insert into t2 select concat(a, repeat('X',48)),repeat('B',50),repeat('B',50) from t1;
+insert into t2 select concat(a, repeat('Y',48)),repeat('B',50),repeat('B',50) from t1;
+alter table t2 add filler1 int;
+insert into t1 select A.a + 2*(B.a + 2*C.a) from t1 A, t1 B, t1 C;
+select * from t2 where filler1 in ( select a from t1);
+a b c filler1
+drop table t1, t2;
+create table t1 (c6 timestamp);
+create table t2 (c2 double);
+insert into t2 values(12.4);
+select 1 from t2 where c2 = any (select log10(null) from t1 where c6 4567890123456789;
+q1 q2
+123 456
+4567890123456789 123
+4567890123456789 -4567890123456789
+9223372036854775807 9223372036854775806
+-9223372036854775806 -9223372036854775805
+SELECT * FROM int8_tbl WHERE q2 > 4567890123456789;
+q1 q2
+9223372036854775807 9223372036854775806
+SELECT * FROM int8_tbl WHERE q2 >= 4567890123456789;
+q1 q2
+123 4567890123456789
+4567890123456789 4567890123456789
+9223372036854775807 9223372036854775806
+SELECT * FROM int8_tbl WHERE q2 = 456;
+q1 q2
+123 456
+SELECT * FROM int8_tbl WHERE q2 <> 456;
+q1 q2
+123 4567890123456789
+4567890123456789 123
+4567890123456789 4567890123456789
+4567890123456789 -4567890123456789
+9223372036854775807 9223372036854775806
+-9223372036854775806 -9223372036854775805
+SELECT * FROM int8_tbl WHERE q2 > 456;
+q1 q2
+123 4567890123456789
+4567890123456789 4567890123456789
+9223372036854775807 9223372036854775806
+SELECT * FROM int8_tbl WHERE q2 >= 456;
+q1 q2
+123 456
+123 4567890123456789
+4567890123456789 4567890123456789
+9223372036854775807 9223372036854775806
+SELECT * FROM int8_tbl WHERE 123 = q1;
+q1 q2
+123 456
+123 4567890123456789
+SELECT * FROM int8_tbl WHERE 123 <> q1;
+q1 q2
+4567890123456789 123
+4567890123456789 4567890123456789
+4567890123456789 -4567890123456789
+9223372036854775807 9223372036854775806
+-9223372036854775806 -9223372036854775805
+SELECT * FROM int8_tbl WHERE 123 < q1;
+q1 q2
+4567890123456789 123
+4567890123456789 4567890123456789
+4567890123456789 -4567890123456789
+9223372036854775807 9223372036854775806
+SELECT * FROM int8_tbl WHERE 123 <= q1;
+q1 q2
+123 456
+123 4567890123456789
+4567890123456789 123
+4567890123456789 4567890123456789
+4567890123456789 -4567890123456789
+9223372036854775807 9223372036854775806
+drop DATABASE integer_range_test;
diff --git a/mysql-test/suite/tianmu/r/issue1065.result b/mysql-test/suite/tianmu/r/issue1065.result
index a0cf60ed7..714cf5da0 100644
--- a/mysql-test/suite/tianmu/r/issue1065.result
+++ b/mysql-test/suite/tianmu/r/issue1065.result
@@ -1,7 +1,8 @@
DROP DATABASE IF EXISTS issue1065_test;
CREATE DATABASE issue1065_test;
USE issue1065_test;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
drop table if exists t_test;
CREATE TABLE t_test(
id INT NOT NULL AUTO_INCREMENT,
@@ -38,7 +39,8 @@ insert INTO t_test(first_name,last_name,sex,score,copy_id) VALUES (firstname,las
END WHILE;
END //
drop PROCEDURE add_user;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
+set tianmu_mandatory=ON;
+set tianmu_no_key_error=ON;
create PROCEDURE add_user(in num INT)
BEGIN
DECLARE rowid INT DEFAULT 0;
@@ -65,7 +67,8 @@ insert INTO t_test(first_name,last_name,sex,score,copy_id) VALUES (firstname,las
END WHILE;
END //
drop PROCEDURE add_user;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
create PROCEDURE add_user(in num INT)
BEGIN
DECLARE rowid INT DEFAULT 0;
@@ -102,7 +105,8 @@ score INT NOT NULL,
copy_id INT NOT NULL,
PRIMARY KEY (`id`)
) engine=innodb;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
+set tianmu_mandatory=ON;
+set tianmu_no_key_error=ON;
create PROCEDURE add_user(in num INT)
BEGIN
DECLARE rowid INT DEFAULT 0;
@@ -129,7 +133,8 @@ insert INTO t_test(first_name,last_name,sex,score,copy_id) VALUES (firstname,las
END WHILE;
END //
drop PROCEDURE add_user;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
create PROCEDURE add_user(in num INT)
BEGIN
DECLARE rowid INT DEFAULT 0;
diff --git a/mysql-test/suite/tianmu/r/issue1079_366.result b/mysql-test/suite/tianmu/r/issue1079_366.result
new file mode 100644
index 000000000..30622d652
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1079_366.result
@@ -0,0 +1,57 @@
+DROP DATABASE IF EXISTS issue1079_test;
+CREATE DATABASE issue1079_test;
+USE issue1079_test;
+create table t(fi int, fv varchar(30), fdt datetime)engine=tianmu;
+insert into t values(1,'VAR-1',current_timestamp);
+insert into t values(2,'VAR-2',current_timestamp);
+insert into t values(3,'VAR-3',current_timestamp);
+insert into t values(4,'VAR-4',current_timestamp);
+insert into t values(5,'VAR-5',current_timestamp);
+insert into t values(6,'VAR-6',current_timestamp);
+insert into t values(7,'VAR-7',current_timestamp);
+insert into t values(8,'VAR-8',current_timestamp);
+insert into t values(9,'VAR-9',current_timestamp);
+insert into t values(10,'VAR-10',current_timestamp);
+select count(*) c from t;
+c
+10
+insert into t select fi+10,concat('VAR-',fi+10),current_timestamp from t;
+insert into t select fi+20,concat('VAR-',fi+20),current_timestamp from t;
+insert into t select fi+40,concat('VAR-',fi+40),current_timestamp from t;
+insert into t select fi+80,concat('VAR-',fi+80),current_timestamp from t;
+select count(*) c from t;
+c
+160
+insert into t select fi+160,concat('VAR-',fi+160),current_timestamp from t;
+insert into t select fi+320,concat('VAR-',fi+320),current_timestamp from t;
+insert into t select fi+640,concat('VAR-',fi+640),current_timestamp from t;
+select count(*) c from t;
+c
+1280
+insert into t select fi+1280,concat('VAR-',fi+1280),current_timestamp from t;
+insert into t select fi+2560,concat('VAR-',fi+2560),current_timestamp from t;
+insert into t select fi+5120,concat('VAR-',fi+5120),current_timestamp from t;
+select count(*) c from t;
+c
+10240
+insert into t select fi+10240,concat('VAR-',fi+10240),current_timestamp from t;
+insert into t select fi+20480,concat('VAR-',fi+20480),current_timestamp from t;
+select count(*) c from t;
+c
+40960
+show create table t;
+Table Create Table
+t CREATE TABLE `t` (
+ `fi` int(11) DEFAULT NULL,
+ `fv` varchar(30) DEFAULT NULL,
+ `fdt` datetime DEFAULT NULL
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
+alter table t modify column fv varchar(60);
+show create table t;
+Table Create Table
+t CREATE TABLE `t` (
+ `fi` int(11) DEFAULT NULL,
+ `fv` varchar(60) DEFAULT NULL,
+ `fdt` datetime DEFAULT NULL
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
+DROP DATABASE issue1079_test;
diff --git a/mysql-test/suite/tianmu/r/issue1090.result b/mysql-test/suite/tianmu/r/issue1090.result
index b527d1dce..ff693e48a 100644
--- a/mysql-test/suite/tianmu/r/issue1090.result
+++ b/mysql-test/suite/tianmu/r/issue1090.result
@@ -2,11 +2,11 @@ set global default_storage_engine=innodb;
include/master-slave.inc
[connection master]
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
#
[on slave]
include/sync_slave_sql_with_master.inc
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
[on master]
create table t_issue1090(c1 int,c2 varchar(255));
show create table t_issue1090;
@@ -19,7 +19,7 @@ t_issue1090 CREATE TABLE `t_issue1090` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -44,7 +44,7 @@ t_issue1090 CREATE TABLE `t_issue1090` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -61,10 +61,10 @@ t_issue1090 CREATE TABLE `t_issue1090` (
drop table t_issue1090;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='MANDATORY_TIANMU'
+# tianmu_mandatory=ON
#
[on slave]
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
[on master]
create table t_issue1090_2(c1 int,c2 varchar(255));
show create table t_issue1090_2;
@@ -75,14 +75,6 @@ t_issue1090_2 CREATE TABLE `t_issue1090_2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
-show variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_2;
Table Create Table
t_issue1090_2 CREATE TABLE `t_issue1090_2` (
@@ -100,14 +92,6 @@ t_issue1090_2 CREATE TABLE `t_issue1090_2` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
-show global variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_2;
Table Create Table
t_issue1090_2 CREATE TABLE `t_issue1090_2` (
@@ -119,10 +103,10 @@ t_issue1090_2 CREATE TABLE `t_issue1090_2` (
drop table t_issue1090_2;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
#
[on slave]
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
[on master]
create table t_issue1090_3(c1 int,c2 varchar(255));
show create table t_issue1090_3;
@@ -133,14 +117,6 @@ t_issue1090_3 CREATE TABLE `t_issue1090_3` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
-show global variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_3;
Table Create Table
t_issue1090_3 CREATE TABLE `t_issue1090_3` (
@@ -158,14 +134,6 @@ t_issue1090_3 CREATE TABLE `t_issue1090_3` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
-show global variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_3;
Table Create Table
t_issue1090_3 CREATE TABLE `t_issue1090_3` (
@@ -177,10 +145,10 @@ t_issue1090_3 CREATE TABLE `t_issue1090_3` (
drop table t_issue1090_3;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU'
+# tianmu_mandatory=ON
#
[on slave]
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
[on master]
create table t_issue1090_4(c1 int,c2 varchar(255));
show create table t_issue1090_4;
@@ -191,14 +159,6 @@ t_issue1090_4 CREATE TABLE `t_issue1090_4` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
-show global variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_4;
Table Create Table
t_issue1090_4 CREATE TABLE `t_issue1090_4` (
@@ -214,14 +174,6 @@ t_issue1090_4 CREATE TABLE `t_issue1090_4` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
[on slave]
include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
-show global variables like '%_engine';
-Variable_name Value
-default_storage_engine TIANMU
-default_tmp_storage_engine InnoDB
-internal_tmp_disk_storage_engine InnoDB
show create table t_issue1090_4;
Table Create Table
t_issue1090_4 CREATE TABLE `t_issue1090_4` (
diff --git a/mysql-test/suite/tianmu/r/issue1111.result b/mysql-test/suite/tianmu/r/issue1111.result
index eea46d34f..dc5a4fe44 100644
--- a/mysql-test/suite/tianmu/r/issue1111.result
+++ b/mysql-test/suite/tianmu/r/issue1111.result
@@ -29,6 +29,13 @@ id name
1 lllll
[on slave]
include/sync_slave_sql_with_master.inc
+show create table ttt;
+Table Create Table
+ttt CREATE TABLE `ttt` (
+ `id` int(11) NOT NULL,
+ `name` varchar(64) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
select * from ttt where id in(1,3,2) order by id desc;
id name
3 lllll
diff --git a/mysql-test/suite/tianmu/r/issue1131.result b/mysql-test/suite/tianmu/r/issue1131.result
index a4af69e29..ae6d729b1 100644
--- a/mysql-test/suite/tianmu/r/issue1131.result
+++ b/mysql-test/suite/tianmu/r/issue1131.result
@@ -1,9 +1,9 @@
use test;
drop table IF EXISTS tmp_table;
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
#
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
create table t_issue1131(c1 int,c2 varchar(255))engine=innodb;
show create table t_issue1131;
Table Create Table
@@ -11,9 +11,6 @@ t_issue1131 CREATE TABLE `t_issue1131` (
`c1` int(11) DEFAULT NULL,
`c2` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-show variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -40,9 +37,9 @@ tmp_table CREATE TEMPORARY TABLE `tmp_table` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table tmp_table;
#
-# sql_mode='MANDATORY_TIANMU'
+# tianmu_mandatory=ON
#
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set tianmu_mandatory=ON;
create table t_issue1131(c1 int,c2 varchar(255))engine=innodb;
show create table t_issue1131;
Table Create Table
@@ -50,9 +47,6 @@ t_issue1131 CREATE TABLE `t_issue1131` (
`c1` int(11) DEFAULT NULL,
`c2` varchar(255) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
-show variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
show variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -79,9 +73,9 @@ tmp_table CREATE TEMPORARY TABLE `tmp_table` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table tmp_table;
#
-# sql_mode='MANDATORY_TIANMU'
+# tianmu_mandatory=ON
# set default_storage_engine=innodb;
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set tianmu_mandatory=ON;
set default_storage_engine=innodb;
create table t_issue1131(c1 int,c2 varchar(255));
show create table t_issue1131;
@@ -90,9 +84,6 @@ t_issue1131 CREATE TABLE `t_issue1131` (
`c1` int(11) DEFAULT NULL,
`c2` varchar(255) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
-show variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
show variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
@@ -119,10 +110,10 @@ tmp_table CREATE TEMPORARY TABLE `tmp_table` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table tmp_table;
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
#
[on slave]
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
create table t_issue1131(c1 int,c2 varchar(255));
show create table t_issue1131;
Table Create Table
@@ -130,9 +121,6 @@ t_issue1131 CREATE TABLE `t_issue1131` (
`c1` int(11) DEFAULT NULL,
`c2` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
-show variables like 'sql_mode';
-Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
diff --git a/mysql-test/suite/tianmu/r/issue1173.result b/mysql-test/suite/tianmu/r/issue1173.result
new file mode 100644
index 000000000..42d7bc979
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1173.result
@@ -0,0 +1,20 @@
+DROP DATABASE IF EXISTS issue1173;
+CREATE DATABASE issue1173;
+USE issue1173;
+CREATE TABLE t1 (a TIME(1) NOT NULL);
+INSERT INTO t1 VALUES ('00:00:02.9');
+SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t1;
+a a & a a | a a^0 a<<1 a<<0 a>>1 bit_count(a)
+00:00:02.9 3 3 3 6 3 1 2
+CREATE TABLE t2 (a DATETIME(1) NOT NULL);
+INSERT INTO t2 VALUES ('2001-01-01 00:00:02.9');
+INSERT INTO t2 VALUES ('2001-01-01 23:59:59.9');
+INSERT INTO t2 VALUES ('9999-12-31 23:59:59.9');
+SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t2;
+a a & a a | a a^0 a<<1 a<<0 a>>1 bit_count(a)
+2001-01-01 00:00:02.9 20010101000003 20010101000003 20010101000003 40020202000006 20010101000003 10005050500001 24
+2001-01-01 23:59:59.9 20010102000000 20010102000000 20010102000000 40020204000000 20010102000000 10005051000000 18
+9999-12-31 23:59:59.9 99991231000000 99991231000000 99991231000000 199982462000000 99991231000000 49995615500000 24
+DROP TABLE t1;
+DROP TABLE t2;
+DROP DATABASE issue1173;
diff --git a/mysql-test/suite/tianmu/r/issue1174.result b/mysql-test/suite/tianmu/r/issue1174.result
index c1c2a5ea2..c0ea38c66 100644
--- a/mysql-test/suite/tianmu/r/issue1174.result
+++ b/mysql-test/suite/tianmu/r/issue1174.result
@@ -31,6 +31,13 @@ id name
0 lllll
[on slave]
include/sync_slave_sql_with_master.inc
+show create table ttt;
+Table Create Table
+ttt CREATE TABLE `ttt` (
+ `id` int(11) NOT NULL,
+ `name` varchar(64) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
select * from ttt where id in(1,3,2,0) order by id desc;
id name
3 lllll
diff --git a/mysql-test/suite/tianmu/r/issue1175.result b/mysql-test/suite/tianmu/r/issue1175.result
new file mode 100644
index 000000000..58716a335
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1175.result
@@ -0,0 +1,67 @@
+DROP DATABASE IF EXISTS issue1175_test;
+# Creating test database issue1175_test
+CREATE DATABASE issue1175_test;
+USE issue1175_test;
+# Create test table with tianmu engine
+CREATE TABLE t1 (
+id INT AUTO_INCREMENT PRIMARY KEY,
+t TIME,
+d DATE,
+dt DATETIME,
+ts TIMESTAMP
+) ENGINE=TIANMU;
+# Insert data into test table
+INSERT INTO t1 (t, d, dt, ts) VALUES
+('00:00:00', '2000-01-01', '2000-01-01 00:00:00', '2000-01-01 00:00:00'),
+('-838:59:59', '2001-02-28', '2001-02-28 00:00:00', '2001-02-28 00:00:00'),
+('838:59:59', '2002-03-31', '2002-03-31 23:59:59', '2002-03-31 23:59:59'),
+('-100:00:00', '2010-12-31', '2010-12-31 12:34:56', '2010-12-31 12:34:56'),
+('200:00:00', '2011-11-30', '2011-11-30 18:00:00', '2011-11-30 18:00:00'),
+('-400:00:00', '2012-02-29', '2012-02-29 01:23:45', '2012-02-29 01:23:45'),
+('720:00:00', '2020-10-31', '2020-10-31 14:00:00', '2020-10-31 14:00:00'),
+('05:30:15', '1985-04-12', '1985-04-12 05:30:15.123', '1985-04-12 05:30:15.123'),
+('-23:45:01', '1995-08-24', '1995-08-24 15:45:30.987', '1995-08-24 15:45:30.987'),
+('67:15:45', '2005-06-15', '2005-06-15 10:59:59.001', '2005-06-15 10:59:59.001'),
+('-115:00:00', '2007-12-25', '2007-12-25 23:30:45.500', '2007-12-25 23:30:45.500'),
+('350:30:15', '2015-09-05', '2015-09-05 12:00:00.999', '2015-09-05 12:00:00.999'),
+('-500:45:30', '2017-03-01', '2017-03-01 01:23:45.250', '2017-03-01 01:23:45.250'),
+('600:15:00', '2021-05-01', '2021-05-01 17:30:00.123', '2021-05-01 17:30:00.123'),
+('12:34:56', '1970-01-01', '1970-01-01 12:34:56', '1970-01-01 12:34:56'),
+('-300:00:00.123', '1980-06-30', '1980-06-30 18:30:45.123', '1980-06-30 18:30:45.123'),
+('450:00:00', '1990-03-15', '1990-03-15 11:59:59.999', '1990-03-15 11:59:59.999'),
+('-600:00:00.9', '1999-09-09', '1999-09-09 06:45:00.250', '1999-09-09 06:45:00.250'),
+('-09:00:00', '2005-02-28', '2005-02-28 15:00:00.123', '2005-02-28 15:00:00.123'),
+('-123:45:00', '2008-08-08', '2008-08-08 20:15:30.987', '2008-08-08 20:15:30.987'),
+('99:00:00', '2013-07-07', '2013-07-07 17:30:45.500', '2013-07-07 17:30:45.500'),
+('-220:00:00', '2016-04-30', '2016-04-30 02:00:00.999', '2016-04-30 02:00:00.999'),
+('580:00:00', '2019-12-31', '2019-12-31 01:23:45.250', '2019-12-31 01:23:45.250'),
+('-750:00:00', '2021-08-31', '2021-08-31 09:45:00.123', '2021-08-31 09:45:00.123');
+# Select all data from test table
+SELECT * FROM t1 ORDER BY id;
+id t d dt ts
+1 00:00:00 2000-01-01 2000-01-01 00:00:00 2000-01-01 00:00:00
+2 -838:59:59 2001-02-28 2001-02-28 00:00:00 2001-02-28 00:00:00
+3 838:59:59 2002-03-31 2002-03-31 23:59:59 2002-03-31 23:59:59
+4 -100:00:00 2010-12-31 2010-12-31 12:34:56 2010-12-31 12:34:56
+5 200:00:00 2011-11-30 2011-11-30 18:00:00 2011-11-30 18:00:00
+6 -400:00:00 2012-02-29 2012-02-29 01:23:45 2012-02-29 01:23:45
+7 720:00:00 2020-10-31 2020-10-31 14:00:00 2020-10-31 14:00:00
+8 05:30:15 1985-04-12 1985-04-12 05:30:15 1985-04-12 05:30:15
+9 -23:45:01 1995-08-24 1995-08-24 15:45:31 1995-08-24 15:45:31
+10 67:15:45 2005-06-15 2005-06-15 10:59:59 2005-06-15 10:59:59
+11 -115:00:00 2007-12-25 2007-12-25 23:30:46 2007-12-25 23:30:46
+12 350:30:15 2015-09-05 2015-09-05 12:00:01 2015-09-05 12:00:01
+13 -500:45:30 2017-03-01 2017-03-01 01:23:45 2017-03-01 01:23:45
+14 600:15:00 2021-05-01 2021-05-01 17:30:00 2021-05-01 17:30:00
+15 12:34:56 1970-01-01 1970-01-01 12:34:56 1970-01-01 12:34:56
+16 -300:00:00 1980-06-30 1980-06-30 18:30:45 1980-06-30 18:30:45
+17 450:00:00 1990-03-15 1990-03-15 12:00:00 1990-03-15 12:00:00
+18 -600:00:01 1999-09-09 1999-09-09 06:45:00 1999-09-09 06:45:00
+19 -09:00:00 2005-02-28 2005-02-28 15:00:00 2005-02-28 15:00:00
+20 -123:45:00 2008-08-08 2008-08-08 20:15:31 2008-08-08 20:15:31
+21 99:00:00 2013-07-07 2013-07-07 17:30:46 2013-07-07 17:30:46
+22 -220:00:00 2016-04-30 2016-04-30 02:00:01 2016-04-30 02:00:01
+23 580:00:00 2019-12-31 2019-12-31 01:23:45 2019-12-31 01:23:45
+24 -750:00:00 2021-08-31 2021-08-31 09:45:00 2021-08-31 09:45:00
+# Dropping test database issue1175_test
+DROP DATABASE issue1175_test;
diff --git a/mysql-test/suite/tianmu/r/issue1325.result b/mysql-test/suite/tianmu/r/issue1325.result
index 2a50d785c..548697b67 100644
--- a/mysql-test/suite/tianmu/r/issue1325.result
+++ b/mysql-test/suite/tianmu/r/issue1325.result
@@ -5,21 +5,6 @@ include/sync_slave_sql_with_master.inc
# on master:
CREATE DATABASE issue1325_test;
USE issue1325_test;
-include/sync_slave_sql_with_master.inc
-# on slave:
-USE issue1325_test;
-show databases;
-Database
-information_schema
-cache
-issue1325_test
-mtr
-mysql
-performance_schema
-sys
-sys_tianmu
-test
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
#
# Secondary INDEX
#
@@ -39,14 +24,14 @@ ttt CREATE TABLE `ttt` (
) ENGINE=InnoDB DEFAULT CHARSET=latin1
include/sync_slave_sql_with_master.inc
# on slave:
-# on master:
+USE issue1325_test;
show create table ttt;
Table Create Table
ttt CREATE TABLE `ttt` (
`id` int(11) NOT NULL,
`name` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=latin1
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
#
# UNIQUE INDEX
#
@@ -149,15 +134,4 @@ student_score CREATE TABLE `student_score` (
DROP DATABASE issue1325_test;
include/sync_slave_sql_with_master.inc
# on slave:
-show databases;
-Database
-information_schema
-cache
-mtr
-mysql
-performance_schema
-sys
-sys_tianmu
-test
-tianmu_data
stop slave;
diff --git a/mysql-test/suite/tianmu/r/issue1402.result b/mysql-test/suite/tianmu/r/issue1402.result
new file mode 100644
index 000000000..8f0489e83
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1402.result
@@ -0,0 +1,53 @@
+DROP DATABASE IF EXISTS issue1402_test;
+CREATE DATABASE issue1402_test;
+USE issue1402_test;
+CREATE TABLE t1 (id INT, d DECIMAL(10,4)) ENGINE=tianmu;
+INSERT INTO t1 VALUES (1, 1.2345), (2, 2.3456), (3, 3.4567);
+SELECT COUNT(*), SUM(d), AVG(d), MIN(d), MAX(d) FROM t1;
+COUNT(*) SUM(d) AVG(d) MIN(d) MAX(d)
+3 7.0368 2.34560000 1.2345 3.4567
+SELECT id, SUM(d) FROM t1 GROUP BY id;
+id SUM(d)
+1 1.2345
+2 2.3456
+3 3.4567
+SELECT * FROM t1 ORDER BY d DESC;
+id d
+3 3.4567
+2 2.3456
+1 1.2345
+SELECT * FROM t1 WHERE d > (SELECT AVG(d) FROM t1);
+id d
+3 3.4567
+SELECT id, SUM(d) FROM t1 WHERE d > (SELECT AVG(d) FROM t1) GROUP BY id;
+id SUM(d)
+3 3.4567
+SELECT * FROM t1 WHERE d > (SELECT AVG(d) FROM t1) ORDER BY d DESC;
+id d
+3 3.4567
+SELECT id, SUM(d) FROM t1 WHERE d > (SELECT AVG(d) FROM t1) GROUP BY id ORDER BY SUM(d) DESC;
+id SUM(d)
+3 3.4567
+SELECT t1.id, t1.d, t2.d FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id;
+id d d
+2 2.3456 2.3456
+3 3.4567 3.4567
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id;
+id SUM(t1.d) SUM(t2.d)
+2 2.3456 2.3456
+3 3.4567 3.4567
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC;
+id SUM(t1.d) SUM(t2.d)
+3 3.4567 3.4567
+2 2.3456 2.3456
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC LIMIT 1;
+id SUM(t1.d) SUM(t2.d)
+3 3.4567 3.4567
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+id SUM(t1.d) SUM(t2.d)
+2 2.3456 2.3456
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id HAVING SUM(t1.d) > 3 ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+id SUM(t1.d) SUM(t2.d)
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id WHERE t1.id > 1 GROUP BY t1.id HAVING SUM(t1.d) > 3 ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+id SUM(t1.d) SUM(t2.d)
+drop database issue1402_test;
diff --git a/mysql-test/suite/tianmu/r/issue1464.result b/mysql-test/suite/tianmu/r/issue1464.result
new file mode 100644
index 000000000..0ab99006a
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1464.result
@@ -0,0 +1,51 @@
+include/master-slave.inc
+[connection master]
+# on master:
+DROP DATABASE IF EXISTS issue1464_test;
+CREATE DATABASE issue1464_test;
+USE issue1464_test;
+include/sync_slave_sql_with_master.inc
+# on slave:
+USE issue1464_test;
+# on master:
+create table ttt(id varchar(64) primary key,name varchar(10))engine=innodb;
+insert into ttt values('0000352b6b4f4011bd18da7176e22c03','AAA');
+insert into ttt values('000246c51ca745f893a705f1699e9b2a','BBB');
+insert into ttt values('00049c87d9c64c498e004f6b08f1dd38','CCC');
+delete from ttt where id='0000352b6b4f4011bd18da7176e22c03';
+select * from ttt order by id;
+id name
+000246c51ca745f893a705f1699e9b2a BBB
+00049c87d9c64c498e004f6b08f1dd38 CCC
+include/sync_slave_sql_with_master.inc
+# on slave:
+show create table ttt;
+Table Create Table
+ttt CREATE TABLE `ttt` (
+ `id` varchar(64) NOT NULL,
+ `name` varchar(10) DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=TIANMU DEFAULT CHARSET=latin1
+select * from ttt order by id;
+id name
+000246c51ca745f893a705f1699e9b2a BBB
+00049c87d9c64c498e004f6b08f1dd38 CCC
+# on master:
+insert into ttt values('0000352b6b4f4011bd18da7176e22c03','AAA');
+update ttt set name='name_' where id='000246c51ca745f893a705f1699e9b2a';
+select * from ttt order by id;
+id name
+0000352b6b4f4011bd18da7176e22c03 AAA
+000246c51ca745f893a705f1699e9b2a name_
+00049c87d9c64c498e004f6b08f1dd38 CCC
+include/sync_slave_sql_with_master.inc
+# on slave:
+select * from ttt order by id;
+id name
+0000352b6b4f4011bd18da7176e22c03 AAA
+000246c51ca745f893a705f1699e9b2a name_
+00049c87d9c64c498e004f6b08f1dd38 CCC
+# on master:
+DROP DATABASE issue1464_test;
+include/sync_slave_sql_with_master.inc
+stop slave;
diff --git a/mysql-test/suite/tianmu/r/issue1510.result b/mysql-test/suite/tianmu/r/issue1510.result
new file mode 100644
index 000000000..3d1701add
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1510.result
@@ -0,0 +1,18 @@
+DROP DATABASE IF EXISTS issue1510_test;
+CREATE DATABASE issue1510_test;
+USE issue1510_test;
+create table ttt(id int primary key,name varchar(10));
+begin;
+insert into ttt values(1,'AAA');
+commit;
+select * from ttt;
+id name
+1 AAA
+drop table ttt;
+create table ttt(id int primary key,name varchar(10));
+insert into ttt values(1,'AAA');
+select * from ttt;
+id name
+1 AAA
+drop table ttt;
+DROP DATABASE issue1510_test;
diff --git a/mysql-test/suite/tianmu/r/issue1523.result b/mysql-test/suite/tianmu/r/issue1523.result
new file mode 100644
index 000000000..589365345
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1523.result
@@ -0,0 +1,156 @@
+include/master-slave.inc
+[connection master]
+# on master:
+DROP DATABASE IF EXISTS issue1523_test;
+CREATE DATABASE issue1523_test;
+USE issue1523_test;
+include/sync_slave_sql_with_master.inc
+# on slave:
+USE issue1523_test;
+# on master:
+CREATE TABLE t1 (
+`id` int(10) NOT NULL AUTO_INCREMENT,
+`dev_code` varchar(20) NOT NULL,
+`port` smallint(2) DEFAULT '0',
+`server_ip` varchar(20) DEFAULT NULL,
+`work_status` int(1) DEFAULT '2',
+`port_link_car` int(1) NOT NULL DEFAULT '0',
+`last_order_sn` varchar(42) DEFAULT NULL,
+`last_charge_type` smallint(1) DEFAULT NULL,
+`last_charge_mode` int(2) DEFAULT '0',
+`last_status` smallint(1) DEFAULT NULL,
+`last_soc` int(3) DEFAULT NULL,
+`last_car_no` varchar(42) DEFAULT NULL,
+`last_vin` varchar(45) DEFAULT NULL,
+`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+`update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+PRIMARY KEY (`id`),
+UNIQUE KEY `portindex` (`dev_code`,`port`),
+KEY `dev_code` (`dev_code`)
+) ENGINE=INNODB;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(1,'3301081000000019',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(2,'3301081000000020',0,'172.16.171.219',3,1,1,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(3,'3301081000000021',0,'172.16.171.219',4,2,2,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+insert into t1 values
+(4,'3301081000000022',1,'172.16.171.219',2,1,'2023040314582504221842260',5,0,5,100,'JJY3786','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+insert into t1 values
+(5,'3301081000000023',1,'172.16.171.219',2,1,'2023040314582504221842261',6,0,6,101,'JJY3787','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+insert into t1 values
+(6,'3301081000000024',1,'172.16.171.219',2,1,'2023040314582504221842262',7,0,7,102,'JJY3788','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(7,'3301081000000025',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+select last_car_no from t1 where id=1;
+last_car_no
+NULL
+select count(*) from t1;
+count(*)
+7
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=1;
+last_car_no
+NULL
+select count(*) from t1;
+count(*)
+7
+# on master:
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+update t1 set last_car_no='JJY3786' where id=1;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(8,'3301081000000026',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+select last_car_no from t1 where id=1;
+last_car_no
+JJY3786
+select count(*) from t1;
+count(*)
+8
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=1;
+last_car_no
+JJY3786
+select count(*) from t1;
+count(*)
+8
+# on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(9,'3301081000000027',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+delete from t1 where id=9;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(9,'3301081000000027',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+select last_car_no from t1 where id=9;
+last_car_no
+NULL
+select count(*) from t1;
+count(*)
+9
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=9;
+last_car_no
+NULL
+select count(*) from t1;
+count(*)
+9
+# on master:
+update t1 set last_car_no=NULL where id=1;
+delete from t1 where id =1;
+select last_car_no from t1 where id=1;
+last_car_no
+select count(*) from t1;
+count(*)
+8
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=1;
+last_car_no
+select count(*) from t1;
+count(*)
+8
+# on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(10,'3301081000000028',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+update t1 set last_car_no='JJY3786' where id=10;
+select last_car_no from t1 where id=10;
+last_car_no
+JJY3786
+select count(*) from t1;
+count(*)
+9
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=10;
+last_car_no
+JJY3786
+select count(*) from t1;
+count(*)
+9
+# on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(11,'3301081000000029',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+update t1 set last_car_no='JJY3786' where id=11;
+delete from t1 where id =11;
+select last_car_no from t1 where id=11;
+last_car_no
+select count(*) from t1;
+count(*)
+9
+include/sync_slave_sql_with_master.inc
+# on slave:
+select last_car_no from t1 where id=11;
+last_car_no
+select count(*) from t1;
+count(*)
+9
+# on master:
+DROP DATABASE issue1523_test;
+include/sync_slave_sql_with_master.inc
+stop slave;
diff --git a/mysql-test/suite/tianmu/r/issue1564.result b/mysql-test/suite/tianmu/r/issue1564.result
new file mode 100644
index 000000000..c84516222
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1564.result
@@ -0,0 +1,99 @@
+DROP DATABASE IF EXISTS issue1564;
+create database issue1564;
+use issue1564;
+create table t(a bigint not null);
+insert into t values(-222222), (-22), (-15),(-16),(0), (11), (12), (9223372036854775807);
+select * from t;
+a
+-222222
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a = 18446744073709551601;
+a
+select * from t where a != 18446744073709551601;
+a
+-222222
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a = -22;
+a
+-22
+select * from t where a != -22;
+a
+-222222
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a in(-16, -15, -11);
+a
+-15
+-16
+select * from t where a > 18446744073709551599;
+a
+select * from t where a >= 18446744073709551599;
+a
+select * from t where a < 18446744073709551599;
+a
+-222222
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a <= 18446744073709551599;
+a
+-222222
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a between -22 and 18446744073709551599;
+a
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a between -22 and 9223372036854775807;
+a
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a between -222222 and 9223372036854775807;
+a
+-222222
+-22
+-15
+-16
+0
+11
+12
+9223372036854775807
+select * from t where a between 9223372036854775807 and -22;
+a
+drop table t;
+drop database issue1564;
diff --git a/mysql-test/suite/tianmu/r/issue1599.result b/mysql-test/suite/tianmu/r/issue1599.result
new file mode 100644
index 000000000..737e25465
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1599.result
@@ -0,0 +1,81 @@
+CREATE DATABASE IF NOT EXISTS test_db_1599;
+USE test_db_1599;
+create table ttt(c1 int,c2 int);
+insert into ttt values(327266,1),(327267,1),(327268,1),(327269,1),(327270,1);
+select c1 from ttt union select 'aaa' c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+327266
+327267
+327268
+327269
+327270
+select c1 from ttt union all select 'aaa' c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+327266
+327267
+327268
+327269
+327270
+select c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+327266
+327267
+327268
+327269
+327270
+select c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+327266
+327267
+327268
+327269
+327270
+select 111 c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+111
+select 111 c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+c1
+111
+111
+111
+111
+111
+drop table ttt;
+create table ttt(c1 decimal(18,0),c2 decimal(18,0));
+insert into ttt values(3000000000027266,1),(3000000000027267,1),(3000000000027268,1),(3000000000027269,1),(3000000000027270,1);
+select c1 from ttt union select 'aaa' c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+c1
+3000000000027266
+3000000000027267
+3000000000027268
+3000000000027269
+3000000000027270
+select c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+c1
+3000000000027266
+3000000000027267
+3000000000027268
+3000000000027269
+3000000000027270
+select 'aaa' c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+c1
+aaa
+aaa
+aaa
+aaa
+aaa
+select 111 c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+c1
+111
+111
+111
+111
+111
+select c1 from ttt union all select 'aaa' c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+c1
+3000000000027266
+3000000000027267
+3000000000027268
+3000000000027269
+3000000000027270
+drop database test_db_1599;
diff --git a/mysql-test/suite/tianmu/r/issue1616.result b/mysql-test/suite/tianmu/r/issue1616.result
new file mode 100644
index 000000000..a6d09cb49
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1616.result
@@ -0,0 +1,61 @@
+DROP DATABASE IF EXISTS issue1616_test;
+CREATE DATABASE issue1616_test;
+USE issue1616_test;
+CREATE TABLE T1 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+DEFAULT '0' NOT NULL, PRIMARY KEY (id)) engine=tianmu;
+INSERT INTO T1 VALUES (3,1,1),(4,1,1);
+INSERT INTO T1 VALUES (3,1,1),(4,1,1);
+ERROR 23000: Duplicate entry '3' for key 'PRIMARY'
+SELECT * FROM T1;
+id parent_id level
+3 1 1
+4 1 1
+UPDATE IGNORE T1 SET id=id+1;
+SELECT * FROM T1;
+id parent_id level
+3 1 1
+5 1 1
+UPDATE T1 SET id =10;
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
+SELECT * FROM T1;
+id parent_id level
+3 1 1
+5 1 1
+UPDATE T1 SET ID=5 WHERE ID=3;
+ERROR 23000: Duplicate entry '5' for key 'PRIMARY'
+SELECT * FROM T1;
+id parent_id level
+3 1 1
+5 1 1
+DROP TABLE T1;
+CREATE TABLE T2 (dt datetime, val int, primary key(dt)) ENGINE =tianmu;
+INSERT INTO T2 VALUES ('2017-11-05 20:29:36',1), ('2027-11-05 20:29:36', 2);
+UPDATE T2 SET dt ='2027-11-05 20:29:36' WHERE val =1;
+ERROR 23000: Duplicate entry '2027-11-05 20:29:36' for key 'PRIMARY'
+SELECT * FROM T2;
+dt val
+2017-11-05 20:29:36 1
+2027-11-05 20:29:36 2
+DROP TABLE T2;
+CREATE TABLE T3 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+DEFAULT '0' NOT NULL, PRIMARY KEY (id, parent_id)) engine=tianmu;
+INSERT INTO T3 VALUES (3,1,1),(4,1,1);
+INSERT INTO T3 VALUES (3,1,1),(4,1,1);
+ERROR 23000: Duplicate entry '3-1' for key 'PRIMARY'
+UPDATE IGNORE T3 SET id=id+1;
+SELECT * FROM T3;
+id parent_id level
+4 1 1
+5 1 1
+DROP TABLE T3;
+CREATE TABLE T4 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+DEFAULT '0' NOT NULL, PRIMARY KEY (id)) engine=innodb;
+INSERT INTO T4 VALUES (3,1,1),(4,1,1);
+UPDATE T4 SET id =10;
+ERROR 23000: Duplicate entry '10' for key 'PRIMARY'
+SELECT * FROM T4;
+id parent_id level
+3 1 1
+4 1 1
+DROP TABLE T4;
+DROP DATABASE issue1616_test;
diff --git a/mysql-test/suite/tianmu/r/issue1637.result b/mysql-test/suite/tianmu/r/issue1637.result
new file mode 100644
index 000000000..049f409e1
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1637.result
@@ -0,0 +1,12 @@
+DROP DATABASE IF EXISTS issue1637_test;
+CREATE DATABASE issue1637_test;
+USE issue1637_test;
+create table ttt(id int primary key,name varchar(10));
+insert into ttt values(1,'aaa');
+insert into ttt values(2,'bbb');
+insert ignore into ttt values(2,'ccc');
+select * from ttt;
+id name
+1 aaa
+2 bbb
+DROP DATABASE issue1637_test;
diff --git a/mysql-test/suite/tianmu/r/issue1662.result b/mysql-test/suite/tianmu/r/issue1662.result
new file mode 100644
index 000000000..cbf0980c8
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1662.result
@@ -0,0 +1,52 @@
+# Create test database
+CREATE DATABASE IF NOT EXISTS test_db_1662;
+USE test_db_1662;
+# Create test table with tianmu engine
+CREATE TABLE IF NOT EXISTS test_table (
+id INT,
+value INT,
+PRIMARY KEY (id)
+) ENGINE=tianmu;
+# Insert data into test table
+INSERT INTO test_table (id, value) VALUES
+(1, 10),
+(2, 20),
+(3, 10),
+(4, 30),
+(5, 20);
+# Select data from test table with user-defined variable
+SELECT
+id,
+value,
+@my_var := IF(value = @prev_value, @my_var, @my_var + 1) AS group_id,
+@prev_value := value
+FROM
+test_table,
+(SELECT @my_var := 0, @prev_value := NULL) AS init
+ORDER BY
+value,
+id;
+id value group_id @prev_value := value
+1 10 2 10
+3 10 2 10
+2 20 4 20
+5 20 4 20
+4 30 6 30
+SELECT
+id,
+value,
+@my_var := IF(id = @prev_value, @my_var, @my_var + 1) AS group_id,
+@prev_value := value
+FROM
+test_table,
+(SELECT @my_var := 0, @prev_value := NULL) AS init
+ORDER BY
+value,
+id;
+id value group_id @prev_value := value
+1 10 2 10
+3 10 4 10
+2 20 6 20
+5 20 8 20
+4 30 10 30
+DROP DATABASE test_db_1662;
diff --git a/mysql-test/suite/tianmu/r/issue1696.result b/mysql-test/suite/tianmu/r/issue1696.result
new file mode 100644
index 000000000..de929cbb8
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1696.result
@@ -0,0 +1,87 @@
+# Creating test database test_db_1696
+CREATE DATABASE IF NOT EXISTS test_db_1696;
+USE test_db_1696;
+CREATE DATABASE IF NOT EXISTS test_database;
+USE test_database;
+CREATE TABLE IF NOT EXISTS t1 (
+id INT NOT NULL,
+value INT NOT NULL
+) ENGINE=tianmu;
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+CREATE TABLE IF NOT EXISTS t2 (
+id INT NOT NULL,
+value INT NOT NULL
+) ENGINE=tianmu;
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+CREATE TABLE IF NOT EXISTS t3 (
+id INT NOT NULL,
+value INT NOT NULL
+) ENGINE=tianmu;
+INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+SET @counter = 0;
+SELECT
+*,
+IF(@counter != 1, @counter, @counter := @counter + 1) AS counter
+FROM
+(
+SELECT
+t1.id AS id1,
+t1.value AS value1,
+t2.id AS id2,
+t2.value AS value2,
+t3.id AS id3,
+t3.value AS value3
+FROM
+t1
+JOIN t2 ON t1.value = t2.value
+JOIN t3 ON t2.value = t3.value
+) AS derived_table;
+id1 value1 id2 value2 id3 value3 counter
+1 1 1 1 1 1 0
+4 1 1 1 1 1 0
+1 1 1 1 4 1 0
+4 1 1 1 4 1 0
+2 2 2 2 2 2 0
+5 2 2 2 2 2 0
+2 2 2 2 5 2 0
+5 2 2 2 5 2 0
+3 3 3 3 3 3 0
+6 3 3 3 3 3 0
+3 3 3 3 6 3 0
+6 3 3 3 6 3 0
+1 1 4 1 1 1 0
+4 1 4 1 1 1 0
+1 1 4 1 4 1 0
+4 1 4 1 4 1 0
+2 2 5 2 2 2 0
+5 2 5 2 2 2 0
+2 2 5 2 5 2 0
+5 2 5 2 5 2 0
+3 3 6 3 3 3 0
+6 3 6 3 3 3 0
+3 3 6 3 6 3 0
+6 3 6 3 6 3 0
+DROP TABLE t1, t2, t3;
+set @rankno = 1;
+create table d(taxis_no int);
+insert into d values(1);
+insert into d values(1);
+insert into d values(1);
+SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d;
+IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1)
+2
+1
+2
+set @rankno = 1;
+drop table d;
+create table d(taxis_no int);
+insert into d values(1);
+insert into d values(2);
+insert into d values(3);
+SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d;
+IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1)
+2
+3
+4
+# Dropping test database test_db_1696
+DROP DATABASE IF EXISTS test_db_1696;
diff --git a/mysql-test/suite/tianmu/r/issue1707.result b/mysql-test/suite/tianmu/r/issue1707.result
new file mode 100644
index 000000000..b3dc200cd
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1707.result
@@ -0,0 +1,34 @@
+CREATE DATABASE IF NOT EXISTS test_db_1707;
+USE test_db_1707;
+CREATE TABLE tianmu_table (
+id INT NOT NULL,
+name VARCHAR(50) NOT NULL,
+age INT NOT NULL,
+gender VARCHAR(10) NOT NULL,
+salary INT NOT NULL,
+address VARCHAR(100) NOT NULL
+) ENGINE=tianmu;
+INSERT INTO tianmu_table
+(id, name, age, gender, salary, address)
+VALUES
+(1, 'John', 25, 'Male', 50000, '123 Main St'),
+(2, 'Jane', 30, 'Female', 60000, '456 Elm St'),
+(3, 'Bob', 35, 'Male', 70000, '789 Maple St');
+select @age_cutoff := age
+from (
+SELECT name, age, gender, salary
+FROM (
+SELECT name, age, gender, salary
+FROM tianmu_table
+WHERE age < 30
+UNION ALL
+SELECT name, age, gender, salary
+FROM tianmu_table
+WHERE age >= 30
+) AS derived_table
+WHERE salary > 30 ) H;
+@age_cutoff := age
+25
+30
+35
+drop database test_db_1707;
diff --git a/mysql-test/suite/tianmu/r/issue1784.result b/mysql-test/suite/tianmu/r/issue1784.result
new file mode 100644
index 000000000..008f115a4
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1784.result
@@ -0,0 +1,144 @@
+DROP DATABASE IF EXISTS issue1784_test;
+CREATE DATABASE issue1784_test;
+USE issue1784_test;
+create table t1 (age int) engine=tianmu;
+select * from t1;
+age
+select age from t1;
+age
+select age, sum(age) from t1 group by age;
+age sum(age)
+select age, sum(age) from (select * from t1) ta group by age;
+age sum(age)
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+case when age is not null then age else 33 end sum(age)
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+case when age is not null then age else 33 end sum(age)
+insert into t1 values(1);
+select * from t1;
+age
+1
+select age from t1;
+age
+1
+select age, sum(age) from t1 group by age;
+age sum(age)
+1 1
+select age, sum(age) from (select * from t1) ta group by age;
+age sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+case when age is not null then age else 33 end sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+case when age is not null then age else 33 end sum(age)
+1 1
+drop table t1;
+create table t1 (age int) engine=innodb;
+select * from t1;
+age
+select age from t1;
+age
+select age, sum(age) from t1 group by age;
+age sum(age)
+select age, sum(age) from (select * from t1) ta group by age;
+age sum(age)
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+case when age is not null then age else 33 end sum(age)
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+case when age is not null then age else 33 end sum(age)
+insert into t1 values(1);
+select * from t1;
+age
+1
+select age from t1;
+age
+1
+select age, sum(age) from t1 group by age;
+age sum(age)
+1 1
+select age, sum(age) from (select * from t1) ta group by age;
+age sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+case when age is not null then age else 33 end sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+case when age is not null then age else 33 end sum(age)
+1 1
+drop table t1;
+SET sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+create table t1 (age int) engine=tianmu;
+select * from t1;
+age
+select age from t1;
+age
+select age, sum(age) from t1;
+age sum(age)
+NULL NULL
+select age, sum(age) from (select * from t1) ta;
+age sum(age)
+NULL NULL
+select case when age is not null then age else 33 end, sum(age) from t1;
+case when age is not null then age else 33 end sum(age)
+33 NULL
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+case when age is not null then age else 33 end sum(age)
+33 NULL
+insert into t1 values(1);
+select * from t1;
+age
+1
+select age from t1;
+age
+1
+select age, sum(age) from t1;
+age sum(age)
+1 1
+select age, sum(age) from (select * from t1) ta;
+age sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from t1;
+case when age is not null then age else 33 end sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+case when age is not null then age else 33 end sum(age)
+1 1
+drop table t1;
+create table t1 (age int) engine=innodb;
+select * from t1;
+age
+select age from t1;
+age
+select age, sum(age) from t1;
+age sum(age)
+NULL NULL
+select age, sum(age) from (select * from t1) ta;
+age sum(age)
+NULL NULL
+select case when age is not null then age else 33 end, sum(age) from t1;
+case when age is not null then age else 33 end sum(age)
+33 NULL
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+case when age is not null then age else 33 end sum(age)
+33 NULL
+insert into t1 values(1);
+select * from t1;
+age
+1
+select age from t1;
+age
+1
+select age, sum(age) from t1;
+age sum(age)
+1 1
+select age, sum(age) from (select * from t1) ta;
+age sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from t1;
+case when age is not null then age else 33 end sum(age)
+1 1
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+case when age is not null then age else 33 end sum(age)
+1 1
+DROP DATABASE issue1784_test;
diff --git a/mysql-test/suite/tianmu/r/issue1808.result b/mysql-test/suite/tianmu/r/issue1808.result
new file mode 100644
index 000000000..2cafc1f57
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1808.result
@@ -0,0 +1,11 @@
+DROP DATABASE IF EXISTS issue1808_test;
+CREATE DATABASE issue1808_test;
+USE issue1808_test;
+SELECT c1 FROM ttt UNION ALL SELECT 'aaa' c1 FROM (SELECT c2 FROM ttt WHERE c1 IN (3000000000027265)) x ORDER BY c1;
+c1
+3000000000027266
+3000000000027267
+3000000000027268
+3000000000027269
+3000000000027270
+DROP DATABASE issue1808_test;
diff --git a/mysql-test/suite/tianmu/r/issue1848.result b/mysql-test/suite/tianmu/r/issue1848.result
new file mode 100644
index 000000000..d5e61d67d
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1848.result
@@ -0,0 +1,3 @@
+SELECT GROUP_CONCAT(t.id) FROM sequence t;
+GROUP_CONCAT(t.id)
+3000000000010000,3000000000010001,3000000000010002,3000000000010003,3000000000010004,3000000000010005,3000000000010006,3000000000010007,3000000000010008,3000000000010009,3000000000010010
diff --git a/mysql-test/suite/tianmu/r/issue1855.result b/mysql-test/suite/tianmu/r/issue1855.result
new file mode 100644
index 000000000..1270e52cc
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1855.result
@@ -0,0 +1,26 @@
+SELECT SUM(LENGTH(p_id)) FROM ttt;
+SUM(LENGTH(p_id))
+34
+SELECT SUM(LENGTH(p_id)/2) FROM ttt;
+SUM(LENGTH(p_id)/2)
+17.0000
+SELECT SUM(LENGTH(p_val)) FROM ttt;
+SUM(LENGTH(p_val))
+6
+SELECT SUM(LENGTH(p_val)/2) FROM ttt;
+SUM(LENGTH(p_val)/2)
+3.0000
+Variable_name Value
+tianmu_groupby_parallel_degree 0
+tianmu_groupby_parallel_rows_minimum 655360
+Variable_name Value
+tianmu_groupby_parallel_degree 4
+tianmu_groupby_parallel_rows_minimum 100
+SUM(LENGTH(p_id))
+158949
+SUM(LENGTH(p_id)/2)
+79474.5000
+SUM(LENGTH(p_val))
+38901
+SUM(LENGTH(p_val)/2)
+19450.5000
diff --git a/mysql-test/suite/tianmu/r/issue1860.result b/mysql-test/suite/tianmu/r/issue1860.result
new file mode 100644
index 000000000..8486c0bed
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1860.result
@@ -0,0 +1,55 @@
+DROP DATABASE IF EXISTS issue1860_test;
+CREATE DATABASE issue1860_test;
+USE issue1860_test;
+CREATE TABLE tt(id decimal(18,0), dt datetime) ENGINE =TIANMU;
+INSERT INTO tt VALUES(1111.0, '2023-01-01');
+SELECT id FROM tt UNION SELECT 2222 c1 FROM dual;
+id
+1111
+2222
+INSERT INTO tt VALUES(2222.0, '2023-02-02');
+SELECT id FROM tt UNION SELECT 2222 c1 FROM dual;
+id
+1111
+2222
+SELECT id FROM tt UNION ALL SELECT 2222 c1 FROM dual;
+id
+1111
+2222
+2222
+SELECT id FROM tt UNION SELECT 2222 ;
+id
+1111
+2222
+sELECT id FROM tt UNION ALL SELECT 2222;
+id
+1111
+2222
+2222
+SELECT id, dt FROM tt UNION SELECT 2222, '2022-01-01';
+id dt
+1111 2023-01-01 00:00:00
+2222 2023-02-02 00:00:00
+2222 2022-01-01
+SELECT id, dt FROM tt UNION SELECT 2222, str_to_date('2022-02-03', '%Y-%m-%d');
+id dt
+1111 2023-01-01 00:00:00
+2222 2023-02-02 00:00:00
+2222 2022-02-03 00:00:00
+SELECT id, dt FROM tt UNION SELECT 2222, str_to_date('2023-02-02', '%Y-%m-%d');
+id dt
+1111 2023-01-01 00:00:00
+2222 2023-02-02 00:00:00
+SELECT dt FROM tt UNION SELECT 2222;
+ERROR HY000: wrong types of columns
+SELECT dt FROM tt UNION SELECT '2222';
+dt
+2023-01-01 00:00:00
+2023-02-02 00:00:00
+2222
+SELECT * FROM tt UNION SELECT 222;
+ERROR 21000: The used SELECT statements have a different number of columns
+SELECT * FROM tt UNION ALL SELECT 222;
+ERROR 21000: The used SELECT statements have a different number of columns
+DROP TABLE tt;
+DROP DATABASE issue1860_test;
diff --git a/mysql-test/suite/tianmu/r/issue1861.result b/mysql-test/suite/tianmu/r/issue1861.result
new file mode 100644
index 000000000..eb9d57c40
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1861.result
@@ -0,0 +1,61 @@
+DROP DATABASE IF EXISTS issue1861_test;
+CREATE DATABASE issue1861_test;
+USE issue1861_test;
+CREATE TABLE `c1fg_pool` (
+`ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `c1fg_pl_node` (
+`ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+`POOL_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+`COMPANY_ID` decimal(18,0) DEFAULT '-1',
+PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `c1fg_pl_account` (
+`ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+`NODE_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `c1fg_pl_subsidiary` (
+`ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+`ACCOUNT_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+`FISCAL_DATE` date DEFAULT NULL,
+`DR_AMOUNT` decimal(16,2) NOT NULL DEFAULT '0.00' ,
+PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+CREATE TABLE `c1md_company` (
+`ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1' ,
+`SYS_ID` decimal(18,0) NOT NULL DEFAULT '-1' ,
+PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+SELECT B.company_id,
+'上划日' ud_type,
+2 sort_no,
+'合计' fiscal_date,
+DATE_FORMAT('2023-06-06', '%Y-%m-%d') fiscal_date,
+C.pl_amount
+FROM c1fg_pool A
+INNER JOIN c1fg_pl_node B
+ON A.row_id = B.pool_id
+LEFT JOIN (SELECT c.node_id, SUM(d.dr_amount) pl_amount
+FROM c1fg_pool a,
+c1fg_pl_node b,
+c1fg_pl_account c,
+c1fg_pl_subsidiary d
+WHERE a.row_id = b.pool_id
+AND b.row_id = c.node_id
+AND c.row_id = d.account_id
+AND b.company_id IN
+(SELECT t1.row_id
+FROM c1md_company t1, c1md_company t2
+WHERE t1.sys_id = t2.sys_id)
+GROUP BY c.node_id) C
+ON B.row_id = C.node_id
+ORDER BY B.company_id;
+company_id ud_type sort_no fiscal_date fiscal_date pl_amount
+DROP TABLE c1md_company;
+DROP TABLE c1fg_pl_subsidiary;
+DROP TABLE c1fg_pl_account;
+DROP TABLE c1fg_pl_node;
+DROP TABLE c1fg_pool;
+DROP DATABASE issue1861_test;
diff --git a/mysql-test/suite/tianmu/r/issue1864.result b/mysql-test/suite/tianmu/r/issue1864.result
new file mode 100644
index 000000000..a4095d46b
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1864.result
@@ -0,0 +1,32 @@
+DROP DATABASE IF EXISTS issue1864_test;
+CREATE DATABASE issue1864_test;
+USE issue1864_test;
+create table t1(c1 decimal(5,2)) engine=tianmu;
+insert into t1 values(111.22);
+create table t2(id int) engine=tianmu;
+insert into t2 values(11122);
+select xxx.x from (select c1 as x from t1 union all select 1 as x from t2) xxx;
+x
+111.22
+1.00
+select xxx.x from ( select t1.c1 as x from t1 inner join t2 on t1.c1 != t2.id ) xxx;
+x
+111.22
+CREATE TABLE cs1 (d1 DECIMAL(17), d2 DECIMAL(17,10), d3 DECIMAL(17,17)) engine=tianmu;
+INSERT INTO cs1 VALUES (125, 1.25, 0.125);
+INSERT INTO cs1 VALUES (-125, -1.25, -0.125);
+select * from cs1;
+d1 d2 d3
+125 1.2500000000 0.12500000000000000
+-125 -1.2500000000 -0.12500000000000000
+select * from cs1 union select * from cs1;
+d1 d2 d3
+125 1.2500000000 0.12500000000000000
+-125 -1.2500000000 -0.12500000000000000
+SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1;
+d1 d1 d2
+125.0000000000 -59.46744073709551616 1.25000000000000000
+-125.0000000000 59.46744073709551616 -1.25000000000000000
+1.2500000000 0.12500000000000000 0.12500000000000000
+-1.2500000000 -0.12500000000000000 -0.12500000000000000
+DROP DATABASE issue1864_test;
diff --git a/mysql-test/suite/tianmu/r/issue1865.result b/mysql-test/suite/tianmu/r/issue1865.result
new file mode 100644
index 000000000..9612b32ae
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/issue1865.result
@@ -0,0 +1,29 @@
+DROP DATABASE IF EXISTS issue1865_test_db;
+CREATE DATABASE issue1865_test_db;
+USE issue1865_test_db;
+create table t1 (a int default 100, b int, c varchar(60))engine=tianmu;
+load data infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+a b c
+NULL NULL 10
+NULL NULL 15
+alter table t1 alter column b drop default;
+alter table t1 alter column b set default 10;
+load data infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+a b c
+NULL NULL 10
+NULL NULL 15
+NULL 10 10
+NULL 10 15
+alter table t1 modify c text;
+load data infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+a b c
+NULL NULL 10
+NULL NULL 15
+NULL 10 10
+NULL 10 15
+NULL 10 10
+NULL 10 15
+DROP DATABASE issue1865_test_db;
diff --git a/mysql-test/suite/tianmu/r/issue663.result b/mysql-test/suite/tianmu/r/issue663.result
index 620b3c789..ad7395cd8 100644
--- a/mysql-test/suite/tianmu/r/issue663.result
+++ b/mysql-test/suite/tianmu/r/issue663.result
@@ -15,8 +15,8 @@ a b a b
2 12 2 12
explain delete t11.*,t12.* from t11,t12 where t11.a = t12.a;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
-1 DELETE t11 NULL ALL NULL NULL NULL NULL 3 100.00 NULL
-1 DELETE t12 NULL ALL NULL NULL NULL NULL 3 33.33 Using where
+1 DELETE t11 NULL ALL PRIMARY NULL NULL NULL 3 100.00 NULL
+1 DELETE t12 NULL ALL PRIMARY NULL NULL NULL 3 33.33 Using where
delete t11.*,t12.* from t11,t12 where t11.a = t12.a;
select * from t11;
a b
diff --git a/mysql-test/suite/tianmu/r/issue848.result b/mysql-test/suite/tianmu/r/issue848.result
index e37ed1c6d..d5a931288 100644
--- a/mysql-test/suite/tianmu/r/issue848.result
+++ b/mysql-test/suite/tianmu/r/issue848.result
@@ -1,5 +1,6 @@
-create database test_issue848;
-use test_issue848;
+DROP DATABASE IF EXISTS issue848_test;
+CREATE DATABASE issue848_test;
+USE issue848_test;
CREATE TABLE `t1` (
`c_char` char(10) DEFAULT NULL COMMENT 'char',
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar',
@@ -29,7 +30,7 @@ t1 CREATE TABLE `t1` (
`c_varchar` varchar(10) CHARACTER SET gbk DEFAULT NULL COMMENT 'varchar',
`c_text` text CHARACTER SET gbk COMMENT 'text'
) ENGINE=TIANMU DEFAULT CHARSET=latin1
-alter table t1 add column ex_column char(30);
+ALTER TABLE t1 ADD COLUMN ex_column char(30) AFTER c_text;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -38,15 +39,15 @@ t1 CREATE TABLE `t1` (
`c_text` text CHARACTER SET gbk COMMENT 'text',
`ex_column` char(30) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
-ALTER TABLE t1 MODIFY c_char char(10) CHARACTER SET UTF8MB4;
-ALTER TABLE t1 MODIFY c_varchar char(10) CHARACTER SET UTF8MB4;
-ALTER TABLE t1 MODIFY c_text char(10) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_char char(15) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_varchar char(15) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_text char(15) CHARACTER SET UTF8MB4;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `c_char` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
- `c_varchar` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
- `c_text` char(10) CHARACTER SET utf8mb4 DEFAULT NULL,
+ `c_char` char(15) CHARACTER SET utf8mb4 DEFAULT NULL,
+ `c_varchar` char(15) CHARACTER SET utf8mb4 DEFAULT NULL,
+ `c_text` char(15) CHARACTER SET utf8mb4 DEFAULT NULL,
`ex_column` char(30) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
select hex(c_char),hex(c_varchar),hex(c_text) from t1;
@@ -66,5 +67,5 @@ t1 CREATE TABLE `t1` (
`c_text` char(10) CHARACTER SET gbk DEFAULT NULL,
`ex_column` char(30) DEFAULT NULL
) ENGINE=TIANMU DEFAULT CHARSET=latin1
-drop table t1;
-drop database test_issue848;
+DROP TABLE t1;
+DROP DATABASE issue848_test;
diff --git a/mysql-test/suite/tianmu/r/issue880.result b/mysql-test/suite/tianmu/r/issue880.result
index e88a7d6e1..11135464f 100644
--- a/mysql-test/suite/tianmu/r/issue880.result
+++ b/mysql-test/suite/tianmu/r/issue880.result
@@ -103,9 +103,9 @@ CREATE TABLE `issue880_t3` (
`union_order_flag` smallint(1) DEFAULT '0' COMMENT '是否合成订单0不是,1是; Size[MB]: 0.1; Ratio: 2.12',
PRIMARY KEY (`id`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED;
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t1.txt' INTO TABLE issue880_t1;
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t3.txt' INTO TABLE issue880_t3;
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t2.txt' INTO TABLE issue880_t2;
+LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t1.txt' INTO TABLE issue880_t1 FIELDS TERMINATED BY ';';
+LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t3.txt' INTO TABLE issue880_t3 FIELDS TERMINATED BY ';';
+LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t2.txt' INTO TABLE issue880_t2 FIELDS TERMINATED BY ';';
select b.create_time AS create_time
from (issue880_t3 a join issue880_t1 b)
where ((a.id = b.period_pay_id) and (a.pay_status = 2) and
diff --git a/mysql-test/suite/tianmu/r/issue956.result b/mysql-test/suite/tianmu/r/issue956.result
index c56185b26..a9197679f 100644
--- a/mysql-test/suite/tianmu/r/issue956.result
+++ b/mysql-test/suite/tianmu/r/issue956.result
@@ -1,13 +1,13 @@
include/master-slave.inc
[connection master]
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
# default_storage_engine=innodb
#
[on slave]
include/sync_slave_sql_with_master.inc
set global default_storage_engine=innodb;
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
[on master]
create table t_issue956(c1 int,c2 varchar(255))engine=InnoDB;
show create table t_issue956;
@@ -20,7 +20,7 @@ t_issue956 CREATE TABLE `t_issue956` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
@@ -43,7 +43,7 @@ t_issue956 CREATE TABLE `t_issue956` (
[on slave]
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
@@ -59,12 +59,12 @@ t_issue956 CREATE TABLE `t_issue956` (
drop table t_issue956;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='MANDATORY_TIANMU'
+# tianmu_mandatory=ON
# default_storage_engine=innodb
#
[on slave]
set global default_storage_engine=innodb;
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
[on master]
create table t_issue956_2(c1 int,c2 varchar(255))engine=InnoDB;
show create table t_issue956_2;
@@ -77,7 +77,7 @@ t_issue956_2 CREATE TABLE `t_issue956_2` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
@@ -100,7 +100,7 @@ t_issue956_2 CREATE TABLE `t_issue956_2` (
[on slave]
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine InnoDB
@@ -116,12 +116,12 @@ t_issue956_2 CREATE TABLE `t_issue956_2` (
drop table t_issue956_2;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
# default_storage_engine=tianmu
#
[on slave]
set global default_storage_engine=tianmu;
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
[on master]
create table t_issue956_3(c1 int,c2 varchar(255))engine=InnoDB;
show create table t_issue956_3;
@@ -134,7 +134,7 @@ t_issue956_3 CREATE TABLE `t_issue956_3` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -157,7 +157,7 @@ t_issue956_3 CREATE TABLE `t_issue956_3` (
[on slave]
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -173,12 +173,12 @@ t_issue956_3 CREATE TABLE `t_issue956_3` (
drop table t_issue956_3;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU'
+# tianmu_mandatory=ON
# default_storage_engine=tianmu
#
[on slave]
set global default_storage_engine=tianmu;
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
[on master]
create table t_issue956_4(c1 int,c2 varchar(255))engine=InnoDB;
show create table t_issue956_4;
@@ -191,7 +191,7 @@ t_issue956_4 CREATE TABLE `t_issue956_4` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -214,7 +214,7 @@ t_issue956_4 CREATE TABLE `t_issue956_4` (
[on slave]
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine TIANMU
@@ -230,12 +230,12 @@ t_issue956_4 CREATE TABLE `t_issue956_4` (
drop table t_issue956_4;
include/sync_slave_sql_with_master.inc
#
-# sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+# tianmu_mandatory=OFF
# default_storage_engine=MyISAM
#
[on slave]
set global default_storage_engine=MyISAM;
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
[on master]
create table t_issue956_4(c1 int,c2 varchar(255))engine=InnoDB;
show create table t_issue956_4;
@@ -248,7 +248,7 @@ t_issue956_4 CREATE TABLE `t_issue956_4` (
include/sync_slave_sql_with_master.inc
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine MyISAM
@@ -271,7 +271,7 @@ t_issue956_4 CREATE TABLE `t_issue956_4` (
[on slave]
show global variables like 'sql_mode';
Variable_name Value
-sql_mode STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql_mode ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
show global variables like '%_engine';
Variable_name Value
default_storage_engine MyISAM
diff --git a/mysql-test/suite/tianmu/r/left_right_func.result b/mysql-test/suite/tianmu/r/left_right_func.result
new file mode 100644
index 000000000..699c44d14
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/left_right_func.result
@@ -0,0 +1,36 @@
+#
+# left and right func test
+#
+DROP DATABASE IF EXISTS left_right_func_test;
+CREATE DATABASE left_right_func_test;
+USE left_right_func_test;
+DROP TABLE IF EXISTS t1;
+CREATE TABLE t1 (`time_tk` INT(11) UNSIGNED NOT NULL) DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES
+(2013113023),
+(1900010100),
+(2199123100),
+(2199123100),
+(2147483646),
+(2147483647),
+(2147483648);
+SELECT LEFT(time_tk,6) AS time_tk_left FROM t1;
+time_tk_left
+201311
+190001
+219912
+219912
+214748
+214748
+214748
+SELECT RIGHT(time_tk,6) AS time_tk_right FROM t1;
+time_tk_right
+113023
+010100
+123100
+123100
+483646
+483647
+483648
+DROP TABLE IF EXISTS t1;
+DROP DATABASE left_right_func_test;
diff --git a/mysql-test/suite/tianmu/r/like_not_like.result b/mysql-test/suite/tianmu/r/like_not_like.result
new file mode 100644
index 000000000..0f17bf0e9
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/like_not_like.result
@@ -0,0 +1,17 @@
+#
+# This test tests the (NOT) LIKE test in filters that is added
+# to a FilterCommand in primproc.
+# This is a very rare situation, yet somehow I managed to trigger it.
+#
+DROP DATABASE IF EXISTS like_not_like;
+CREATE DATABASE like_not_like;
+USE like_not_like;
+CREATE TABLE tcs(d1 CHAR(6), d2 CHAR(6));
+INSERT INTO tcs(d1, d2) VALUES ('a','a'), ('a', 'b');
+SELECT 'stonedb like', d1, d2 FROM tcs WHERE (d1 LIKE d2);
+stonedb like d1 d2
+stonedb like a a
+SELECT 'stonedb not like', d1, d2 FROM tcs WHERE (d1 NOT LIKE d2);
+stonedb not like d1 d2
+stonedb not like a b
+DROP DATABASE like_not_like;
diff --git a/mysql-test/suite/tianmu/r/multi_join.result b/mysql-test/suite/tianmu/r/multi_join.result
new file mode 100644
index 000000000..9de477a7e
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/multi_join.result
@@ -0,0 +1,29 @@
+#
+# right join/left join/inner join /full join
+#
+DROP DATABASE IF EXISTS multi_join_test;
+CREATE DATABASE multi_join_test;
+USE multi_join_test;
+drop table if exists all_datatype_table;
+Warnings:
+Note 1051 Unknown table 'multi_join_test.all_datatype_table'
+create table all_datatype_table(id int not null,c_intger integer,c_char char(10));
+insert into all_datatype_table values(1,1000,1000);
+insert into all_datatype_table values(2,2000,1000);
+insert into all_datatype_table values(3,2001,null);
+insert into all_datatype_table values(4,2002,'a');
+select count(*) from all_datatype_table t1 right join all_datatype_table t2 on t1.id=t2.id
+inner join all_datatype_table t3 on t1.id=t3.id
+right join all_datatype_table t4 on t1.id=t4.id
+left join all_datatype_table t5 on t1.id=t5.id
+inner join all_datatype_table t6 on t1.id=t6.id
+left join all_datatype_table t7 on t1.id=t7.id
+right join all_datatype_table t8 on t1.id=t8.id
+right join all_datatype_table t10 on t1.id=t10.id
+right join all_datatype_table t11 on t1.id=t11.id
+right join all_datatype_table t13 on t1.id=t13.id
+right join all_datatype_table t15 on t1.id=t15.id
+right join all_datatype_table t16 on t1.id=t16.id;
+count(*)
+4
+drop DATABASE multi_join_test;
diff --git a/mysql-test/suite/tianmu/r/order_by.result b/mysql-test/suite/tianmu/r/order_by.result
new file mode 100644
index 000000000..0ccc367c3
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/order_by.result
@@ -0,0 +1,58 @@
+DROP DATABASE IF EXISTS order_by;
+CREATE DATABASE order_by;
+USE order_by;
+create table t1 (a int, b int) ;
+create table t2 (a int, b int) ;
+insert into t1 values (1, 2), (1, 3), (1, 4), (2, 5), (2, 6), (2, 7);
+insert into t2 values (1, 2), (1, 2), (1, 4), (2, 5), (2, 6), (2, 8);
+select * from t1, t2 where t1.a = t2.a and t2.b = (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+a b a b
+1 2 1 4
+1 3 1 4
+1 4 1 4
+2 5 2 8
+2 6 2 8
+2 7 2 8
+select * from t1, t2 where t1.a = t2.a and t2.b < (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+a b a b
+1 2 1 2
+1 2 1 2
+1 3 1 2
+1 3 1 2
+1 4 1 2
+1 4 1 2
+2 5 2 5
+2 5 2 6
+2 6 2 5
+2 6 2 6
+2 7 2 5
+2 7 2 6
+select * from t1, t2 where t1.a = t2.a and t2.b > (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+a b a b
+select * from t1, t2 where t1.a = t2.a and t1.b = (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b;
+a b a b
+select * from t1, t2 where t1.a = t2.a and t2.b < (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t1.a,t1.b,t2.b;
+a b a b
+1 2 1 2
+1 2 1 2
+1 3 1 2
+1 3 1 2
+1 4 1 2
+1 4 1 2
+2 5 2 5
+2 5 2 6
+2 6 2 5
+2 6 2 6
+2 7 2 5
+2 7 2 6
+select * from t1, t2 where t1.a = t2.a and t2.b > (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t1.a,t1.b,t2.b;
+a b a b
+1 2 1 4
+1 3 1 4
+1 4 1 4
+2 5 2 8
+2 6 2 8
+2 7 2 8
+drop table t1;
+drop table t2;
+DROP DATABASE order_by;
diff --git a/mysql-test/suite/tianmu/r/range.result b/mysql-test/suite/tianmu/r/range.result
new file mode 100644
index 000000000..e09a9a5df
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/range.result
@@ -0,0 +1,1154 @@
+#
+# Test range
+#
+DROP DATABASE IF EXISTS range_test;
+CREATE DATABASE range_test;
+USE range_test;
+drop table if exists t1, t2, t3;
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+Warnings:
+Warning 3090 Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated. It will be removed in a future release.
+CREATE TABLE t1 (
+event_date date DEFAULT '0000-00-00' NOT NULL,
+type int(11) DEFAULT '0' NOT NULL,
+event_id int(11) DEFAULT '0' NOT NULL,
+PRIMARY KEY (event_date,type,event_id)
+);
+INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
+('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26),
+('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45),
+('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5),
+('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17),
+('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40),
+('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6),
+('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41),
+('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41),
+('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29),
+('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19),
+('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42),
+('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30),
+('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8),
+('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22),
+('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43),
+('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37),
+('1999-09-19',100100,37), ('2000-12-18',100700,38);
+select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
+event_date type event_id
+1999-07-10 100100 24
+1999-07-11 100100 25
+1999-07-13 100600 0
+1999-07-13 100600 4
+1999-07-13 100600 26
+1999-07-14 100600 10
+explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
+id select_type table partitions type possible_keys key key_len ref rows filtered Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+Warnings:
+Note 1003 /* select#1 */ select `range_test`.`t1`.`event_date` AS `event_date`,`range_test`.`t1`.`type` AS `type`,`range_test`.`t1`.`event_id` AS `event_id` from `range_test`.`t1` where 0 order by `range_test`.`t1`.`event_date`
+select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
+event_date type event_id
+1999-07-10 100100 24
+1999-07-11 100100 25
+1999-07-13 100600 0
+1999-07-13 100600 4
+1999-07-13 100600 26
+1999-07-14 100600 10
+1999-07-15 100600 16
+drop table t1;
+CREATE TABLE t1 (
+PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
+YEAR smallint(6) DEFAULT '0' NOT NULL,
+ISSUE smallint(6) DEFAULT '0' NOT NULL,
+CLOSED tinyint(4) DEFAULT '0' NOT NULL,
+ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
+PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
+);
+INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
+(1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'),
+(3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'),
+(3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'),
+(3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'),
+(1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'),
+(1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'),
+(1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'),
+(1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'),
+(1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'),
+(1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'),
+(1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'),
+(1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'),
+(1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'),
+(3,1999,35,0,'1999-07-12');
+select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE;
+YEAR ISSUE
+1999 29
+1999 30
+1999 31
+1999 32
+1999 33
+1999 34
+1999 35
+drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+parent_id int(11) DEFAULT '0' NOT NULL,
+level tinyint(4) DEFAULT '0' NOT NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2),
+(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2),
+(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1),
+(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2),
+(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2),
+(19,3,2), (5,1,1), (179,5,2);
+SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
+id parent_id level
+2 1 1
+3 1 1
+4 1 1
+5 1 1
+6 1 1
+7 1 1
+drop table t1;
+create table t1(
+Satellite varchar(25) not null,
+SensorMode varchar(25) not null,
+FullImageCornersUpperLeftLongitude double not null,
+FullImageCornersUpperRightLongitude double not null,
+FullImageCornersUpperRightLatitude double not null,
+FullImageCornersLowerRightLatitude double not null);
+insert into t1 values("OV-3","PAN1",91,-92,40,50);
+insert into t1 values("OV-4","PAN1",91,-92,40,50);
+select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
+Satellite SensorMode FullImageCornersUpperLeftLongitude FullImageCornersUpperRightLongitude FullImageCornersUpperRightLatitude FullImageCornersLowerRightLatitude
+OV-3 PAN1 91 -92 40 50
+drop table t1;
+create table t1 ( aString char(100) not null default "");
+insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love");
+select * from t1 where aString < "believe in myself" order by aString;
+aString
+baaa
+believe
+believe in love
+select * from t1 where aString > "believe in love" order by aString;
+aString
+believe in myself
+select * from t1 where aString < "believe in myself" order by aString;
+aString
+baaa
+believe
+believe in love
+select * from t1 where aString > "believe in love" order by aString;
+aString
+believe in myself
+drop table t1;
+create table t1 (id int(10) primary key);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
+select id from t1 where id in (2,5,9) ;
+id
+2
+5
+9
+select id from t1 where id=2 or id=5 or id=9 ;
+id
+2
+5
+9
+drop table t1;
+create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
+insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
+(3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
+(6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
+(9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
+(12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
+(15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
+(18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
+select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
+id1 idnull
+drop table t1;
+create table t1 (
+id int not null auto_increment,
+name char(1) not null,
+uid int not null,
+primary key (id));
+create table t2 (
+id int not null auto_increment,
+name char(1) not null,
+uid int not null,
+primary key (id));
+insert into t1(id, uid, name) values(1, 0, ' ');
+insert into t1(uid, name) values(0, ' ');
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+delete from t2;
+insert into t2(uid, name) values
+(1, CHAR(64+1)),
+(2, CHAR(64+2)),
+(3, CHAR(64+3)),
+(4, CHAR(64+4)),
+(5, CHAR(64+5)),
+(6, CHAR(64+6)),
+(7, CHAR(64+7)),
+(8, CHAR(64+8)),
+(9, CHAR(64+9)),
+(10, CHAR(64+10)),
+(11, CHAR(64+11)),
+(12, CHAR(64+12)),
+(13, CHAR(64+13)),
+(14, CHAR(64+14)),
+(15, CHAR(64+15)),
+(16, CHAR(64+16)),
+(17, CHAR(64+17)),
+(18, CHAR(64+18)),
+(19, CHAR(64+19)),
+(20, CHAR(64+20)),
+(21, CHAR(64+21)),
+(22, CHAR(64+22)),
+(23, CHAR(64+23)),
+(24, CHAR(64+24)),
+(25, CHAR(64+25)),
+(26, CHAR(64+26));
+insert into t1(uid, name) select uid, name from t2 order by uid;
+delete from t1;
+delete from t2;
+insert into t2(id, uid, name) select id, uid, name from t1;
+select count(*) from t1;
+count(*)
+0
+select count(*) from t2;
+count(*)
+0
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+id name uid id name uid
+select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
+id name uid id name uid
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+id name uid id name uid
+select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
+id name uid id name uid
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0 order by t1.id;
+id name uid id name uid
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0 order by t1.id;
+id name uid id name uid
+drop table t1,t2;
+create table t1 (x bigint unsigned not null);
+insert into t1(x) values (0xfffffffffffff0);
+insert into t1(x) values (0xfffffffffffff1);
+select * from t1;
+x
+72057594037927920
+72057594037927921
+select count(*) from t1 where x>0;
+count(*)
+2
+select count(*) from t1 where x=0;
+count(*)
+0
+select count(*) from t1 where x<0;
+count(*)
+0
+select count(*) from t1 where x < -16;
+count(*)
+0
+select count(*) from t1 where x = -16;
+count(*)
+0
+select count(*) from t1 where x > -16;
+count(*)
+2
+select count(*) from t1 where x = 18446744073709551601;
+count(*)
+0
+create table t2 (x bigint not null);
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
+select * from t2;
+x
+-16
+-15
+select count(*) from t2 where x>0;
+count(*)
+0
+select count(*) from t2 where x=0;
+count(*)
+0
+select count(*) from t2 where x<0;
+count(*)
+2
+select count(*) from t2 where x < -16;
+count(*)
+0
+select count(*) from t2 where x = -16;
+count(*)
+1
+select count(*) from t2 where x > -16;
+count(*)
+1
+drop table t1,t2;
+create table t1 (x bigint unsigned not null primary key) engine=innodb;
+insert into t1(x) values (0xfffffffffffff0);
+insert into t1(x) values (0xfffffffffffff1);
+select * from t1;
+x
+72057594037927920
+72057594037927921
+select count(*) from t1 where x>0;
+count(*)
+2
+select count(*) from t1 where x=0;
+count(*)
+0
+select count(*) from t1 where x<0;
+count(*)
+0
+select count(*) from t1 where x < -16;
+count(*)
+0
+select count(*) from t1 where x = -16;
+count(*)
+0
+select count(*) from t1 where x > -16;
+count(*)
+2
+select count(*) from t1 where x = 18446744073709551601;
+count(*)
+0
+drop table t1;
+create table t1 (a bigint unsigned);
+insert into t1 select 184467440737095515;
+insert into t1 select 184467440737095514;
+select * from t1 where a <> -1;
+a
+184467440737095515
+184467440737095514
+select * from t1 where a > -1 or a < -1;
+a
+184467440737095515
+184467440737095514
+select * from t1 where a > -1;
+a
+184467440737095515
+184467440737095514
+select * from t1 where a < -1;
+a
+drop table t1;
+set names latin1;
+create table t1 (a char(10), b text) character set latin1;
+INSERT INTO t1 (a) VALUES
+('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
+drop table t1;
+CREATE TABLE t1 (
+`CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
+`ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '',
+`ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '',
+`FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '',
+`FUNCTINT` int(11) NOT NULL default '0'
+) DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
+('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0),
+('001',' 3',' 0','Text 017',0);
+SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2');
+count(*)
+4
+SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1');
+count(*)
+4
+drop table t1;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+CREATE TABLE t2 (
+pk1 int(11) NOT NULL,
+pk2 int(11) NOT NULL,
+pk3 int(11) NOT NULL,
+pk4 int(11) NOT NULL,
+filler char(82),
+PRIMARY KEY (pk1,pk2,pk3,pk4)
+) DEFAULT CHARSET=latin1;
+insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
+INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
+(2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
+(2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
+SELECT * FROM t2
+WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635)))
+OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635))))
+) AND (pk3 >=1000000);
+pk1 pk2 pk3 pk4 filler
+2621 2635 1000015 0 filler
+drop table t1, t2;
+create table t1(a char(2));
+insert into t1 values ('x'), ('xx');
+select a from t1 where a > 'x';
+a
+xx
+drop table t1;
+create table t1 (
+c1 char(10), c2 char(10), c3 char(10), c4 char(10),
+c5 char(10), c6 char(10), c7 char(10), c8 char(10),
+c9 char(10), c10 char(10), c11 char(10), c12 char(10),
+c13 char(10), c14 char(10), c15 char(10), c16 char(10)
+);
+insert into t1 (c1) values ('1'),('1'),('1'),('1');
+select * from t1 where
+c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+"abcdefg1", "123456781", "qwertyui1", "asddfg1",
+"abcdefg2", "123456782", "qwertyui2", "asddfg2",
+"abcdefg3", "123456783", "qwertyui3", "asddfg3",
+"abcdefg4", "123456784", "qwertyui4", "asddfg4",
+"abcdefg5", "123456785", "qwertyui5", "asddfg5",
+"abcdefg6", "123456786", "qwertyui6", "asddfg6",
+"abcdefg7", "123456787", "qwertyui7", "asddfg7",
+"abcdefg8", "123456788", "qwertyui8", "asddfg8",
+"abcdefg9", "123456789", "qwertyui9", "asddfg9",
+"abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+"abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+"abcdefgC", "12345678C", "qwertyuiC", "asddfgC");
+c1 c2 c3 c4 c5 c6 c7 c8 c9 c10 c11 c12 c13 c14 c15 c16
+drop table t1;
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+status varchar(20),
+PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES
+(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'),
+(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'),
+(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'),
+(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'),
+(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'),
+(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'),
+(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'),
+(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
+(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
+(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
+SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+SELECT * FROM t1 WHERE status NOT IN ('A','B');
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+id status
+53 C
+54 C
+55 C
+56 C
+57 C
+58 C
+59 C
+60 C
+DROP TABLE t1;
+CREATE TABLE t1 (a int, b int, primary key(a,b));
+INSERT INTO t1 VALUES
+(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
+CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
+SELECT a,b FROM t1 WHERE a < 2 and b=3;
+a b
+1 3
+SELECT a,b FROM v1 WHERE a < 2 and b=3;
+a b
+1 3
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (name varchar(15) NOT NULL);
+INSERT INTO t1 VALUES ('Betty'), ('Anna');
+SELECT * FROM t1;
+name
+Betty
+Anna
+DELETE FROM t1 WHERE name NOT LIKE 'A%a';
+SELECT * FROM t1;
+name
+Anna
+DROP TABLE t1;
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (NULL), (1), (2), (3);
+SELECT * FROM t1;
+a
+NULL
+1
+2
+3
+DELETE FROM t1 WHERE NOT(a <=> 2);
+SELECT * FROM t1;
+a
+2
+DROP TABLE t1;
+create table t1 (a int, b int, primary key(a,b));
+create view v1 as select a, b from t1;
+INSERT INTO `t1` VALUES
+(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2)
+,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
+drop view v1;
+drop table t1;
+create table t3 (a int);
+insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a varchar(10), filler char(200)) charset=binary;
+insert into t1 values ('a','');
+insert into t1 values ('a ','');
+insert into t1 values ('a ', '');
+insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), ''
+ from t3 A, t3 B, t3 C;
+create table t2 (a varchar(10), filler char(200));
+insert into t2 select * from t1;
+update t1 set a='b' where a<>'a';
+select a, hex(filler) from t1 where a not between 'b' and 'b';
+a hex(filler)
+a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+drop table t1,t2,t3;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int);
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+count(*)
+1000
+set @a=concat(@a, ')');
+insert into t2 values (11),(13),(15);
+drop table t1, t2;
+CREATE TABLE t1 (
+id int NOT NULL DEFAULT '0',
+b int NOT NULL DEFAULT '0',
+c int NOT NULL DEFAULT '0');
+INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+INSERT INTO t1(b,c) VALUES (3,4), (3,4);
+SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+id b c
+0 3 4
+0 3 4
+SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+id b c
+0 3 4
+0 3 4
+SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+id b c
+0 3 4
+0 3 4
+SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+id b c
+0 3 4
+0 3 4
+DROP TABLE t1;
+
+"Comparison of DATE with DATETIME still not using indexes correctly"
+
+CREATE TABLE t1 (
+id int(11) NOT NULL auto_increment,
+dateval date default NULL,
+PRIMARY KEY (id)
+) AUTO_INCREMENT=173;
+INSERT INTO t1 VALUES
+(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
+(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
+(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
+drop table t1;
+CREATE TABLE t1 (
+a varchar(32)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+INSERT INTO t1 VALUES
+('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
+SELECT a FROM t1 WHERE a='b' OR a='B';
+a
+B
+B
+DROP TABLE t1;
+CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255;
+COUNT(*)
+4
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1;
+COUNT(*)
+0
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+DROP TABLE t1;
+CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1));
+INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127;
+COUNT(*)
+4
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0;
+COUNT(*)
+5
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128;
+COUNT(*)
+4
+Warnings:
+Warning 1681 'SQL_NO_CACHE' is deprecated and will be removed in a future release.
+DROP TABLE t1;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int, b int, filler char(100));
+insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
+t1 B, t1 C where A.a < 5;
+insert into t2 select 1000, b, 'filler' from t2;
+drop table t1, t2;
+CREATE TABLE t1( a INT, b INT);
+CREATE TABLE t2( a INT, b INT );
+CREATE TABLE t3( a INT, b INT );
+INSERT INTO t1( a, b )
+VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7);
+INSERT INTO t2( a, b )
+VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1),
+( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1),
+(11, 1), (12, 1), (13, 1), (14, 1), (15, 1),
+(16, 1), (17, 1), (18, 1), (19, 1), (20, 1);
+INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1;
+INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1;
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+INSERT INTO t3
+VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
+(6, 0), (7, 0), (8, 0), (9, 0), (10, 0);
+INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
+INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
+SELECT * FROM t1 WHERE
+3 <= a AND a < 5 OR
+5 < a AND b = 3 OR
+3 <= a;
+a b
+5 0
+9 7
+SELECT * FROM t2 WHERE
+5 <= a AND a < 10 AND b = 1 OR
+15 <= a AND a < 20 AND b = 3
+OR
+1 <= a AND b = 1;
+a b
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+10 1
+11 1
+12 1
+13 1
+14 1
+15 1
+16 1
+17 1
+18 1
+19 1
+20 1
+15 3
+16 3
+17 3
+18 3
+19 3
+SELECT * FROM t2 WHERE
+5 <= a AND a < 10 AND b = 2 OR
+15 <= a AND a < 20 AND b = 3
+OR
+1 <= a AND b = 1;
+a b
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+10 1
+11 1
+12 1
+13 1
+14 1
+15 1
+16 1
+17 1
+18 1
+19 1
+20 1
+5 2
+6 2
+7 2
+8 2
+9 2
+15 3
+16 3
+17 3
+18 3
+19 3
+SELECT * FROM t3 WHERE
+5 <= a AND a < 10 AND b = 3 OR
+a < 5 OR
+a < 10;
+a b
+1 0
+2 0
+3 0
+4 0
+5 0
+6 0
+7 0
+8 0
+9 0
+DROP TABLE t1, t2, t3;
+#
+# Endless 100% CPU loop with STRAIGHT_JOIN
+#
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (NULL);
+SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL);
+a
+DROP TABLE t1;
+#
+# regression of range optimizer and date comparison in 5.1.39!
+#
+CREATE TABLE t1 ( a DATE );
+CREATE TABLE t2 ( a DATETIME);
+# Make optimizer choose range scan
+INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22');
+INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23');
+INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'),
+('2009-09-22 12:00:00');
+INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'),
+('2009-09-23 12:00:00');
+# DATE vs DATE
+SELECT * FROM t1 WHERE a >= '2009/09/23';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '20090923';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009-9-23';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009.09.23';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009:09:23';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+# DATE vs DATETIME
+SELECT * FROM t2 WHERE a >= '2009/09/23';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '20090923';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009-9-23';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009.09.23';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009:09:23';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+# DATETIME vs DATETIME
+SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '20090923120000';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00';
+a
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+2009-09-23 12:00:00
+# DATETIME vs DATE
+SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '20090923000000';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00';
+a
+2009-09-23
+2009-09-23
+2009-09-23
+# Test of the new get_date_from_str implementation
+# Behavior differs slightly between the trunk and mysql-pe.
+# The former may give errors for the truncated values, while the latter
+# gives warnings. The purpose of this test is not to interfere, and only
+# preserve existing behavior.
+SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
+str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20';
+str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
+str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'
+1
+Warnings:
+Warning 1292 Truncated incorrect date value: ''
+SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
+str_to_date('2007-20-00', '%Y-%m-%d') <= '';
+str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
+str_to_date('2007-20-00', '%Y-%m-%d') <= ''
+NULL
+Warnings:
+Warning 1292 Truncated incorrect date value: ''
+Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
+Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
+SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
+str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
+1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: ''
+SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
+str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''
+NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '2007-20-00' for function str_to_date
+SELECT str_to_date('', '%Y-%m-%d');
+str_to_date('', '%Y-%m-%d')
+0000-00-00
+DROP TABLE t1, t2;
+#
+# valgrind errors with query using 'Range checked for each
+# record'
+#
+CREATE TABLE t1 (
+a INT,
+b CHAR(2),
+c INT,
+d INT
+);
+INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ),
+( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 );
+CREATE TABLE t2 (
+a INT,
+c INT,
+e INT
+);
+INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL );
+# Should not give Valgrind warnings
+SELECT 1
+FROM t1, t2
+WHERE t1.d <> '1' AND t1.b > '1'
+AND t1.a = t2.a AND t1.c = t2.c;
+1
+1
+1
+1
+1
+DROP TABLE t1, t2;
+#
+# sql-bench's insert test fails due to wrong result
+#
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a));
+INSERT INTO t1 VALUES (0,0), (1,1);
+DROP TABLE t1;
+#
+# 'NOT BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1 (c_key INT, c_notkey INT);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+c_key c_notkey
+1 1
+3 3
+DROP TABLE t1;
+#
+# 'BETWEEN' evaluation is incorrect
+#
+CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
+INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+pk i4
+1 10
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+pk i4
+1 10
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+pk i4
+1 10
+2 20
+3 30
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+pk i4
+1 10
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+pk i4
+1 10
+2 20
+3 30
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+pk i4
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+pk i4
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+pk i4
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+pk i4
+1 10
+2 20
+3 30
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+pk i4
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+pk i4
+1 10
+2 20
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+pk i4 pk i4
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+pk i4 pk i4
+DROP TABLE t1;
+#
+# SELECT RESULTS VARY WITH VERSION AND
+# WITH/WITHOUT INDEX RANGE SCAN
+#
+create table t1 (id int unsigned not null auto_increment primary key);
+insert into t1 values (null);
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+create table t2 (
+id int unsigned not null auto_increment,
+val decimal(5,3) not null,
+primary key (id,val));
+insert into t2 select null,id*0.0009 from t1;
+drop database range_test;
diff --git a/mysql-test/suite/tianmu/r/ssb_small.result b/mysql-test/suite/tianmu/r/ssb_small.result
new file mode 100644
index 000000000..c010f8fb3
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/ssb_small.result
@@ -0,0 +1,84 @@
+DROP DATABASE IF EXISTS ssb_small_test;
+CREATE DATABASE ssb_small_test;
+USE ssb_small_test;
+create table part (
+p_partkey int,
+p_name varchar (55),
+p_mfgr char (25),
+p_brand char (10),
+p_type varchar (25),
+p_size int,
+p_container char (10),
+p_retailprice decimal(12,2),
+p_comment varchar (23)
+);
+create table lineitem (
+l_orderkey int,
+l_partkey int,
+l_suppkey int,
+l_linenumber bigint,
+l_quantity decimal(12,2),
+l_extendedprice decimal(12,2),
+l_discount decimal(12,2),
+l_tax decimal(12,2),
+l_returnflag char (1),
+l_linestatus char (1),
+l_shipdate date,
+l_commitdate date,
+l_receiptdate date,
+l_shipinstruct char (25),
+l_shipmode char (10),
+l_comment varchar (44)
+);
+INSERT INTO part VALUES
+(1, 'goldenrod lavender spring chocolate lace', 'Manufacturer#1', 'Brand#13', 'PROMO BURNISHED COPPER', 7, 'JUMBO PKG', 901.00, 'ly. slyly ironi'),
+(2, 'blush thistle blue yellow saddle', 'Manufacturer#1', 'Brand#13', 'LARGE BRUSHED BRASS', 1, 'LG CASE', 902.00, 'lar accounts amo'),
+(3, 'spring green yellow purple cornsilk', 'Manufacturer#4', 'Brand#42', 'STANDARD POLISHED BRASS', 21, 'WRAP CASE', 903.00, 'egular deposits hag'),
+(4, 'cornflower chocolate smoke green pink', 'Manufacturer#3', 'Brand#34', 'SMALL PLATED BRASS', 14, 'MED DRUM', 904.00, 'p furiously r'),
+(5, 'forest brown coral puff cream', 'Manufacturer#3', 'Brand#32', 'STANDARD POLISHED TIN', 15, 'SM PKG', 905.00, 'wake carefully');
+INSERT INTO lineitem VALUES
+(1, 156, 4, 1, 17, 17954.55, 0.04, 0.02, 'N', 'O', '1996-03-13', '1996-02-12', '1996-03-22', 'DELIVER IN PERSON', 'TRUCK', 'egular courts above the'),
+(1, 68, 9, 2, 36, 34850.16, 0.09, 0.06, 'N', 'O', '1996-04-12', '1996-02-28', '1996-04-20', 'TAKE BACK RETURN', 'MAIL', 'ly final dependencies: slyly bold'),
+(1, 64, 5, 3, 8, 7712.48, 0.10, 0.02, 'N', 'O', '1996-01-29', '1996-03-05', '1996-01-31', 'TAKE BACK RETURN', 'REG AIR', 'riously. regular, express dep'),
+(1, 3, 6, 4, 28, 25284.00, 0.09, 0.06, 'N', 'O', '1996-04-21', '1996-03-30', '1996-05-16', 'NONE', 'AIR', 'lites. fluffily even de'),
+(1, 25, 8, 5, 24, 22200.48, 0.10, 0.04, 'N', 'O', '1996-03-30', '1996-03-14', '1996-04-01', 'NONE', 'FOB', 'pending foxes. slyly re'),
+(1, 16, 3, 6, 32, 29312.32, 0.07, 0.02, 'N', 'O', '1996-01-30', '1996-02-07', '1996-02-03', 'DELIVER IN PERSON', 'MAIL', 'arefully slyly ex'),
+(2, 107, 2, 1, 38, 38269.80, 0.00, 0.05, 'N', 'O', '1997-01-28', '1997-01-14', '1997-02-02', 'TAKE BACK RETURN', 'RAIL', 'ven requests. deposits breach a');
+select
+sum(l_extendedprice* (1 - l_discount)) as revenue
+from
+lineitem,
+part
+where
+(
+p_partkey = l_partkey
+and p_brand = 'Brand#23'
+ and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
+and l_quantity >= 2 and l_quantity <= 2 + 10
+and p_size between 1 and 5
+and l_shipmode in ('AIR', 'AIR REG')
+and l_shipinstruct = 'DELIVER IN PERSON'
+ )
+or
+(
+p_partkey = l_partkey
+and p_brand = 'Brand#24'
+ and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
+and l_quantity >= 20 and l_quantity <= 20 + 10
+and p_size between 1 and 10
+and l_shipmode in ('AIR', 'AIR REG')
+and l_shipinstruct = 'DELIVER IN PERSON'
+ )
+or
+(
+p_partkey = l_partkey
+and p_brand = 'Brand#44'
+ and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
+and l_quantity >= 26 and l_quantity <= 26 + 10
+and p_size between 1 and 15
+and l_shipmode in ('AIR', 'AIR REG')
+and l_shipinstruct = 'DELIVER IN PERSON'
+ );
+revenue
+NULL
+DROP DATABASE ssb_small_test;
diff --git a/mysql-test/suite/tianmu/r/std_test.result b/mysql-test/suite/tianmu/r/std_test.result
new file mode 100644
index 000000000..c018c65e1
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/std_test.result
@@ -0,0 +1,193 @@
+#
+# std floor VAR_SAMP func test
+#
+DROP DATABASE IF EXISTS std_test;
+CREATE DATABASE std_test;
+USE std_test;
+create table t1 (
+col_signed tinyint,
+col_unsigned tinyint unsigned
+);
+LOAD DATA LOCAL infile 'MYSQL_TEST_DIR/suite/tianmu/std_data/tinyint_range.tbl' INTO TABLE t1 FIELDS TERMINATED BY '|';
+ALTER TABLE t1 ADD COLUMN col_small_signed SMALLINT;
+ALTER TABLE t1 ADD COLUMN col_small_unsigned SMALLINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_med_signed MEDIUMINT;
+ALTER TABLE t1 ADD COLUMN col_med_unsigned MEDIUMINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_int_signed INT;
+ALTER TABLE t1 ADD COLUMN col_int_unsigned INT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_big_signed BIGINT;
+ALTER TABLE t1 ADD COLUMN col_big_unsigned BIGINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_dec_signed DECIMAL(17,0);
+ALTER TABLE t1 ADD COLUMN col_dec_unsigned DECIMAL(17,0) UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_float_signed FLOAT;
+ALTER TABLE t1 ADD COLUMN col_float_unsigned FLOAT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_double_signed DOUBLE;
+ALTER TABLE t1 ADD COLUMN col_double_unsigned DOUBLE UNSIGNED;
+UPDATE t1 SET col_small_signed=col_signed + sign(col_signed) * 32000;
+UPDATE t1 SET col_small_unsigned=col_unsigned + 65000;
+UPDATE t1 SET col_med_signed=col_signed + sign(col_signed) * 8388000;
+UPDATE t1 SET col_med_unsigned=col_unsigned + 16776000;
+UPDATE t1 SET col_int_signed=col_signed + sign(col_signed) * 2147483000;
+UPDATE t1 SET col_int_unsigned=col_unsigned + 4294000000;
+UPDATE t1 SET col_big_signed=col_signed + sign(col_signed) * 9223372036854775000;
+UPDATE t1 SET col_float_signed=col_signed + 0.637 + sign(col_signed) * 8388000;
+UPDATE t1 SET col_float_unsigned=col_unsigned + 0.637 + 16776000;
+UPDATE t1 SET col_double_signed=col_signed + 0.637 + sign(col_signed) * 2147483000;
+UPDATE t1 SET col_double_unsigned=col_unsigned + 0.637 + 4294000000;
+SELECT 'q1', floor(STD(col_signed)) FROM t1;
+q1 floor(STD(col_signed))
+q1 73
+SELECT 'q2', floor(STD(col_unsigned)) FROM t1;
+q2 floor(STD(col_unsigned))
+q2 73
+SELECT 'q3', floor(STD(col_small_signed)) FROM t1;
+q3 floor(STD(col_small_signed))
+q3 32000
+SELECT 'q4', floor(STD(col_small_unsigned)) FROM t1;
+q4 floor(STD(col_small_unsigned))
+q4 73
+SELECT 'q5', floor(STD(col_med_signed)) FROM t1;
+q5 floor(STD(col_med_signed))
+q5 8371470
+SELECT 'q6', floor(STD(col_med_unsigned)) FROM t1;
+q6 floor(STD(col_med_unsigned))
+q6 73
+SELECT 'q7', floor(STD(col_int_signed)) FROM t1;
+q7 floor(STD(col_int_signed))
+q7 2143234889
+SELECT 'q8', floor(STD(col_int_unsigned)) FROM t1;
+q8 floor(STD(col_int_unsigned))
+q8 73
+SELECT 'q9', floor(STD(col_big_signed)) FROM t1;
+q9 floor(STD(col_big_signed))
+q9 9205126264421171000
+SELECT 'q13', floor(STD(col_float_signed)) FROM t1;
+q13 floor(STD(col_float_signed))
+q13 8371470
+SELECT 'q14', floor(STD(col_float_unsigned)) FROM t1;
+q14 floor(STD(col_float_unsigned))
+q14 73
+SELECT 'q15', floor(STD(col_double_signed)) FROM t1;
+q15 floor(STD(col_double_signed))
+q15 2143234889
+SELECT 'q16', floor(STD(col_double_unsigned)) FROM t1;
+q16 floor(STD(col_double_unsigned))
+q16 73
+SELECT 'q17', floor(STDDEV_SAMP(col_signed)) FROM t1;
+q17 floor(STDDEV_SAMP(col_signed))
+q17 73
+SELECT 'q18', floor(STDDEV_SAMP(col_unsigned)) FROM t1;
+q18 floor(STDDEV_SAMP(col_unsigned))
+q18 73
+SELECT 'q19', floor(STDDEV_SAMP(col_small_signed)) FROM t1;
+q19 floor(STDDEV_SAMP(col_small_signed))
+q19 32063
+SELECT 'q20', floor(STDDEV_SAMP(col_small_unsigned)) FROM t1;
+q20 floor(STDDEV_SAMP(col_small_unsigned))
+q20 73
+SELECT 'q21', floor(STDDEV_SAMP(col_med_signed)) FROM t1;
+q21 floor(STDDEV_SAMP(col_med_signed))
+q21 8387998
+SELECT 'q22', floor(STDDEV_SAMP(col_med_unsigned)) FROM t1;
+q22 floor(STDDEV_SAMP(col_med_unsigned))
+q22 73
+SELECT 'q23', floor(STDDEV_SAMP(col_int_signed)) FROM t1;
+q23 floor(STDDEV_SAMP(col_int_signed))
+q23 2147466354
+SELECT 'q24', floor(STDDEV_SAMP(col_int_unsigned)) FROM t1;
+q24 floor(STDDEV_SAMP(col_int_unsigned))
+q24 73
+SELECT 'q25', floor(STDDEV_SAMP(col_big_signed)) FROM t1;
+q25 floor(STDDEV_SAMP(col_big_signed))
+q25 9223300272764650000
+SELECT 'q29', floor(STDDEV_SAMP(col_float_signed)) FROM t1;
+q29 floor(STDDEV_SAMP(col_float_signed))
+q29 8387998
+SELECT 'q30', floor(STDDEV_SAMP(col_float_unsigned)) FROM t1;
+q30 floor(STDDEV_SAMP(col_float_unsigned))
+q30 73
+SELECT 'q31', floor(STDDEV_SAMP(col_double_signed)) FROM t1;
+q31 floor(STDDEV_SAMP(col_double_signed))
+q31 2147466354
+SELECT 'q32', floor(STDDEV_SAMP(col_double_unsigned)) FROM t1;
+q32 floor(STDDEV_SAMP(col_double_unsigned))
+q32 73
+SELECT 'q33', floor(VAR_POP(col_signed)) FROM t1;
+q33 floor(VAR_POP(col_signed))
+q33 5376
+SELECT 'q34', floor(VAR_POP(col_unsigned)) FROM t1;
+q34 floor(VAR_POP(col_unsigned))
+q34 5376
+SELECT 'q35', floor(VAR_POP(col_small_signed)) FROM t1;
+q35 floor(VAR_POP(col_small_signed))
+q35 1024021882
+SELECT 'q36', floor(VAR_POP(col_small_unsigned)) FROM t1;
+q36 floor(VAR_POP(col_small_unsigned))
+q36 5376
+SELECT 'q37', floor(VAR_POP(col_med_signed)) FROM t1;
+q37 floor(VAR_POP(col_med_signed))
+q37 70081516547007
+SELECT 'q38', floor(VAR_POP(col_med_unsigned)) FROM t1;
+q38 floor(VAR_POP(col_med_unsigned))
+q38 5376
+SELECT 'q39', floor(VAR_POP(col_int_signed)) FROM t1;
+q39 floor(VAR_POP(col_int_signed))
+q39 4593455793567980000
+SELECT 'q40', floor(VAR_POP(col_int_unsigned)) FROM t1;
+q40 floor(VAR_POP(col_int_unsigned))
+q40 5376
+SELECT 'q41', floor(VAR_POP(col_big_signed)) FROM t1;
+q41 floor(VAR_POP(col_big_signed))
+q41 84734349543936470000000000000000000000
+SELECT 'q45', floor(VAR_POP(col_float_signed)) FROM t1;
+q45 floor(VAR_POP(col_float_signed))
+q45 70081516546971
+SELECT 'q46', floor(VAR_POP(col_float_unsigned)) FROM t1;
+q46 floor(VAR_POP(col_float_unsigned))
+q46 5376
+SELECT 'q47', floor(VAR_POP(col_double_signed)) FROM t1;
+q47 floor(VAR_POP(col_double_signed))
+q47 4593455793567980000
+SELECT 'q48', floor(VAR_POP(col_double_unsigned)) FROM t1;
+q48 floor(VAR_POP(col_double_unsigned))
+q48 5376
+SELECT 'q49', floor(VAR_SAMP(col_signed)) FROM t1;
+q49 floor(VAR_SAMP(col_signed))
+q49 5397
+SELECT 'q50', floor(VAR_SAMP(col_unsigned)) FROM t1;
+q50 floor(VAR_SAMP(col_unsigned))
+q50 5397
+SELECT 'q51', floor(VAR_SAMP(col_small_signed)) FROM t1;
+q51 floor(VAR_SAMP(col_small_signed))
+q51 1028069399
+SELECT 'q52', floor(VAR_SAMP(col_small_unsigned)) FROM t1;
+q52 floor(VAR_SAMP(col_small_unsigned))
+q52 5397
+SELECT 'q53', floor(VAR_SAMP(col_med_signed)) FROM t1;
+q53 floor(VAR_SAMP(col_med_signed))
+q53 70358518588695
+SELECT 'q54', floor(VAR_SAMP(col_med_unsigned)) FROM t1;
+q54 floor(VAR_SAMP(col_med_unsigned))
+q54 5397
+SELECT 'q55', floor(VAR_SAMP(col_int_signed)) FROM t1;
+q55 floor(VAR_SAMP(col_int_signed))
+q55 4611611745321213400
+SELECT 'q56', floor(VAR_SAMP(col_int_unsigned)) FROM t1;
+q56 floor(VAR_SAMP(col_int_unsigned))
+q56 5397
+SELECT 'q57', floor(VAR_SAMP(col_big_signed)) FROM t1;
+q57 floor(VAR_SAMP(col_big_signed))
+q57 85069267921580480000000000000000000000
+SELECT 'q61', floor(VAR_SAMP(col_float_signed)) FROM t1;
+q61 floor(VAR_SAMP(col_float_signed))
+q61 70358518588659
+SELECT 'q62', floor(VAR_SAMP(col_float_unsigned)) FROM t1;
+q62 floor(VAR_SAMP(col_float_unsigned))
+q62 5397
+SELECT 'q63', floor(VAR_SAMP(col_double_signed)) FROM t1;
+q63 floor(VAR_SAMP(col_double_signed))
+q63 4611611745321213400
+SELECT 'q64', floor(VAR_SAMP(col_double_unsigned)) FROM t1;
+q64 floor(VAR_SAMP(col_double_unsigned))
+q64 5397
+DROP DATABASE std_test;
diff --git a/mysql-test/suite/tianmu/r/union_case.result b/mysql-test/suite/tianmu/r/union_case.result
new file mode 100644
index 000000000..1526d2c5d
--- /dev/null
+++ b/mysql-test/suite/tianmu/r/union_case.result
@@ -0,0 +1,55 @@
+# MCOL-641 Union Test Cases
+# Once MCOL-5417 is supported, the errored out queries below should be fixed.
+DROP DATABASE IF EXISTS union_case_test;
+CREATE DATABASE union_case_test;
+USE union_case_test;
+SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+Warnings:
+Warning 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
+CREATE TABLE cs1 (d1 DECIMAL(17), d2 DECIMAL(17,10), d3 DECIMAL(17,17)) ;
+CREATE TABLE cs2 (d1 DECIMAL(17) UNSIGNED, d2 DECIMAL(17,10) UNSIGNED, d3 DECIMAL(17,17) UNSIGNED) ;
+INSERT INTO cs1 VALUES (125, 1.25, 0.125);
+INSERT INTO cs1 VALUES (-125, -1.25, -0.125);
+INSERT INTO cs1 values (9999999999999998, 9999999.9999999998, 0.9999999999999998);
+INSERT INTO cs1 values (99999999999999999, 9999999.9999999999, 0.99999999999999999);
+INSERT INTO cs1 values (-9999999999999998, -9999999.9999999998, -0.9999999999999998);
+INSERT INTO cs1 values (-99999999999999999, -9999999.9999999999, -0.99999999999999999);
+CREATE TABLE cs3 (d1 int, d2 int, d3 int) ;
+INSERT INTO cs3 VALUES (12, 16, 56);
+INSERT INTO cs3 VALUES (7, 6, 45);
+INSERT INTO cs3 VALUES (0, 0, 0);
+SELECT d1, d1, d2 FROM cs3 UNION SELECT d2, d3, d3 FROM cs3;
+d1 d1 d2
+12 12 16
+7 7 6
+0 0 0
+16 56 56
+6 45 45
+INSERT INTO cs2 VALUES (125, 1.25, 0.125);
+INSERT INTO cs2 values (9999999999999998, 9999999.9999999998, 0.9999999999999998);
+INSERT INTO cs2 values (99999999999999999, 9999999.9999999999, 0.99999999999999999);
+DROP TABLE cs1, cs2;
+CREATE TABLE cs1 (d1 DECIMAL(17, 0), d2 DECIMAL(17, 14), d3 DECIMAL(17, 14)) ;
+CREATE TABLE cs2 (d1 DECIMAL(17, 0) UNSIGNED, d2 DECIMAL(17, 14) UNSIGNED, d3 DECIMAL(17, 14) UNSIGNED) ;
+INSERT INTO cs1 VALUES (12345678901234567, 12.34567890123456, 0.1234567890123456);
+Warnings:
+Note 1265 Data truncated for column 'd3' at row 1
+INSERT INTO cs1 VALUES (-12345678901234567, -12.34567890123456, -0.1234567890123456);
+Warnings:
+Note 1265 Data truncated for column 'd3' at row 1
+INSERT INTO cs1 VALUES (99999999999999999, 99.999999999999999, 0.999999999999999);
+Warnings:
+Note 1265 Data truncated for column 'd2' at row 1
+Note 1265 Data truncated for column 'd3' at row 1
+INSERT INTO cs1 VALUES (-99999999999999999, -99.999999999999999, -0.999999999999999);
+Warnings:
+Note 1265 Data truncated for column 'd2' at row 1
+Note 1265 Data truncated for column 'd3' at row 1
+INSERT INTO cs2 VALUES (12345678901234567, 12.34567890123456, 0.1234567890123456);
+Warnings:
+Note 1265 Data truncated for column 'd3' at row 1
+INSERT INTO cs2 VALUES (99999999999999999, 99.999999999999999, 0.999999999999999);
+Warnings:
+Note 1265 Data truncated for column 'd2' at row 1
+Note 1265 Data truncated for column 'd3' at row 1
+DROP DATABASE union_case_test;
diff --git a/mysql-test/suite/tianmu/r/unsigned_support_issue1267.result b/mysql-test/suite/tianmu/r/unsigned_support_issue1267.result
index 9f7062c0e..cd921e885 100644
--- a/mysql-test/suite/tianmu/r/unsigned_support_issue1267.result
+++ b/mysql-test/suite/tianmu/r/unsigned_support_issue1267.result
@@ -425,7 +425,7 @@ ut us um ui
255 65535 16777215 4294967295
select * into outfile "MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt" from load_unsigned;
truncate table load_unsigned;
-LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt' INTO TABLE load_unsigned FIELDS TERMINATED BY ';';
+LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt' INTO TABLE load_unsigned;
select * from load_unsigned;
ut us um ui
0 0 0 0
diff --git a/mysql-test/suite/tianmu/r/various_join.result b/mysql-test/suite/tianmu/r/various_join.result
index a254d9fce..170556d0a 100644
--- a/mysql-test/suite/tianmu/r/various_join.result
+++ b/mysql-test/suite/tianmu/r/various_join.result
@@ -22,27 +22,27 @@ insert into t6 values (1, 2), (3, 4);
insert into t7 values (1, 3);
insert into t8 values (1, 3);
insert into t9 values (1, 2);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) order by t3.a;
a b a b a b
1 3 1 2 1 2
+NULL NULL NULL NULL 2 3
NULL NULL NULL NULL 3 4
NULL NULL NULL NULL 4 5
-NULL NULL NULL NULL 2 3
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a) order by t4.a;
a b a b a b a b
-1 3 1 2 1 2 1 3
NULL NULL NULL NULL 3 4 NULL NULL
NULL NULL NULL NULL 4 5 NULL NULL
NULL NULL NULL NULL 2 3 NULL NULL
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a = 1 or t3.a = 3);
+1 3 1 2 1 2 1 3
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a = 1 or t3.a = 3) order by t3.a;
a b a b a b
1 3 1 2 1 2
NULL NULL NULL NULL 3 4
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a > 1);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a > 1) order by t3.a;
a b a b a b
+NULL NULL NULL NULL 2 3
NULL NULL NULL NULL 3 4
NULL NULL NULL NULL 4 5
-NULL NULL NULL NULL 2 3
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t2.a = t3.a) left join t4 on (t3.a = t4.a and t1.b = t4.b) order by t3.a;
a b a b a b a b
1 3 1 2 1 2 1 3
@@ -55,24 +55,24 @@ a b a b a b a b
2 3 2 4 2 3 NULL NULL
NULL NULL NULL NULL 3 4 NULL NULL
NULL NULL NULL NULL 4 5 NULL NULL
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t1.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t1.a) order by t3.a;
a b a b a b
-NULL NULL NULL NULL 3 4
-NULL NULL NULL NULL 4 5
NULL NULL NULL NULL 1 2
NULL NULL NULL NULL 2 3
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t2.a and t3.a > t1.a);
-a b a b a b
NULL NULL NULL NULL 3 4
NULL NULL NULL NULL 4 5
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t2.a and t3.a > t1.a) order by t3.a;
+a b a b a b
NULL NULL NULL NULL 1 2
NULL NULL NULL NULL 2 3
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.b > t2.a and t3.a < t1.b);
+NULL NULL NULL NULL 3 4
+NULL NULL NULL NULL 4 5
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.b > t2.a and t3.a < t1.b) order by t3.a;
a b a b a b
1 3 1 2 1 2
+NULL NULL NULL NULL 2 3
NULL NULL NULL NULL 3 4
NULL NULL NULL NULL 4 5
-NULL NULL NULL NULL 2 3
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) order by t3.a;
a b a b a b a b
1 3 1 2 1 2 1 3
@@ -82,26 +82,26 @@ NULL NULL NULL NULL 4 5 NULL NULL
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) right join t4 on (t3.a = t4.a and t2.a = t4.a) order by t3.a;
a b a b a b a b
1 3 1 2 1 2 1 3
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) left join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) left join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a) order by t3.a;
a b a b a b a b
1 3 1 2 1 2 1 3
2 3 2 4 2 3 NULL NULL
NULL NULL NULL NULL 3 4 NULL NULL
NULL NULL NULL NULL 4 5 NULL NULL
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) right join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) right join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a) order by t4.a;
a b a b a b a b
1 3 1 2 1 2 1 3
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) left join t5 on (t4.a = t5.a and t3.b = t5.b);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) left join t5 on (t4.a = t5.a and t3.b = t5.b) order by t5.a;
a b a b a b a b a b
-1 3 1 2 1 2 1 3 1 2
NULL NULL NULL NULL 3 4 NULL NULL NULL NULL
NULL NULL NULL NULL 4 5 NULL NULL NULL NULL
NULL NULL NULL NULL 2 3 NULL NULL NULL NULL
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b);
+1 3 1 2 1 2 1 3 1 2
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) order by t5.a;
a b a b a b a b a b
1 3 1 2 1 2 1 3 1 2
NULL NULL NULL NULL NULL NULL NULL NULL 3 4
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) right join t6 on (t5.a = t6.a and t4.a = t6.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) right join t6 on (t5.a = t6.a and t4.a = t6.a) order by t6.a;
a b a b a b a b a b a b
1 3 1 2 1 2 1 3 1 2 1 2
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 3 4
diff --git a/mysql-test/suite/tianmu/std_data/issue1865.dat b/mysql-test/suite/tianmu/std_data/issue1865.dat
new file mode 100644
index 000000000..a70a059c2
--- /dev/null
+++ b/mysql-test/suite/tianmu/std_data/issue1865.dat
@@ -0,0 +1,2 @@
+\N 10
+\N 15
diff --git a/mysql-test/suite/tianmu/std_data/tinyint_range.tbl b/mysql-test/suite/tianmu/std_data/tinyint_range.tbl
new file mode 100644
index 000000000..68653bee0
--- /dev/null
+++ b/mysql-test/suite/tianmu/std_data/tinyint_range.tbl
@@ -0,0 +1,254 @@
+-126|0
+-125|1
+-124|2
+-123|3
+-122|4
+-121|5
+-120|6
+-119|7
+-118|8
+-117|9
+-116|10
+-115|11
+-114|12
+-113|13
+-112|14
+-111|15
+-110|16
+-109|17
+-108|18
+-107|19
+-106|20
+-105|21
+-104|22
+-103|23
+-102|24
+-101|25
+-100|26
+-99|27
+-98|28
+-97|29
+-96|30
+-95|31
+-94|32
+-93|33
+-92|34
+-91|35
+-90|36
+-89|37
+-88|38
+-87|39
+-86|40
+-85|41
+-84|42
+-83|43
+-82|44
+-81|45
+-80|46
+-79|47
+-78|48
+-77|49
+-76|50
+-75|51
+-74|52
+-73|53
+-72|54
+-71|55
+-70|56
+-69|57
+-68|58
+-67|59
+-66|60
+-65|61
+-64|62
+-63|63
+-62|64
+-61|65
+-60|66
+-59|67
+-58|68
+-57|69
+-56|70
+-55|71
+-54|72
+-53|73
+-52|74
+-51|75
+-50|76
+-49|77
+-48|78
+-47|79
+-46|80
+-45|81
+-44|82
+-43|83
+-42|84
+-41|85
+-40|86
+-39|87
+-38|88
+-37|89
+-36|90
+-35|91
+-34|92
+-33|93
+-32|94
+-31|95
+-30|96
+-29|97
+-28|98
+-27|99
+-26|100
+-25|101
+-24|102
+-23|103
+-22|104
+-21|105
+-20|106
+-19|107
+-18|108
+-17|109
+-16|110
+-15|111
+-14|112
+-13|113
+-12|114
+-11|115
+-10|116
+-9|117
+-8|118
+-7|119
+-6|120
+-5|121
+-4|122
+-3|123
+-2|124
+-1|125
+0|126
+1|127
+2|128
+3|129
+4|130
+5|131
+6|132
+7|133
+8|134
+9|135
+10|136
+11|137
+12|138
+13|139
+14|140
+15|141
+16|142
+17|143
+18|144
+19|145
+20|146
+21|147
+22|148
+23|149
+24|150
+25|151
+26|152
+27|153
+28|154
+29|155
+30|156
+31|157
+32|158
+33|159
+34|160
+35|161
+36|162
+37|163
+38|164
+39|165
+40|166
+41|167
+42|168
+43|169
+44|170
+45|171
+46|172
+47|173
+48|174
+49|175
+50|176
+51|177
+52|178
+53|179
+54|180
+55|181
+56|182
+57|183
+58|184
+59|185
+60|186
+61|187
+62|188
+63|189
+64|190
+65|191
+66|192
+67|193
+68|194
+69|195
+70|196
+71|197
+72|198
+73|199
+74|200
+75|201
+76|202
+77|203
+78|204
+79|205
+80|206
+81|207
+82|208
+83|209
+84|210
+85|211
+86|212
+87|213
+88|214
+89|215
+90|216
+91|217
+92|218
+93|219
+94|220
+95|221
+96|222
+97|223
+98|224
+99|225
+100|226
+101|227
+102|228
+103|229
+104|230
+105|231
+106|232
+107|233
+108|234
+109|235
+110|236
+111|237
+112|238
+113|239
+114|240
+115|241
+116|242
+117|243
+118|244
+119|245
+120|246
+121|247
+122|248
+123|249
+124|250
+125|251
+126|252
+127|253
diff --git a/mysql-test/suite/tianmu/t/alter_table1.test b/mysql-test/suite/tianmu/t/alter_table1.test
index d5bea703f..17bfd8f29 100644
--- a/mysql-test/suite/tianmu/t/alter_table1.test
+++ b/mysql-test/suite/tianmu/t/alter_table1.test
@@ -18,7 +18,7 @@ CREATE TABLE st1
name VARCHAR(25),
deptId INT(11),
salary FLOAT
-);
+) engine=tianmu;
alter table st1 add column test varchar(4);
alter table st1 add column test1 varchar(4) after test;
@@ -48,7 +48,7 @@ CREATE TABLE st2
name VARCHAR(25),
deptId INT(11),
salary FLOAT
-);
+) engine=tianmu;
insert into st2 values(3,'haha1',45,4.5);
insert into st2 values(1,'haha2',12,1.2);
@@ -72,7 +72,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
ALTER TABLE st3 RENAME to st4 ;
ALTER TABLE st4 RENAME as st3 ;
@@ -95,7 +95,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
alter table st5 modify name varchar(20);
alter table st5 modify column name varchar(24);
@@ -112,7 +112,7 @@ name VARCHAR(25),
deptId INT(11),
salary FLOAT,
PRIMARY KEY(id)
-);
+) engine=tianmu;
alter table st6 rename to st7,add name1 varchar(10);
desc st7;
@@ -130,4 +130,9 @@ alter table st8 add name3 varchar(10),modify name varchar(20);
desc st8;
# clean up
+DROP TABLE st8;
+DROP TABLE st5;
+DROP TABLE st4;
+DROP TABLE st2;
+DROP TABLE st1;
drop database alter_table1_test;
diff --git a/mysql-test/suite/tianmu/t/auto_increment.testbak b/mysql-test/suite/tianmu/t/auto_increment.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/auto_increment.testbak
rename to mysql-test/suite/tianmu/t/auto_increment.test
diff --git a/mysql-test/suite/tianmu/t/bigint_unsigned.test b/mysql-test/suite/tianmu/t/bigint_unsigned.test
new file mode 100644
index 000000000..3b8581545
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/bigint_unsigned.test
@@ -0,0 +1,229 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # Test bigint unsigned
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS bigint_unsigned_test;
+--enable_warnings
+
+CREATE DATABASE bigint_unsigned_test;
+USE bigint_unsigned_test;
+
+# Test of reading of bigint values
+
+select 0,256,00000000000000065536,2147483647,-2147483648,2147483648,+4294967296;
+select 9223372036854775807,-009223372036854775808;
+select +9999999999999999999,-9999999999999999999;
+select cast(9223372036854775808 as unsigned)+1;
+select 9223372036854775808+1;
+select -(0-3),round(-(0-3)), round(9999999999999999999);
+select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001;
+select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001;
+select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16);
+
+# bigint test range[0, 9223372036854775807]
+
+create table t1 (a bigint unsigned not null, primary key(a));
+insert into t1 values (9223372036854775807), (0xFFFFFFFFFFFFFF), (9223372036854775806), (9223372036854775805);
+select * from t1 order by 1;
+select * from t1 where a=9223372036854775807;
+select * from t1 where a='9223372036854775807';
+delete from t1 where a=9223372036854775807;
+select * from t1 order by 1;
+drop table t1;
+
+create table t1 ( a int not null default 1, big bigint );
+insert into t1 (big) values (-1),(12345678901234567),(9223372036854775807),(9223372036854775805);
+select * from t1;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
+--error 1264
+alter table t1 modify big bigint unsigned not null;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
+insert into t1 (big) values (9223372036854775807);
+select * from t1;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
+alter table t1 modify big bigint not null;
+select * from t1;
+select min(big),max(big),max(big)-1 from t1;
+select min(big),max(big),max(big)-1 from t1 group by a;
+drop table t1;
+
+# Test problem with big values for auto_increment
+
+create table t1 (id bigint auto_increment primary key, a int) auto_increment=9999999999;
+insert into t1 values (null,1);
+select * from t1;
+select * from t1 limit 9999999999;
+drop table t1;
+
+# precisions for bigints
+
+CREATE TABLE t1 (quantity decimal(18,0));
+insert into t1 values (100000000000000);
+insert into t1 values (10000000000000.0);
+insert into t1 values ('10000000000000');
+select * from t1;
+drop table t1;
+
+SELECT '0x8000000000000001'+0;
+
+# Test for join BIGINT UNSIGNED
+
+create table t1 (
+ value64 bigint unsigned not null,
+ value32 integer not null,
+ primary key(value64, value32)
+);
+
+create table t2 (
+ value64 bigint unsigned not null,
+ value32 integer not null,
+ primary key(value64, value32)
+);
+
+insert into t1 values(9223372036854775806, 1);
+insert into t1 values(9223372036854775807, 2);
+insert into t2 values(9223372036854775806, 3);
+insert into t2 values(9223372036854775807, 4);
+
+select * from t1;
+select * from t2;
+select * from t1, t2 where t1.value64=9223372036854775806 and t2.value64=9223372036854775806;
+select * from t1, t2 where t1.value64=9223372036854775806 and t2.value64=t1.value64;
+select * from t1, t2 where t1.value64= 9223372036854775807 and t2.value64=9223372036854775807;
+select * from t1, t2 where t1.value64= 9223372036854775807 and t2.value64=t1.value64;
+drop table t1, t2;
+
+# Test bigint
+
+create table t1 (sint64 bigint not null);
+insert into t1 values (-9223372036854775806);
+select * from t1;
+drop table t1;
+
+create table t1 (a char(100), b varchar(100), c text, d blob);
+insert into t1 values(
+ 18446744073709551615,18446744073709551615,
+ 18446744073709551615, 18446744073709551615
+);
+insert into t1 values (-1 | 0,-1 | 0,-1 | 0 ,-1 | 0);
+select * from t1;
+drop table t1;
+
+create table t1 (quantity decimal(2) unsigned);
+insert into t1 values (50), (0), (1);
+select * from t1;
+drop table t1;
+
+#mod is signed with bigint
+
+select cast(9223372036854775807 as unsigned) mod 50 as result;
+create table t1 (c1 bigint unsigned);
+insert into t1 values (9223372036854775807);
+select c1 mod 50 as result from t1;
+drop table t1;
+
+#use bigint unsigned as input to cast
+
+select cast(19999999999999999999 as signed);
+select cast(-19999999999999999999 as signed);
+
+select -9223372036854775808;
+select -(9223372036854775808);
+select -((9223372036854775808));
+select -(-(9223372036854775808));
+select --9223372036854775808, ---9223372036854775808, ----9223372036854775808;
+select -(-9223372036854775808), -(-(-9223372036854775808));
+
+CREATE TABLE t1 (id INT AUTO_INCREMENT PRIMARY KEY,
+ a BIGINT(20) UNSIGNED,
+ b VARCHAR(20));
+INSERT INTO t1 (a) VALUES
+ (0),
+ (CAST(0x7FFFFFFFFFFFFFF AS UNSIGNED)),
+ (CAST(0x800000000000000 AS UNSIGNED)),
+ (CAST(0xFFFFFFFFFFFFFFF AS UNSIGNED));
+UPDATE t1 SET b = a;
+select * from t1;
+DROP TABLE t1;
+
+# DECIMAL COMPARISON
+
+CREATE TABLE t_bigint(id BIGINT);
+INSERT INTO t_bigint VALUES (1), (2);
+
+SELECT id, id >= 1.1 FROM t_bigint;
+SELECT id, 1.1 <= id FROM t_bigint;
+
+SELECT id, id = 1.1 FROM t_bigint;
+SELECT id, 1.1 = id FROM t_bigint;
+
+SELECT * from t_bigint WHERE id = 1.1;
+SELECT * from t_bigint WHERE id = 1.1e0;
+#bug1346 SELECT * from t_bigint WHERE id = '1.1';
+#bug1346 SELECT * from t_bigint WHERE id = '1.1e0';
+SELECT * from t_bigint WHERE id IN (1.1, 2.2);
+SELECT * from t_bigint WHERE id IN (1.1e0, 2.2e0);
+#bug1346 SELECT * from t_bigint WHERE id IN ('1.1', '2.2');
+#bug1346 SELECT * from t_bigint WHERE id IN ('1.1e0', '2.2e0');
+SELECT * from t_bigint WHERE id BETWEEN 1.1 AND 1.9;
+SELECT * from t_bigint WHERE id BETWEEN 1.1e0 AND 1.9e0;
+#bug1346 SELECT * from t_bigint WHERE id BETWEEN '1.1' AND '1.9';
+#bug1346 SELECT * from t_bigint WHERE id BETWEEN '1.1e0' AND '1.9e0';
+DROP TABLE t_bigint;
+
+CREATE TABLE t1 (a BIGINT);
+INSERT INTO t1 VALUES (1);
+SELECT * FROM t1 WHERE coalesce(a) BETWEEN 0 and 0.9;
+SELECT * FROM t1 WHERE coalesce(a)=0.9;
+SELECT * FROM t1 WHERE coalesce(a) in (0.8,0.9);
+SELECT * FROM t1 WHERE a BETWEEN 0 AND 0.9;
+SELECT * FROM t1 WHERE a=0.9;
+SELECT * FROM t1 WHERE a IN (0.8,0.9);
+DROP TABLE t1;
+
+# between...and againest bigint unsigned
+
+create table t (id bigint unsigned, b int);
+insert into t values(7223372036854775807,1);
+insert into t values(7223372036854775806,2);
+insert into t values(9223372036854775805,3);
+select count(*) from t
+where id>=7223372036854775806 and id <=9223372036854775807;
+select count(*) from t
+where id between 7223372036854775806 and 9223372036854775807;
+alter table t add primary key (id);
+select count(*) from t
+where id>=7223372036854775806 and id <=9223372036854775807;
+select count(*) from t
+where id between 7223372036854775806 and 9223372036854775807;
+drop table t;
+
+SELECT (184467440737095 BETWEEN 0 AND 18446744073709551500);
+SELECT 184467440737095 >= 0;
+SELECT 0 <= 18446744073709551500;
+
+#select cast(100 as unsigned) between 1 and -1 returns true
+
+SELECT CAST(100 AS UNSIGNED) BETWEEN 1 AND -1;
+SELECT CAST(100 AS UNSIGNED) NOT BETWEEN 1 AND -1;
+SELECT CAST(0 AS UNSIGNED) BETWEEN 0 AND -1;
+SELECT CAST(0 AS UNSIGNED) NOT BETWEEN 0 AND -1;
+
+select -9223372036854775808 mod 9223372036854775810 as result;
+select bin(convert(-9223372036854775808 using ucs2));
+SELECT ( 9223372036854775808 BETWEEN 9223372036854775808 AND 9223372036854775808 );
+SELECT ( 9223372036854775807 BETWEEN 9223372036854775808 AND 1 );
+SELECT ( -1 BETWEEN 9223372036854775808 AND 1 );
+SELECT ( 0 BETWEEN 9223372036854775808 AND 1 );
+SELECT ( 1 BETWEEN 9223372036854775808 AND 1 );
+
+# cleanup
+drop DATABASE bigint_unsigned_test;
diff --git a/mysql-test/suite/tianmu/t/case_when.test b/mysql-test/suite/tianmu/t/case_when.test
new file mode 100644
index 000000000..212ddbeeb
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/case_when.test
@@ -0,0 +1,163 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # test case when
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS case_when_test;
+--enable_warnings
+
+CREATE DATABASE case_when_test;
+USE case_when_test;
+
+--disable_warnings
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+--enable_warnings
+
+select CASE "b" when "a" then 1 when "b" then 2 END;
+select CASE "c" when "a" then 1 when "b" then 2 END;
+select CASE "c" when "a" then 1 when "b" then 2 ELSE 3 END;
+select CASE BINARY "b" when "a" then 1 when "B" then 2 WHEN "b" then "ok" END;
+select CASE "b" when "a" then 1 when binary "B" then 2 WHEN "b" then "ok" END;
+select CASE concat("a","b") when concat("ab","") then "a" when "b" then "b" end;
+select CASE when 1=0 then "true" else "false" END;
+select CASE 1 when 1 then "one" WHEN 2 then "two" ELSE "more" END;
+select CASE 2.0 when 1 then "one" WHEN 2.0 then "two" ELSE "more" END;
+select (CASE "two" when "one" then "1" WHEN "two" then "2" END) | 0;
+select (CASE "two" when "one" then 1.00 WHEN "two" then 2.00 END) +0.0;
+select case 1/0 when "a" then "true" else "false" END;
+select case 1/0 when "a" then "true" END;
+select (case 1/0 when "a" then "true" END) | 0;
+select (case 1/0 when "a" then "true" END) + 0.0;
+select case when 1>0 then "TRUE" else "FALSE" END;
+select case when 1<0 then "TRUE" else "FALSE" END;
+
+#
+# using GROUP BY on CASE
+#
+create table t1 (a int);
+insert into t1 values(1),(2),(3),(4);
+select case a when 1 then 2 when 2 then 3 else 0 end as fcase, count(*) from t1 group by fcase order by fcase;
+select case a when 1 then "one" when 2 then "two" else "nothing" end as fcase, count(*) from t1 group by fcase order by fcase;
+drop table t1;
+
+#
+# Test MAX(CASE ... ) that can return null
+#
+
+create table t1 (row int not null, col int not null, val varchar(255) not null);
+insert into t1 values (1,1,'orange'),(1,2,'large'),(2,1,'yellow'),(2,2,'medium'),(3,1,'green'),(3,2,'small');
+select max(case col when 1 then val else null end) as color from t1 group by row;
+drop table t1;
+
+SET NAMES latin1;
+
+#
+# CASE and argument types/collations aggregation into result
+#
+CREATE TABLE t1 SELECT
+ CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' END AS c1,
+ CASE WHEN 1 THEN _latin1'a' ELSE _latin1'a' COLLATE latin1_danish_ci END AS c2,
+ CASE WHEN 1 THEN 'a' ELSE 1 END AS c3,
+ CASE WHEN 1 THEN 1 ELSE 'a' END AS c4,
+ CASE WHEN 1 THEN 'a' ELSE 1.0 END AS c5,
+ CASE WHEN 1 THEN 1.0 ELSE 'a' END AS c6,
+ CASE WHEN 1 THEN 1 ELSE 1.0 END AS c7,
+ CASE WHEN 1 THEN 1.0 ELSE 1 END AS c8,
+ CASE WHEN 1 THEN 1.0 END AS c9,
+ CASE WHEN 1 THEN 0.1e1 else 0.1 END AS c10,
+ CASE WHEN 1 THEN 0.1e1 else 1 END AS c11,
+ CASE WHEN 1 THEN 0.1e1 else '1' END AS c12
+;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--error 1267
+SELECT CASE
+ WHEN 1
+ THEN _latin1'a' COLLATE latin1_danish_ci
+ ELSE _latin1'a' COLLATE latin1_swedish_ci
+ END;
+
+--error 1270
+SELECT CASE _latin1'a' COLLATE latin1_general_ci
+ WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1
+ WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2
+ END;
+
+SELECT
+CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' COLLATE latin1_bin WHEN _latin1'A' THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_swedish_ci THEN '1' ELSE 2 END,
+CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END;
+
+--error 1267
+CREATE TABLE t1 SELECT IFNULL('a' COLLATE latin1_swedish_ci, 'b' COLLATE latin1_bin);
+
+SELECT 'case+union+test'
+UNION
+SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
+
+SELECT CASE LOWER('1') WHEN LOWER('2') THEN 'BUG' ELSE 'nobug' END;
+
+SELECT 'case+union+test'
+UNION
+SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END;
+
+#
+# problem with MIN(CASE...)
+#
+
+create table t1(a float, b int default 3);
+insert into t1 (a) values (2), (11), (8);
+select min(a), min(case when 1=1 then a else NULL end),
+ min(case when 1!=1 then NULL else a end)
+from t1 where b=3 group by b;
+drop table t1;
+
+
+#
+# conversion of the arguments for COALESCE and IFNULL
+#
+
+CREATE TABLE t1 (EMPNUM INT);
+INSERT INTO t1 VALUES (0), (2);
+CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
+INSERT INTO t2 VALUES (0.0), (9.0);
+
+SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
+ t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
+ FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
+
+SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
+ t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
+ FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
+
+DROP TABLE t1,t2;
+
+#
+# Truncated UNSIGNED BIGINT columns
+#
+create table t1 (a int, b bigint unsigned);
+create table t2 (c int);
+insert into t1 (a, b) values (1,457279462277), (2,1819694241997),
+ (3,1114190595086);
+insert into t2 (c) values (1), (2), (3);
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+ join t2 on t1.a=t2.c order by d;
+select t1.a, (case t1.a when 0 then 0 else t1.b end) d from t1
+ join t2 on t1.a=t2.c where b=1114190595086 order by d;
+drop table t1, t2;
+
+#
+# CRASH IN ITEM_FUNC_CASE::FIND_ITEM WITH CASE WHEN
+# ELSE CLAUSE
+#
+
+CREATE TABLE t1(a YEAR);
+SELECT 1 FROM t1 WHERE a=1 AND CASE 1 WHEN a THEN 1 ELSE 1 END;
+DROP TABLE t1;
+
+#clean up
+drop database case_when_test;
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/create_tmp.test b/mysql-test/suite/tianmu/t/create_tmp.test
new file mode 100644
index 000000000..e214ef7b7
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/create_tmp.test
@@ -0,0 +1,107 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # Test create temporary
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS create_tmp_test;
+--enable_warnings
+
+CREATE DATABASE create_tmp_test;
+USE create_tmp_test;
+
+CREATE TEMPORARY TABLE st (
+ id INT(11),
+ name VARCHAR(255)
+);
+
+INSERT INTO st (id, name) VALUES (1, 'John');
+INSERT INTO st (id, name) VALUES (2, 'Jane');
+SELECT * FROM st;
+UPDATE st SET name = 'Johnny' WHERE id = 1;
+SELECT * FROM st;
+DELETE FROM st WHERE id = 2;
+SELECT * FROM st;
+
+CREATE TEMPORARY TABLE st1 (
+ id INT(11),
+ name VARCHAR(255)
+);
+
+CREATE TEMPORARY TABLE st2 (
+ id INT(11),
+ city VARCHAR(255)
+);
+
+INSERT INTO st1 (id, name) VALUES (1, 'John');
+INSERT INTO st1 (id, name) VALUES (2, 'Jane');
+INSERT INTO st2 (id, city) VALUES (1, 'London');
+INSERT INTO st2 (id, city) VALUES (2, 'New York');
+SELECT st1.name, st2.city
+FROM st1 INNER JOIN st2 ON st1.id=st2.id;
+
+create table t2 (id int(11) auto_increment primary key, score int(11), name varchar(32)) ;
+insert into t2 (score, name) values (98, 'Bob');
+select * from t2 where score > 90;
+
+create temporary table t3 like t2 ;
+insert into t3 (score, name) values (88, 'Charlie');
+select * from t3;
+
+# data type
+create table t5 (
+ id int(11) unsigned auto_increment primary key,
+ col1 varchar(32),
+ col2 datetime,
+ col3 time
+) ;
+
+insert into t5 (col1, col2, col3) values ('aaa', '2022-01-17 15:22:00', '12:00:00');
+insert into t5 (col1, col2, col3) values ('bbb', '2022-01-18 10:10:10', '20:00:00');
+insert into t5 (col1, col2, col3) values ('ccc', '2022-01-19 15:45:32', '18:45:00');
+select * from t5 where col1 = 'aaa';
+
+# create temporary table like
+create temporary table temp_t6 like t5 ;
+insert into temp_t6 (col1, col2, col3) select col1, col2, col3 from t5 where col1 between 'aaa' and 'bbb';
+select * from temp_t6 order by col2 desc;
+drop temporary table if exists temp_t7;
+
+# unsigned type
+create temporary table temp_t7(
+ id int(11)unsigned auto_increment primary key,
+ col1 varchar(32)
+);
+insert into temp_t7(col1)values('apple'),('banana'),('orange'),('watermelon'),('grapefruit');
+select * from temp_t7 order by id desc;
+
+create temporary table temp_t8(id int(11) unsigned auto_increment primary key, col1 varchar(32), col2 datetime, status char(1)) ;
+insert into temp_t8(col1,col2,status)values('aaa','2022-02-19 09:21:40','Y'),('bbb','2022-02-20 14:15:23','N'),('ccc','2022-02-21 22:30:10','Y'),('ddd','2022-02-22 08:50:20','N'),('eee','2022-02-23 10:35:59','Y');
+select * from temp_t8;
+
+create temporary table temp_t9(id int(11) unsigned auto_increment primary key, col3 varchar(32), col4 int(11),price decimal(8,2));
+insert into temp_t9(col3, col4, price) values('code11', 10, 523.2),('code22', 20 , 2480),('code33', 30, 89.99),('code44', 40, 5200.55);
+select * from temp_t9;
+
+CREATE TEMPORARY TABLE temp_t10 SELECT * FROM temp_t9 LIMIT 3;
+select * from temp_t10;
+
+# decimal type
+drop table if exists t1,t2,t3;
+CREATE TEMPORARY TABLE t1 (c1 DECIMAL(10,2));
+INSERT INTO t1 VALUES (10.00), (-24.53), (5936.28);
+
+CREATE TEMPORARY TABLE t2 (c1 DECIMAL(38,10));
+INSERT INTO t2 VALUES (1.23), (-2.78), (99.99);
+
+CREATE TEMPORARY TABLE t3 (c1 DECIMAL(12,5), c2 DECIMAL(20,8));
+INSERT INTO t3 VALUES (123.45678, 450.04510000), (-234.54628, 2434.87654865);
+
+SELECT *, LENGTH(c1) FROM t1;
+SELECT *, LENGTH(c1) FROM t2;
+SELECT *, LENGTH(c1), LENGTH(c2) FROM t3;
+DROP TEMPORARY TABLE t1, t2, t3;
+
+# clean UP
+DROP DATABASE create_tmp_test;
diff --git a/mysql-test/suite/tianmu/t/date_formats.test b/mysql-test/suite/tianmu/t/date_formats.test
new file mode 100644
index 000000000..56a85f879
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/date_formats.test
@@ -0,0 +1,172 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # Test of date format functions
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS date_formats_test;
+--enable_warnings
+
+CREATE DATABASE date_formats_test;
+USE date_formats_test;
+
+# Test of str_to_date
+
+# PS doesnot support fractions of a second
+select str_to_date(concat('15-01-2001',' 2:59:58.999'),
+ concat('%d-%m-%Y',' ','%H:%i:%s.%f'));
+select STR_TO_DATE('2004.12.12 22.30.61','%Y.%m.%d %T');
+
+SET sql_mode = 'STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+create table t1 (date char(30), format char(30) not null);
+insert into t1 values
+('2003-01-02 10:11:12', '%Y-%m-%d %H:%i:%S'),
+('03-01-02 8:11:2.123456', '%y-%m-%d %H:%i:%S.%#'),
+#bug1495('0003-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('03-01-02 8:11:2.123456', '%Y-%m-%d %H:%i:%S.%#'),
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p'),
+#bug1495('2003-01-02 01:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f%p'),
+#bug1495('2003-01-02 02:11:12.12345AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+#bug1495('2003-01-02 12:11:12.12345 am', '%Y-%m-%d %h:%i:%S.%f%p'),
+('2003-01-02 11:11:12Pm', '%Y-%m-%d %h:%i:%S%p'),
+('10:20:10', '%H:%i:%s'),
+('10:20:10', '%h:%i:%s.%f'),
+('10:20:10', '%T'),
+('10:20:10AM', '%h:%i:%s%p'),
+('10:20:10AM', '%r'),
+#bug1495('10:20:10.44AM', '%h:%i:%s.%f%p'),
+('15-01-2001 12:59:58', '%d-%m-%Y %H:%i:%S'),
+('15 September 2001', '%d %M %Y'),
+('15 SEPTEMB 2001', '%d %M %Y'),
+('15 MAY 2001', '%d %b %Y'),
+('15th May 2001', '%D %b %Y'),
+('Sunday 15 MAY 2001', '%W %d %b %Y'),
+('Sund 15 MAY 2001', '%W %d %b %Y'),
+('Tuesday 00 2002', '%W %U %Y'),
+('Thursday 53 1998', '%W %u %Y'),
+('Sunday 01 2001', '%W %v %x'),
+('Tuesday 52 2001', '%W %V %X'),
+('060 2004', '%j %Y'),
+('4 53 1998', '%w %u %Y'),
+('15-01-2001', '%d-%m-%Y %H:%i:%S'),
+('15-01-20', '%d-%m-%y'),
+('15-2001-1', '%d-%Y-%c');
+
+select date,format,str_to_date(date, format) as str_to_date from t1;
+# Use as a string
+select date,format,concat('',str_to_date(date, format)) as con from t1;
+# Use as datetime
+select date,format,cast(str_to_date(date, format) as datetime) as datetime from t1;
+select date,format,DATE(str_to_date(date, format)) as date2 from t1;
+select date,format,TIME(str_to_date(date, format)) as time from t1;
+select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1;
+# Test small bug in %f handling
+select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d'));
+
+# Test wrong dates or converion specifiers
+
+truncate table t1;
+insert into t1 values
+('2003-01-02 10:11:12 PM', '%Y-%m-%d %H:%i:%S %p'),
+('2003-01-02 10:11:12.123456', '%Y-%m-%d %h:%i:%S %p'),
+('2003-01-02 10:11:12AM', '%Y-%m-%d %h:%i:%S.%f %p'),
+('2003-01-02 10:11:12AN', '%Y-%m-%d %h:%i:%S%p'),
+('2003-01-02 10:11:12 PM', '%y-%m-%d %H:%i:%S %p'),
+('10:20:10AM', '%H:%i:%s%p'),
+('15 Septembei 2001', '%d %M %Y'),
+('15 Ju 2001', '%d %M %Y'),
+('Sund 15 MA', '%W %d %b %Y'),
+('Thursdai 12 1998', '%W %u %Y'),
+('Sunday 01 2001', '%W %v %X'),
+('Tuesday 52 2001', '%W %V %x'),
+('Tuesday 52 2001', '%W %V %Y'),
+('Tuesday 52 2001', '%W %u %x'),
+('7 53 1998', '%w %u %Y'),
+(NULL, get_format(DATE,'USA'));
+select date,format,str_to_date(date, format) as str_to_date from t1;
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+
+# Test 'maybe' date formats and 'strange but correct' results
+
+truncate table t1;
+insert into t1 values
+('10:20:10AM', '%h:%i:%s'),
+('2003-01-02 10:11:12', '%Y-%m-%d %h:%i:%S'),
+('03-01-02 10:11:12 PM', '%Y-%m-%d %h:%i:%S %p');
+
+select date,format,str_to_date(date, format) as str_to_date from t1;
+select date,format,concat(str_to_date(date, format),'') as con from t1;
+drop table t1;
+
+# Test of date_format()
+create table t1 (d date);
+insert into t1 values ('2004-07-14'),('2005-07-14');
+select date_format(d,"%d") from t1 order by 1;
+drop table t1;
+
+# PS doesnot support fractional seconds
+select str_to_date("2003-....01ABCD-02 10:11:12.0012", "%Y-%.%m%@-%d %H:%i:%S.%f") as a;
+
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+#bug1495create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
+#bug1495 str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2,
+#bug1495 str_to_date("2003-01-02", "%Y-%m-%d") as f3,
+#bug1495 str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5;
+#bug1495describe t1;
+#bug1495select * from t1;
+
+#bug1495create table t1 select "02 10" as a, "%d %H" as b;
+#bug1495select str_to_date(a,b) from t1;
+#bug1495create table t2 select str_to_date(a,b) from t1;
+#bug1495describe t2;
+select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f") as f1,
+ str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S") as f2,
+ str_to_date("2003-01-02", "%Y-%m-%d") as f3,
+ str_to_date("02 10:11:12", "%d %H:%i:%S.%f") as f4,
+ str_to_date("02 10:11:12", "%d %H:%i:%S") as f5,
+ str_to_date("02 10", "%d %f") as f6;
+select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1,
+ addtime("-01:01:01.01 GGG", "-23:59:59.1") as f2,
+ microsecond("1997-12-31 23:59:59.01XXXX") as f3;
+
+select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
+ str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
+
+create table t1 (f1 datetime);
+insert into t1 (f1) values ("2005-01-01");
+insert into t1 (f1) values ("2005-02-01");
+select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M");
+drop table t1;
+
+CREATE TABLE t1 (a varchar(10), PRIMARY KEY (a));
+CREATE TABLE t2 (a varchar(10), b date, PRIMARY KEY(a,b));
+CREATE TABLE t3 (a varchar(10), b TIME, PRIMARY KEY(a,b));
+INSERT INTO t1 VALUES ('test1');
+INSERT INTO t2 VALUES
+('test1','2016-12-13'),('test1','2016-12-14'),('test1','2016-12-15');
+INSERT INTO t3 VALUES
+('test1','11:13:14'), ('test1','12:13:14'), ('test1','10:13:14');
+
+SELECT *
+FROM t1 LEFT JOIN t2
+ ON t2.a = 'test1' AND t2.b = '20161213'
+WHERE t1.a = 'test1';
+
+SELECT *
+FROM t1 LEFT JOIN t2 IGNORE INDEX(PRIMARY)
+ ON t2.a = 'test1' AND t2.b = '20161213'
+WHERE t1.a = 'test1';
+
+SELECT b, b = '20161213',
+ CASE b WHEN '20161213' then 'found' ELSE 'not found' END FROM t2;
+SELECT b, b IN ('20161213'), b in ('20161213', 0) FROM t2;
+
+#Uses datatype TIME
+SELECT b, b = '121314',
+ CASE b WHEN '121314' then 'found' ELSE 'not found' END FROM t3 order by 1;
+SELECT b, b in ('121314'), b in ('121314', 0) FROM t3 order by 1;
+
+#clean UP
+drop database date_formats_test;
+
diff --git a/mysql-test/suite/tianmu/t/disabled.def b/mysql-test/suite/tianmu/t/disabled.def
new file mode 100644
index 000000000..2ecc5ee14
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/disabled.def
@@ -0,0 +1,19 @@
+ ##############################################################################
+ #
+ # List the test cases that are to be disabled temporarily.
+ #
+ # Separate the test case name and the comment with ':'.
+ #
+ # : BUG#
+ #
+ # Do not use any TAB characters for whitespace.
+ #
+ ##############################################################################
+ auto_increment : BUG_FOR_auto_increment 2023-4-7 ringsc
+ issue364 : bug_for_364 2023-4-7 ringsc
+ issue433 : bug_for_433 2023-4-7 ringsc
+ issue446 : bug_for_446 2023-4-7 ringsc
+ issue581 : bug_for_581 2023-4-7 ringsc
+ load : bug_for_load 2023-4-7 ringsc
+ trigger : bug_for_trigger 2023-4-7 ringsc
+ alter_table_primarykey : bug_for_alter_pk
diff --git a/mysql-test/suite/tianmu/t/double_float.test b/mysql-test/suite/tianmu/t/double_float.test
index 3687c3c46..d2b3fe9fd 100644
--- a/mysql-test/suite/tianmu/t/double_float.test
+++ b/mysql-test/suite/tianmu/t/double_float.test
@@ -13,8 +13,6 @@ USE `double_float`;
SET default_storage_engine=tianmu;
SELECT @@default_storage_engine;
-set autocommit=0;
-
CREATE TABLE test1 (dkey int);
INSERT INTO test1 VALUES (1), (2), (3);
SELECT test1.dkey FROM test1 ORDER BY test1.dkey;
@@ -28,19 +26,19 @@ INSERT INTO qatabledouble VALUES (1.993777023789432E+21);
INSERT INTO qatabledouble VALUES (1.797693134862315E+38);
INSERT INTO qatabledouble VALUES (-19937770237894323221);
INSERT INTO qatabledouble VALUES (17976931348623158);
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
INSERT INTO qatabledouble VALUES (null);
INSERT INTO qatabledouble VALUES (null);
INSERT INTO qatabledouble VALUES (null);
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
INSERT INTO qatablefloat VALUES (null);
INSERT INTO qatablefloat VALUES (null);
INSERT INTO qatablefloat VALUES (null);
-SELECT * FROM qatablefloat;
+SELECT * FROM qatablefloat order by col;
DELETE FROM qatabledouble WHERE col IS NULL;
-SELECT * FROM qatabledouble;
+SELECT * FROM qatabledouble order by col;
delete FROM qatablefloat WHERE col IS NULL;
-SELECT * FROM qatablefloat;
+SELECT * FROM qatablefloat order by col;
CREATE TABLE qatabledouble_v2 (col1 DOUBLE, col2 DOUBLE, col3 DOUBLE) ;
INSERT INTO qatabledouble_v2 VALUES (-0.50, -0.50, -0.50);
INSERT INTO qatabledouble_v2 VALUES (-0.49, -0.49, -0.49);
@@ -67,7 +65,7 @@ INSERT INTO qatabledouble_v2 VALUES (0.0,0.0,0.0);
INSERT INTO qatabledouble_v2 VALUES (.50,.50,.50);
INSERT INTO qatabledouble_v2 VALUES (.49,.49,.49);
INSERT INTO qatabledouble_v2 VALUES (.0,.0,.0);
-SELECT * FROM qatabledouble_v2;
+SELECT * FROM qatabledouble_v2 order by col1;
CREATE TABLE qatablefloat_v3 (col1 float, col2 float, col3 float) ;
INSERT INTO qatablefloat_v3 VALUES (-0.50, -0.50, -0.50);
INSERT INTO qatablefloat_v3 VALUES (-0.49, -0.49, -0.49);
@@ -94,6 +92,6 @@ INSERT INTO qatablefloat_v3 VALUES (0.0,0.0,0.0);
INSERT INTO qatablefloat_v3 VALUES (.50,.50,.50);
INSERT INTO qatablefloat_v3 VALUES (.49,.49,.49);
INSERT INTO qatablefloat_v3 VALUES (.0,.0,.0);
-SELECT * FROM qatablefloat_v3;
+SELECT * FROM qatablefloat_v3 order by col1;
DROP DATABASE `double_float`;
diff --git a/mysql-test/suite/tianmu/t/drop_index-master.opt b/mysql-test/suite/tianmu/t/drop_index-master.opt
index 4494579d7..4eb1b974d 100644
--- a/mysql-test/suite/tianmu/t/drop_index-master.opt
+++ b/mysql-test/suite/tianmu/t/drop_index-master.opt
@@ -1 +1,2 @@
---sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_KEY_ERROR
+--sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/drop_index.test b/mysql-test/suite/tianmu/t/drop_index.test
index 6ad7b74e3..57c656400 100644
--- a/mysql-test/suite/tianmu/t/drop_index.test
+++ b/mysql-test/suite/tianmu/t/drop_index.test
@@ -34,7 +34,7 @@ CREATE TABLE `t3` (
FULLTEXT KEY `idx_lastname` (`last_name`)
) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
-set session sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set session tianmu_no_key_error=OFF;
--error ER_TIANMU_NOT_SUPPORTED_UNIQUE_INDEX
drop index idx_id on t1;
diff --git a/mysql-test/suite/tianmu/t/drop_restric.test b/mysql-test/suite/tianmu/t/drop_restric.test
new file mode 100644
index 000000000..1e39e9e37
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/drop_restric.test
@@ -0,0 +1,30 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # DROP TABLE RESTRICT
+--echo # The RESTRICT clause limits the table to being dropped in the front end only.
+--echo # This could be useful when the table has been dropped on one user module,
+--echo # and needs to be synced to others.
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS drop_restric_test;
+--enable_warnings
+
+CREATE DATABASE drop_restric_test;
+USE drop_restric_test;
+
+CREATE TABLE t1 (id INT, name CHAR(25));
+INSERT INTO t1 VALUES (1, 'one'), (2, 'two'), (3, 'three'), (4, 'four'), (5, 'five');
+
+SELECT * FROM t1 ORDER BY id;
+SELECT COUNT(*) FROM t1;
+
+DROP TABLE IF EXISTS t1 RESTRICT;
+--error 1051
+DROP TABLE t1;
+
+# Clean up
+--disable_warnings
+DROP DATABASE IF EXISTS drop_restric_test;
+--enable_warnings
diff --git a/mysql-test/suite/tianmu/t/empty_string_not_null.test b/mysql-test/suite/tianmu/t/empty_string_not_null.test
new file mode 100644
index 000000000..844c010a3
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/empty_string_not_null.test
@@ -0,0 +1,71 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # tests updates that sets invalid range when we set value at max boundary that is less than max.
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS empty_string_not_null;
+CREATE DATABASE empty_string_not_null;
+USE empty_string_not_null;
+--enable_warnings
+
+CREATE TABLE t(s text);
+INSERT INTO t(s) VALUES (''), (NULL);
+
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+SELECT COUNT(*) FROM t WHERE s IS NOT NULL;
+
+SELECT * FROM t;
+
+DROP TABLE t;
+
+CREATE TABLE t(s text);
+# this will test different code path in writeengine.
+INSERT INTO t(s) VALUES ('');
+INSERT INTO t(s) VALUES (NULL);
+
+SELECT * FROM t;
+
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+
+DROP TABLE t;
+
+CREATE TABLE t(s text) ;
+# handling of some obsucure pseudo-null magic value.
+INSERT INTO t(s) VALUES ('_CpNuLl_'),(''), (NULL);
+
+SELECT * FROM t;
+
+SELECT COUNT(*) FROM t WHERE s IS NULL;
+
+DROP TABLE t;
+
+# There is a problem with comparison
+CREATE TABLE t(c6 CHAR(6)) ;
+
+INSERT INTO t(c6) VALUES ('a'), ('b'), ('c');
+
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= '');
+
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b');
+
+SELECT 0, COUNT(*) FROM t WHERE (c6 <= '');
+
+SELECT 0, COUNT(*) FROM t WHERE (c6 <= ' ');
+
+SELECT 2, COUNT(*) FROM t WHERE (c6 <= 'b' OR c6 <= ' ');
+
+SELECT 0, COUNT(*) FROM t WHERE (c6 < '');
+
+SELECT 0, COUNT(*) FROM t WHERE (c6 < ' ');
+
+DROP TABLE IF EXISTS t;
+CREATE TABLE t(a CHAR(10));
+INSERT INTO t(a) VALUES (''), (NULL), (' '), (' a ');
+SELECT LTRIM(a) FROM t;
+SELECT RTRIM(a) FROM t;
+#SELECT length(RTRIM(a)) FROM t;
+#SELECT length(RTRIM(a)) FROM t;
+
+DROP DATABASE empty_string_not_null;
diff --git a/mysql-test/suite/tianmu/t/escape.test b/mysql-test/suite/tianmu/t/escape.test
index dbd976c58..27a24cc05 100644
--- a/mysql-test/suite/tianmu/t/escape.test
+++ b/mysql-test/suite/tianmu/t/escape.test
@@ -41,7 +41,7 @@ SELECT * FROM st1 WHERE NAME LIKE CONCAT("%", "a_", "%") ESCAPE "a";
SELECT * FROM st1 WHERE NAME LIKE "a%_" ESCAPE "a" ;
SELECT * FROM st1 WHERE NAME LIKE "a%a" ESCAPE "a" ;
-#bug1157 SELECT * FROM st1 WHERE NAME LIKE "a%a_" ESCAPE "a";
+SELECT * FROM st1 WHERE NAME LIKE "a%a_" ESCAPE "a";
drop table st1;
CREATE TABLE `st1` (
@@ -61,7 +61,7 @@ select * from st1;
select * from st1 where name like '%hello%';
select * from st1 where name like '_hello';
select * from st1 where name like 'hello12_';
-#bug1157 select * from st1 where name like '/_hello' escape '/';
+select * from st1 where name like '/_hello' escape '/';
create table st2(id int ,column_2 varchar(10),column_3 varchar(10));
@@ -80,11 +80,11 @@ select * from st2 where column_2 like '%\_%' ;
select * from st2 where column_2 like '%?_%' escape '?';
-#bug1162 select * from st2 where column_2 like '%?_a\\%';
-#bug1162 select * from st2 where column_2 like '%\_a\\%';
+select * from st2 where column_2 like '%?_a\\%';
+select * from st2 where column_2 like '%\_a\\%';
-#bug1162 select * from st2 where column_2 like '%?_a?\%';
-#bug1162 select * from st2 where column_2 like '%\_a\\%';
+select * from st2 where column_2 like '%?_a?\%';
+select * from st2 where column_2 like '%\_a\\%';
# clean up
DROP DATABASE escape_test;
diff --git a/mysql-test/suite/tianmu/t/hash_join.test b/mysql-test/suite/tianmu/t/hash_join.test
new file mode 100644
index 000000000..fffbc1f90
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/hash_join.test
@@ -0,0 +1,107 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS hash_join_test;
+--enable_warnings
+
+CREATE DATABASE hash_join_test;
+
+USE hash_join_test;
+
+CREATE TABLE `test1` (
+ `id` varchar(64) NOT NULL COMMENT 'ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE `test2` (
+ `user_id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+CREATE TABLE `test3` (
+ `id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+CREATE TABLE `test4` (
+ `id` varchar(32) NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+insert test1 values('aaa');
+insert test1 values('bbb');
+insert test1 values('ccc');
+insert test1 values('eee');
+
+insert test2 values('aaa');
+insert test2 values('bbb');
+insert test2 values('ccc');
+insert test2 values('fff');
+
+insert test3 values('aaa');
+insert test3 values('bbb');
+insert test3 values('ccc');
+insert test3 values('ddd');
+
+insert test4 values('aaa');
+insert test4 values('bbb');
+insert test4 values('ccc');
+insert test4 values('hhh');
+insert test4 values('ggg');
+
+select test1.id,test2.user_id from test2,test1 where test2.user_id = test1.id ;
+
+select test1.id,test2.user_id,test3.id from test2,test1,test3 where test2.user_id = test1.id and test2.user_id = test3.id;
+
+select test1.id,test2.user_id,test3.id,test4.id from test2,test1,test3,test4 where test2.user_id = test1.id and test2.user_id = test3.id and test3.id = test4.id;
+
+CREATE TABLE `t1` (
+ `id` int NOT NULL COMMENT 'ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE `t2` (
+ `user_id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+CREATE TABLE `t3` (
+ `id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+CREATE TABLE `t4` (
+ `id` int NOT NULL COMMENT '用户ID'
+) ENGINE=TIANMU DEFAULT CHARSET=utf8;
+
+insert t1 values(101);
+insert t1 values(103);
+insert t1 values(103);
+insert t1 values(201);
+
+insert t2 values(101);
+insert t2 values(102);
+insert t2 values(103);
+insert t2 values(202);
+
+insert t3 values(101);
+insert t3 values(102);
+insert t3 values(103);
+insert t3 values(203);
+
+insert t4 values(101);
+insert t4 values(102);
+insert t4 values(103);
+insert t4 values(204);
+insert t4 values(205);
+
+select t1.id,t2.user_id from t2,t1 where t2.user_id = t1.id ;
+
+select t1.id,t2.user_id,t3.id from t2,t1,t3 where t2.user_id = t1.id and t2.user_id = t3.id;
+
+select t1.id,t2.user_id,t3.id,t4.id from t2,t1,t3,t4 where t2.user_id = t1.id and t2.user_id = t3.id and t3.id = t4.id;
+
+drop table test1;
+drop table test2;
+drop table test3;
+drop table test4;
+
+drop table t1;
+drop table t2;
+drop table t3;
+drop table t4;
+
+DROP DATABASE hash_join_test;
diff --git a/mysql-test/suite/tianmu/t/in_withpk.test b/mysql-test/suite/tianmu/t/in_withpk.test
new file mode 100644
index 000000000..45f46a8b4
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/in_withpk.test
@@ -0,0 +1,126 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # Test in subquery with pk
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS in_withpk_test;
+--enable_warnings
+
+CREATE DATABASE in_withpk_test;
+USE in_withpk_test;
+
+create table t0 (a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (
+ a int,
+ b int,
+ primary key(a)
+) ;
+insert into t1 values (1,1),(3,3),(2,2);
+
+create table t2 (
+ a int,
+ b int
+) ;
+insert into t2 select a, a/2 from t0;
+select * from t1 order by 1;
+select * from t2;
+select * from t2 where b in (select a from t1);
+
+create table t3 (
+ a int,
+ b int,
+ pk1 char(50), pk2 char(50), pk3 char(50),
+ primary key(pk1, pk2, pk3)
+) ;
+insert into t3 select a,a, a,a,a from t0;
+
+select * from t3 where b in (select a from t1);
+
+drop table t3;
+create table t3 (
+ a int,
+ b int,
+ pk1 char(100), pk2 char(100),
+ primary key(pk1, pk2)
+) ;
+insert into t3 select
+ A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a, A.a + 10*B.a
+from t0 A, t0 B where B.a <5;
+select * from t3 where b in (select a from t0);
+select * from t3 where b in (select A.a+B.a from t0 A, t0 B where B.a<5) order by a,b;
+
+select * from t1 where a in (select b from t2) order by a;
+
+drop table t0, t1, t2, t3;
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (a char(50), b char(50), c char(50), primary key (a,b,c)) ;
+insert into t2 select concat(a, repeat('X',48)),repeat('B',50),repeat('B',50) from t1;
+insert into t2 select concat(a, repeat('Y',48)),repeat('B',50),repeat('B',50) from t1;
+alter table t2 add filler1 int;
+
+insert into t1 select A.a + 2*(B.a + 2*C.a) from t1 A, t1 B, t1 C;
+
+select * from t2 where filler1 in ( select a from t1);
+drop table t1, t2;
+
+create table t1 (c6 timestamp);
+create table t2 (c2 double);
+insert into t2 values(12.4);
+select 1 from t2 where c2 = any (select log10(null) from t1 where c6 4567890123456789;
+#bug1332 SELECT * FROM int8_tbl WHERE q2 < 4567890123456789;
+SELECT * FROM int8_tbl WHERE q2 > 4567890123456789;
+#bug1332 SELECT * FROM int8_tbl WHERE q2 <= 4567890123456789;
+SELECT * FROM int8_tbl WHERE q2 >= 4567890123456789;
+
+# int8/int4 cmp
+SELECT * FROM int8_tbl WHERE q2 = 456;
+SELECT * FROM int8_tbl WHERE q2 <> 456;
+#bug1332 SELECT * FROM int8_tbl WHERE q2 < 456;
+SELECT * FROM int8_tbl WHERE q2 > 456;
+#bug1332 SELECT * FROM int8_tbl WHERE q2 <= 456;
+SELECT * FROM int8_tbl WHERE q2 >= 456;
+
+# int4/int8 cmp
+SELECT * FROM int8_tbl WHERE 123 = q1;
+SELECT * FROM int8_tbl WHERE 123 <> q1;
+SELECT * FROM int8_tbl WHERE 123 < q1;
+#bug1332 SELECT * FROM int8_tbl WHERE 123 > q1;
+SELECT * FROM int8_tbl WHERE 123 <= q1;
+#bug1332 SELECT * FROM int8_tbl WHERE 123 >= q1;
+
+# cleanup
+drop DATABASE integer_range_test;
diff --git a/mysql-test/suite/tianmu/t/issue1065.test b/mysql-test/suite/tianmu/t/issue1065.test
index 128d5f6e4..e0f391b59 100644
--- a/mysql-test/suite/tianmu/t/issue1065.test
+++ b/mysql-test/suite/tianmu/t/issue1065.test
@@ -9,7 +9,8 @@ CREATE DATABASE issue1065_test;
USE issue1065_test;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
--enable_warnings
--disable_warnings
drop table if exists t_test;
@@ -56,7 +57,8 @@ DELIMITER ;//
drop PROCEDURE add_user;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
+set tianmu_mandatory=ON;
+set tianmu_no_key_error=ON;
--enable_warnings
DELIMITER //;
@@ -90,7 +92,8 @@ DELIMITER ;//
drop PROCEDURE add_user;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
--enable_warnings
DELIMITER //;
@@ -136,7 +139,8 @@ CREATE TABLE t_test(
) engine=innodb;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
+set tianmu_mandatory=ON;
+set tianmu_no_key_error=ON;
--enable_warnings
DELIMITER //;
@@ -170,7 +174,8 @@ DELIMITER ;//
drop PROCEDURE add_user;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
+set tianmu_no_key_error=OFF;
--enable_warnings
DELIMITER //;
diff --git a/mysql-test/suite/tianmu/t/issue1079_366.test b/mysql-test/suite/tianmu/t/issue1079_366.test
new file mode 100644
index 000000000..340b61aaf
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1079_366.test
@@ -0,0 +1,50 @@
+--source include/have_tianmu.inc
+--source include/have_binlog_format_row.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1079_test;
+--enable_warnings
+CREATE DATABASE issue1079_test;
+USE issue1079_test;
+
+create table t(fi int, fv varchar(30), fdt datetime)engine=tianmu;
+
+insert into t values(1,'VAR-1',current_timestamp);
+insert into t values(2,'VAR-2',current_timestamp);
+insert into t values(3,'VAR-3',current_timestamp);
+insert into t values(4,'VAR-4',current_timestamp);
+insert into t values(5,'VAR-5',current_timestamp);
+insert into t values(6,'VAR-6',current_timestamp);
+insert into t values(7,'VAR-7',current_timestamp);
+insert into t values(8,'VAR-8',current_timestamp);
+insert into t values(9,'VAR-9',current_timestamp);
+insert into t values(10,'VAR-10',current_timestamp);
+select count(*) c from t;
+
+insert into t select fi+10,concat('VAR-',fi+10),current_timestamp from t;
+insert into t select fi+20,concat('VAR-',fi+20),current_timestamp from t;
+insert into t select fi+40,concat('VAR-',fi+40),current_timestamp from t;
+insert into t select fi+80,concat('VAR-',fi+80),current_timestamp from t;
+select count(*) c from t;
+
+insert into t select fi+160,concat('VAR-',fi+160),current_timestamp from t;
+insert into t select fi+320,concat('VAR-',fi+320),current_timestamp from t;
+insert into t select fi+640,concat('VAR-',fi+640),current_timestamp from t;
+select count(*) c from t;
+
+insert into t select fi+1280,concat('VAR-',fi+1280),current_timestamp from t;
+insert into t select fi+2560,concat('VAR-',fi+2560),current_timestamp from t;
+insert into t select fi+5120,concat('VAR-',fi+5120),current_timestamp from t;
+select count(*) c from t;
+
+insert into t select fi+10240,concat('VAR-',fi+10240),current_timestamp from t;
+insert into t select fi+20480,concat('VAR-',fi+20480),current_timestamp from t;
+select count(*) c from t;
+
+show create table t;
+
+alter table t modify column fv varchar(60);
+
+show create table t;
+
+DROP DATABASE issue1079_test;
diff --git a/mysql-test/suite/tianmu/t/issue1090.test b/mysql-test/suite/tianmu/t/issue1090.test
index c40f01b0f..467ea3d28 100644
--- a/mysql-test/suite/tianmu/t/issue1090.test
+++ b/mysql-test/suite/tianmu/t/issue1090.test
@@ -6,12 +6,12 @@ set global default_storage_engine=innodb;
--enable_warnings
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo #
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
--enable_warnings
--echo [on master]
@@ -39,11 +39,11 @@ drop table t_issue1090;
--echo #
---echo # sql_mode='MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo #
--echo [on slave]
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
--enable_warnings
--echo [on master]
@@ -52,8 +52,6 @@ create table t_issue1090_2(c1 int,c2 varchar(255));
show create table t_issue1090_2;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show variables like '%_engine';
show create table t_issue1090_2;
--echo [on master]
connection master;
@@ -61,8 +59,6 @@ alter table t_issue1090_2 add c3 int;
show create table t_issue1090_2;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show global variables like '%_engine';
show create table t_issue1090_2;
--echo [on master]
connection master;
@@ -70,11 +66,11 @@ drop table t_issue1090_2;
--source include/sync_slave_sql_with_master.inc
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo #
--echo [on slave]
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
--enable_warnings
--echo [on master]
@@ -84,8 +80,6 @@ create table t_issue1090_3(c1 int,c2 varchar(255));
show create table t_issue1090_3;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show global variables like '%_engine';
show create table t_issue1090_3;
--echo [on master]
connection master;
@@ -93,8 +87,6 @@ alter table t_issue1090_3 add c3 int;
show create table t_issue1090_3;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show global variables like '%_engine';
show create table t_issue1090_3;
--echo [on master]
connection master;
@@ -102,12 +94,12 @@ drop table t_issue1090_3;
--source include/sync_slave_sql_with_master.inc
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo #
--echo [on slave]
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
--enable_warnings
@@ -118,8 +110,6 @@ create table t_issue1090_4(c1 int,c2 varchar(255));
show create table t_issue1090_4;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show global variables like '%_engine';
show create table t_issue1090_4;
--echo [on master]
connection master;
@@ -127,8 +117,6 @@ alter table t_issue1090_4 DROP COLUMN c2;
show create table t_issue1090_4;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
-show global variables like 'sql_mode';
-show global variables like '%_engine';
show create table t_issue1090_4;
--echo [on master]
connection master;
diff --git a/mysql-test/suite/tianmu/t/issue1111-slave.opt b/mysql-test/suite/tianmu/t/issue1111-slave.opt
new file mode 100644
index 000000000..0b4d5c77c
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1111-slave.opt
@@ -0,0 +1,2 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
diff --git a/mysql-test/suite/tianmu/t/issue1111.testbak b/mysql-test/suite/tianmu/t/issue1111.test
similarity index 99%
rename from mysql-test/suite/tianmu/t/issue1111.testbak
rename to mysql-test/suite/tianmu/t/issue1111.test
index 5d156aa4d..d3093c558 100644
--- a/mysql-test/suite/tianmu/t/issue1111.testbak
+++ b/mysql-test/suite/tianmu/t/issue1111.test
@@ -10,7 +10,6 @@ drop table if exists `t3`;
-- source include/master-slave.inc
--enable_warnings
-
--echo #
--echo # Has primary key
--echo #
@@ -34,6 +33,7 @@ update ttt set name='lllll' where id in(1,3,2);
select * from ttt where id in(1,3,2) order by id desc;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
+show create table ttt;
select * from ttt where id in(1,3,2) order by id desc;
--echo [on master]
connection master;
diff --git a/mysql-test/suite/tianmu/t/issue1131.test b/mysql-test/suite/tianmu/t/issue1131.test
index 7527f3e72..1d3dc5848 100644
--- a/mysql-test/suite/tianmu/t/issue1131.test
+++ b/mysql-test/suite/tianmu/t/issue1131.test
@@ -5,15 +5,14 @@ use test;
drop table IF EXISTS tmp_table;
--enable_warnings
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo #
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
--enable_warnings
create table t_issue1131(c1 int,c2 varchar(255))engine=innodb;
show create table t_issue1131;
-show variables like 'sql_mode';
show variables like '%_engine';
alter table t_issue1131 add c3 int;
show create table t_issue1131;
@@ -29,15 +28,14 @@ drop table tmp_table;
--echo #
---echo # sql_mode='MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo #
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set tianmu_mandatory=ON;
--enable_warnings
create table t_issue1131(c1 int,c2 varchar(255))engine=innodb;
show create table t_issue1131;
-show variables like 'sql_mode';
show variables like '%_engine';
alter table t_issue1131 add c3 int;
show create table t_issue1131;
@@ -52,16 +50,15 @@ show create table tmp_table;
drop table tmp_table;
--echo #
---echo # sql_mode='MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo # set default_storage_engine=innodb;
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set tianmu_mandatory=ON;
--enable_warnings
set default_storage_engine=innodb;
create table t_issue1131(c1 int,c2 varchar(255));
show create table t_issue1131;
-show variables like 'sql_mode';
show variables like '%_engine';
alter table t_issue1131 add c3 int;
show create table t_issue1131;
@@ -76,16 +73,15 @@ show create table tmp_table;
drop table tmp_table;
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo #
--echo [on slave]
--disable_warnings
-set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set tianmu_mandatory=OFF;
--enable_warnings
create table t_issue1131(c1 int,c2 varchar(255));
show create table t_issue1131;
-show variables like 'sql_mode';
show variables like '%_engine';
alter table t_issue1131 add c3 int;
show create table t_issue1131;
diff --git a/mysql-test/suite/tianmu/t/issue1173.test b/mysql-test/suite/tianmu/t/issue1173.test
new file mode 100644
index 000000000..e1b4d9e83
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1173.test
@@ -0,0 +1,21 @@
+--source include/have_tianmu.inc
+--disable_warnings
+
+DROP DATABASE IF EXISTS issue1173;
+CREATE DATABASE issue1173;
+USE issue1173;
+
+CREATE TABLE t1 (a TIME(1) NOT NULL);
+INSERT INTO t1 VALUES ('00:00:02.9');
+SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t1;
+
+CREATE TABLE t2 (a DATETIME(1) NOT NULL);
+INSERT INTO t2 VALUES ('2001-01-01 00:00:02.9');
+INSERT INTO t2 VALUES ('2001-01-01 23:59:59.9');
+INSERT INTO t2 VALUES ('9999-12-31 23:59:59.9');
+SELECT a, a & a, a | a, a^0, a<<1, a<<0, a>>1, bit_count(a) FROM t2;
+
+DROP TABLE t1;
+DROP TABLE t2;
+
+DROP DATABASE issue1173;
diff --git a/mysql-test/suite/tianmu/t/issue1174-slave.opt b/mysql-test/suite/tianmu/t/issue1174-slave.opt
new file mode 100644
index 000000000..43c6c2ea1
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1174-slave.opt
@@ -0,0 +1,2 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1174.test b/mysql-test/suite/tianmu/t/issue1174.test
index 51662f244..dfcefcd02 100644
--- a/mysql-test/suite/tianmu/t/issue1174.test
+++ b/mysql-test/suite/tianmu/t/issue1174.test
@@ -10,7 +10,6 @@ drop table if exists `t3`;
-- source include/master-slave.inc
--enable_warnings
-
--echo #
--echo # Has primary key
--echo #
@@ -35,6 +34,7 @@ update ttt set name='lllll' where id in(1,3,2,0);
select * from ttt where id in(1,3,2,0) order by id desc;
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
+show create table ttt;
select * from ttt where id in(1,3,2,0) order by id desc;
--echo [on master]
connection master;
diff --git a/mysql-test/suite/tianmu/t/issue1175.test b/mysql-test/suite/tianmu/t/issue1175.test
new file mode 100644
index 000000000..1562d2402
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1175.test
@@ -0,0 +1,54 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1175_test;
+--enable_warnings
+
+--echo # Creating test database issue1175_test
+CREATE DATABASE issue1175_test;
+
+USE issue1175_test;
+
+--disable_warnings
+
+--echo # Create test table with tianmu engine
+CREATE TABLE t1 (
+ id INT AUTO_INCREMENT PRIMARY KEY,
+ t TIME,
+ d DATE,
+ dt DATETIME,
+ ts TIMESTAMP
+) ENGINE=TIANMU;
+
+--echo # Insert data into test table
+INSERT INTO t1 (t, d, dt, ts) VALUES
+('00:00:00', '2000-01-01', '2000-01-01 00:00:00', '2000-01-01 00:00:00'),
+('-838:59:59', '2001-02-28', '2001-02-28 00:00:00', '2001-02-28 00:00:00'),
+('838:59:59', '2002-03-31', '2002-03-31 23:59:59', '2002-03-31 23:59:59'),
+('-100:00:00', '2010-12-31', '2010-12-31 12:34:56', '2010-12-31 12:34:56'),
+('200:00:00', '2011-11-30', '2011-11-30 18:00:00', '2011-11-30 18:00:00'),
+('-400:00:00', '2012-02-29', '2012-02-29 01:23:45', '2012-02-29 01:23:45'),
+('720:00:00', '2020-10-31', '2020-10-31 14:00:00', '2020-10-31 14:00:00'),
+('05:30:15', '1985-04-12', '1985-04-12 05:30:15.123', '1985-04-12 05:30:15.123'),
+('-23:45:01', '1995-08-24', '1995-08-24 15:45:30.987', '1995-08-24 15:45:30.987'),
+('67:15:45', '2005-06-15', '2005-06-15 10:59:59.001', '2005-06-15 10:59:59.001'),
+('-115:00:00', '2007-12-25', '2007-12-25 23:30:45.500', '2007-12-25 23:30:45.500'),
+('350:30:15', '2015-09-05', '2015-09-05 12:00:00.999', '2015-09-05 12:00:00.999'),
+('-500:45:30', '2017-03-01', '2017-03-01 01:23:45.250', '2017-03-01 01:23:45.250'),
+('600:15:00', '2021-05-01', '2021-05-01 17:30:00.123', '2021-05-01 17:30:00.123'),
+('12:34:56', '1970-01-01', '1970-01-01 12:34:56', '1970-01-01 12:34:56'),
+('-300:00:00.123', '1980-06-30', '1980-06-30 18:30:45.123', '1980-06-30 18:30:45.123'),
+('450:00:00', '1990-03-15', '1990-03-15 11:59:59.999', '1990-03-15 11:59:59.999'),
+('-600:00:00.9', '1999-09-09', '1999-09-09 06:45:00.250', '1999-09-09 06:45:00.250'),
+('-09:00:00', '2005-02-28', '2005-02-28 15:00:00.123', '2005-02-28 15:00:00.123'),
+('-123:45:00', '2008-08-08', '2008-08-08 20:15:30.987', '2008-08-08 20:15:30.987'),
+('99:00:00', '2013-07-07', '2013-07-07 17:30:45.500', '2013-07-07 17:30:45.500'),
+('-220:00:00', '2016-04-30', '2016-04-30 02:00:00.999', '2016-04-30 02:00:00.999'),
+('580:00:00', '2019-12-31', '2019-12-31 01:23:45.250', '2019-12-31 01:23:45.250'),
+('-750:00:00', '2021-08-31', '2021-08-31 09:45:00.123', '2021-08-31 09:45:00.123');
+
+--echo # Select all data from test table
+SELECT * FROM t1 ORDER BY id;
+
+--echo # Dropping test database issue1175_test
+DROP DATABASE issue1175_test;
diff --git a/mysql-test/suite/tianmu/t/issue1186-slave.opt b/mysql-test/suite/tianmu/t/issue1186-slave.opt
index f217c0127..43c6c2ea1 100644
--- a/mysql-test/suite/tianmu/t/issue1186-slave.opt
+++ b/mysql-test/suite/tianmu/t/issue1186-slave.opt
@@ -1 +1,2 @@
---sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR'
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1318-master.opt b/mysql-test/suite/tianmu/t/issue1318-master.opt
index 4494579d7..4eb1b974d 100644
--- a/mysql-test/suite/tianmu/t/issue1318-master.opt
+++ b/mysql-test/suite/tianmu/t/issue1318-master.opt
@@ -1 +1,2 @@
---sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_KEY_ERROR
+--sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1325-slave.opt b/mysql-test/suite/tianmu/t/issue1325-slave.opt
new file mode 100644
index 000000000..43c6c2ea1
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1325-slave.opt
@@ -0,0 +1,2 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1325.test b/mysql-test/suite/tianmu/t/issue1325.test
index 998df688c..2282bf278 100644
--- a/mysql-test/suite/tianmu/t/issue1325.test
+++ b/mysql-test/suite/tianmu/t/issue1325.test
@@ -15,14 +15,6 @@ CREATE DATABASE issue1325_test;
USE issue1325_test;
---source include/sync_slave_sql_with_master.inc
---echo # on slave:
-USE issue1325_test;
-show databases;
---disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU,NO_KEY_ERROR';
---enable_warnings
-
--echo #
--echo # Secondary INDEX
--echo #
@@ -40,8 +32,7 @@ show create table ttt;
--source include/sync_slave_sql_with_master.inc
--echo # on slave:
-connection master;
---echo # on master:
+USE issue1325_test;
show create table ttt;
--echo #
@@ -62,7 +53,6 @@ show create table xxx;
--echo # on slave:
show create table xxx;
-
--echo #
--echo # Full-text index
--echo #
@@ -120,5 +110,4 @@ DROP DATABASE issue1325_test;
--source include/sync_slave_sql_with_master.inc
--echo # on slave:
-show databases;
stop slave;
diff --git a/mysql-test/suite/tianmu/t/issue1402.test b/mysql-test/suite/tianmu/t/issue1402.test
new file mode 100644
index 000000000..173f42884
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1402.test
@@ -0,0 +1,43 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1402_test;
+--enable_warnings
+
+CREATE DATABASE issue1402_test;
+
+USE issue1402_test;
+
+CREATE TABLE t1 (id INT, d DECIMAL(10,4)) ENGINE=tianmu;
+
+INSERT INTO t1 VALUES (1, 1.2345), (2, 2.3456), (3, 3.4567);
+
+SELECT COUNT(*), SUM(d), AVG(d), MIN(d), MAX(d) FROM t1;
+
+SELECT id, SUM(d) FROM t1 GROUP BY id;
+
+SELECT * FROM t1 ORDER BY d DESC;
+
+SELECT * FROM t1 WHERE d > (SELECT AVG(d) FROM t1);
+
+SELECT id, SUM(d) FROM t1 WHERE d > (SELECT AVG(d) FROM t1) GROUP BY id;
+
+SELECT * FROM t1 WHERE d > (SELECT AVG(d) FROM t1) ORDER BY d DESC;
+
+SELECT id, SUM(d) FROM t1 WHERE d > (SELECT AVG(d) FROM t1) GROUP BY id ORDER BY SUM(d) DESC;
+
+SELECT t1.id, t1.d, t2.d FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC LIMIT 1;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id GROUP BY t1.id HAVING SUM(t1.d) > 3 ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+
+SELECT t1.id, SUM(t1.d), SUM(t2.d) FROM t1 JOIN (SELECT id, d FROM t1 WHERE d > 2) t2 ON t1.id = t2.id WHERE t1.id > 1 GROUP BY t1.id HAVING SUM(t1.d) > 3 ORDER BY SUM(t1.d) DESC LIMIT 1 OFFSET 1;
+
+drop database issue1402_test;
diff --git a/mysql-test/suite/tianmu/t/issue1464-slave.opt b/mysql-test/suite/tianmu/t/issue1464-slave.opt
new file mode 100644
index 000000000..43c6c2ea1
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1464-slave.opt
@@ -0,0 +1,2 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1464.test b/mysql-test/suite/tianmu/t/issue1464.test
new file mode 100644
index 000000000..498df28e8
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1464.test
@@ -0,0 +1,44 @@
+--source include/have_tianmu.inc
+--source include/have_binlog_format_row.inc
+--disable_warnings
+--source include/master-slave.inc
+--enable_warnings
+
+connection master;
+--echo # on master:
+--disable_warnings
+DROP DATABASE IF EXISTS issue1464_test;
+--enable_warnings
+CREATE DATABASE issue1464_test;
+USE issue1464_test;
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+USE issue1464_test;
+
+connection master;
+--echo # on master:
+create table ttt(id varchar(64) primary key,name varchar(10))engine=innodb;
+insert into ttt values('0000352b6b4f4011bd18da7176e22c03','AAA');
+insert into ttt values('000246c51ca745f893a705f1699e9b2a','BBB');
+insert into ttt values('00049c87d9c64c498e004f6b08f1dd38','CCC');
+delete from ttt where id='0000352b6b4f4011bd18da7176e22c03';
+select * from ttt order by id;
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+show create table ttt;
+select * from ttt order by id;
+
+connection master;
+--echo # on master:
+insert into ttt values('0000352b6b4f4011bd18da7176e22c03','AAA');
+update ttt set name='name_' where id='000246c51ca745f893a705f1699e9b2a';
+select * from ttt order by id;
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+select * from ttt order by id;
+
+connection master;
+--echo # on master:
+DROP DATABASE issue1464_test;
+--source include/sync_slave_sql_with_master.inc
+stop slave;
diff --git a/mysql-test/suite/tianmu/t/issue1510-master.opt b/mysql-test/suite/tianmu/t/issue1510-master.opt
new file mode 100644
index 000000000..e3c87f6c3
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1510-master.opt
@@ -0,0 +1 @@
+--autocommit=0
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1510.test b/mysql-test/suite/tianmu/t/issue1510.test
new file mode 100644
index 000000000..640acae21
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1510.test
@@ -0,0 +1,23 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1510_test;
+--enable_warnings
+
+CREATE DATABASE issue1510_test;
+
+USE issue1510_test;
+
+create table ttt(id int primary key,name varchar(10));
+begin;
+insert into ttt values(1,'AAA');
+commit;
+select * from ttt;
+drop table ttt;
+
+create table ttt(id int primary key,name varchar(10));
+insert into ttt values(1,'AAA');
+select * from ttt;
+drop table ttt;
+
+DROP DATABASE issue1510_test;
diff --git a/mysql-test/suite/tianmu/t/issue1523-slave.opt b/mysql-test/suite/tianmu/t/issue1523-slave.opt
new file mode 100644
index 000000000..8404579b8
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1523-slave.opt
@@ -0,0 +1,3 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
+--tianmu_insert_delayed=1
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1523.test b/mysql-test/suite/tianmu/t/issue1523.test
new file mode 100644
index 000000000..6762bb0be
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1523.test
@@ -0,0 +1,154 @@
+--source include/have_tianmu.inc
+--source include/have_binlog_format_row.inc
+--disable_warnings
+--source include/master-slave.inc
+--enable_warnings
+
+connection master;
+--echo # on master:
+--disable_warnings
+DROP DATABASE IF EXISTS issue1523_test;
+--enable_warnings
+CREATE DATABASE issue1523_test;
+USE issue1523_test;
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+USE issue1523_test;
+
+connection master;
+--echo # on master:
+CREATE TABLE t1 (
+ `id` int(10) NOT NULL AUTO_INCREMENT,
+ `dev_code` varchar(20) NOT NULL,
+ `port` smallint(2) DEFAULT '0',
+ `server_ip` varchar(20) DEFAULT NULL,
+ `work_status` int(1) DEFAULT '2',
+ `port_link_car` int(1) NOT NULL DEFAULT '0',
+ `last_order_sn` varchar(42) DEFAULT NULL,
+ `last_charge_type` smallint(1) DEFAULT NULL,
+ `last_charge_mode` int(2) DEFAULT '0',
+ `last_status` smallint(1) DEFAULT NULL,
+ `last_soc` int(3) DEFAULT NULL,
+ `last_car_no` varchar(42) DEFAULT NULL,
+ `last_vin` varchar(45) DEFAULT NULL,
+ `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `portindex` (`dev_code`,`port`),
+ KEY `dev_code` (`dev_code`)
+) ENGINE=INNODB;
+
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(1,'3301081000000019',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(2,'3301081000000020',0,'172.16.171.219',3,1,1,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(3,'3301081000000021',0,'172.16.171.219',4,2,2,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+insert into t1 values
+(4,'3301081000000022',1,'172.16.171.219',2,1,'2023040314582504221842260',5,0,5,100,'JJY3786','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+insert into t1 values
+(5,'3301081000000023',1,'172.16.171.219',2,1,'2023040314582504221842261',6,0,6,101,'JJY3787','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+insert into t1 values
+(6,'3301081000000024',1,'172.16.171.219',2,1,'2023040314582504221842262',7,0,7,102,'JJY3788','LKLA6G1M4HA727506','2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(7,'3301081000000025',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+update t1 set last_car_no='JJY3786' where id=1;
+update t1 set last_car_no=NULL where id=1;
+update t1 set last_car_no='JJY3786' where id=1;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(8,'3301081000000026',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(9,'3301081000000027',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+delete from t1 where id=9;
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(9,'3301081000000027',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+select last_car_no from t1 where id=9;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=9;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+update t1 set last_car_no=NULL where id=1;
+delete from t1 where id =1;
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=1;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(10,'3301081000000028',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+update t1 set last_car_no='JJY3786' where id=10;
+select last_car_no from t1 where id=10;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=10;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+insert into t1(id,dev_code,port,server_ip,work_status,port_link_car,last_charge_mode,create_time,update_time) values
+(11,'3301081000000029',0,'172.16.171.219',2,0,0,'2018-08-20 13:46:42','2023-04-02 22:10:30');
+update t1 set last_car_no='JJY3786' where id=11;
+delete from t1 where id =11;
+select last_car_no from t1 where id=11;
+select count(*) from t1;
+
+--source include/sync_slave_sql_with_master.inc
+--echo # on slave:
+sleep 5;
+select last_car_no from t1 where id=11;
+select count(*) from t1;
+
+connection master;
+--echo # on master:
+DROP DATABASE issue1523_test;
+--source include/sync_slave_sql_with_master.inc
+stop slave;
diff --git a/mysql-test/suite/tianmu/t/issue1564.test b/mysql-test/suite/tianmu/t/issue1564.test
new file mode 100644
index 000000000..5314f03f3
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1564.test
@@ -0,0 +1,27 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1564;
+--enable_warnings
+create database issue1564;
+use issue1564;
+
+create table t(a bigint not null);
+insert into t values(-222222), (-22), (-15),(-16),(0), (11), (12), (9223372036854775807);
+select * from t;
+select * from t where a = 18446744073709551601;
+select * from t where a != 18446744073709551601;
+select * from t where a = -22;
+select * from t where a != -22;
+select * from t where a in(-16, -15, -11);
+select * from t where a > 18446744073709551599;
+select * from t where a >= 18446744073709551599;
+select * from t where a < 18446744073709551599;
+select * from t where a <= 18446744073709551599;
+select * from t where a between -22 and 18446744073709551599;
+select * from t where a between -22 and 9223372036854775807;
+select * from t where a between -222222 and 9223372036854775807;
+select * from t where a between 9223372036854775807 and -22;
+
+drop table t;
+drop database issue1564;
diff --git a/mysql-test/suite/tianmu/t/issue1599.test b/mysql-test/suite/tianmu/t/issue1599.test
new file mode 100644
index 000000000..328829a3d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1599.test
@@ -0,0 +1,42 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+
+CREATE DATABASE IF NOT EXISTS test_db_1599;
+
+USE test_db_1599;
+
+create table ttt(c1 int,c2 int);
+
+insert into ttt values(327266,1),(327267,1),(327268,1),(327269,1),(327270,1);
+
+select c1 from ttt union select 'aaa' c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+select c1 from ttt union all select 'aaa' c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+select c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+select c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+select 111 c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+select 111 c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (327265)) x;
+
+drop table ttt;
+
+create table ttt(c1 decimal(18,0),c2 decimal(18,0));
+
+insert into ttt values(3000000000027266,1),(3000000000027267,1),(3000000000027268,1),(3000000000027269,1),(3000000000027270,1);
+
+select c1 from ttt union select 'aaa' c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+
+select c1 from ttt union select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+
+select 'aaa' c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+
+select 111 c1 from ttt union all select 111 c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+
+select c1 from ttt union all select 'aaa' c1 from (select c2 from ttt where c1 IN (3000000000027265)) x;
+
+
+drop database test_db_1599;
diff --git a/mysql-test/suite/tianmu/t/issue1616.test b/mysql-test/suite/tianmu/t/issue1616.test
new file mode 100644
index 000000000..7805fb960
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1616.test
@@ -0,0 +1,64 @@
+--source include/have_tianmu.inc
+--disable_warnings
+DROP DATABASE IF EXISTS issue1616_test;
+CREATE DATABASE issue1616_test;
+USE issue1616_test;
+--enable_warnings
+
+CREATE TABLE T1 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+ DEFAULT '0' NOT NULL, PRIMARY KEY (id)) engine=tianmu;
+
+INSERT INTO T1 VALUES (3,1,1),(4,1,1);
+--ERROR 1062
+INSERT INTO T1 VALUES (3,1,1),(4,1,1);
+
+SELECT * FROM T1;
+
+UPDATE IGNORE T1 SET id=id+1;
+
+SELECT * FROM T1;
+
+--ERROR 1062
+UPDATE T1 SET id =10;
+
+SELECT * FROM T1;
+
+--ERROR 1062
+UPDATE T1 SET ID=5 WHERE ID=3;
+SELECT * FROM T1;
+
+DROP TABLE T1;
+
+
+CREATE TABLE T2 (dt datetime, val int, primary key(dt)) ENGINE =tianmu;
+INSERT INTO T2 VALUES ('2017-11-05 20:29:36',1), ('2027-11-05 20:29:36', 2);
+--ERROR 1062
+UPDATE T2 SET dt ='2027-11-05 20:29:36' WHERE val =1;
+
+SELECT * FROM T2;
+DROP TABLE T2;
+
+#multi-keys
+CREATE TABLE T3 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+ DEFAULT '0' NOT NULL, PRIMARY KEY (id, parent_id)) engine=tianmu;
+
+INSERT INTO T3 VALUES (3,1,1),(4,1,1);
+--ERROR 1062
+INSERT INTO T3 VALUES (3,1,1),(4,1,1);
+
+UPDATE IGNORE T3 SET id=id+1;
+SELECT * FROM T3;
+
+DROP TABLE T3;
+
+CREATE TABLE T4 (id int(11) NOT NULL auto_increment, parent_id int(11) DEFAULT '0' NOT NULL, level tinyint(4)
+ DEFAULT '0' NOT NULL, PRIMARY KEY (id)) engine=innodb;
+
+INSERT INTO T4 VALUES (3,1,1),(4,1,1);
+--ERROR 1062
+UPDATE T4 SET id =10;
+
+SELECT * FROM T4;
+DROP TABLE T4;
+
+DROP DATABASE issue1616_test;
diff --git a/mysql-test/suite/tianmu/t/issue1637-master.opt b/mysql-test/suite/tianmu/t/issue1637-master.opt
new file mode 100644
index 000000000..02eff7f9d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1637-master.opt
@@ -0,0 +1,3 @@
+--tianmu_mandatory=ON
+--tianmu_no_key_error=ON
+--tianmu_insert_delayed=0
diff --git a/mysql-test/suite/tianmu/t/issue1637.test b/mysql-test/suite/tianmu/t/issue1637.test
new file mode 100644
index 000000000..991fe6064
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1637.test
@@ -0,0 +1,22 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1637_test;
+--enable_warnings
+
+CREATE DATABASE issue1637_test;
+
+USE issue1637_test;
+
+create table ttt(id int primary key,name varchar(10));
+insert into ttt values(1,'aaa');
+insert into ttt values(2,'bbb');
+--disable_warnings
+insert ignore into ttt values(2,'ccc');
+--enable_warnings
+
+sleep 2;
+
+select * from ttt;
+
+DROP DATABASE issue1637_test;
diff --git a/mysql-test/suite/tianmu/t/issue1662.test b/mysql-test/suite/tianmu/t/issue1662.test
new file mode 100644
index 000000000..1db590381
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1662.test
@@ -0,0 +1,53 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+
+--let $my_var = 0
+
+--echo # Create test database
+CREATE DATABASE IF NOT EXISTS test_db_1662;
+
+USE test_db_1662;
+
+--echo # Create test table with tianmu engine
+CREATE TABLE IF NOT EXISTS test_table (
+ id INT,
+ value INT,
+ PRIMARY KEY (id)
+) ENGINE=tianmu;
+
+--echo # Insert data into test table
+INSERT INTO test_table (id, value) VALUES
+ (1, 10),
+ (2, 20),
+ (3, 10),
+ (4, 30),
+ (5, 20);
+
+--echo # Select data from test table with user-defined variable
+SELECT
+ id,
+ value,
+ @my_var := IF(value = @prev_value, @my_var, @my_var + 1) AS group_id,
+ @prev_value := value
+FROM
+ test_table,
+ (SELECT @my_var := 0, @prev_value := NULL) AS init
+ORDER BY
+ value,
+ id;
+
+SELECT
+ id,
+ value,
+ @my_var := IF(id = @prev_value, @my_var, @my_var + 1) AS group_id,
+ @prev_value := value
+FROM
+ test_table,
+ (SELECT @my_var := 0, @prev_value := NULL) AS init
+ORDER BY
+ value,
+ id;
+
+DROP DATABASE test_db_1662;
+
diff --git a/mysql-test/suite/tianmu/t/issue1696.test b/mysql-test/suite/tianmu/t/issue1696.test
new file mode 100644
index 000000000..cdc0ed5dc
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1696.test
@@ -0,0 +1,77 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+
+--echo # Creating test database test_db_1696
+CREATE DATABASE IF NOT EXISTS test_db_1696;
+
+USE test_db_1696;
+
+CREATE DATABASE IF NOT EXISTS test_database;
+USE test_database;
+
+CREATE TABLE IF NOT EXISTS t1 (
+ id INT NOT NULL,
+ value INT NOT NULL
+) ENGINE=tianmu;
+
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+
+CREATE TABLE IF NOT EXISTS t2 (
+ id INT NOT NULL,
+ value INT NOT NULL
+) ENGINE=tianmu;
+
+INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+
+CREATE TABLE IF NOT EXISTS t3 (
+ id INT NOT NULL,
+ value INT NOT NULL
+) ENGINE=tianmu;
+
+INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3);
+
+SET @counter = 0;
+
+SELECT
+ *,
+ IF(@counter != 1, @counter, @counter := @counter + 1) AS counter
+FROM
+ (
+ SELECT
+ t1.id AS id1,
+ t1.value AS value1,
+ t2.id AS id2,
+ t2.value AS value2,
+ t3.id AS id3,
+ t3.value AS value3
+ FROM
+ t1
+ JOIN t2 ON t1.value = t2.value
+ JOIN t3 ON t2.value = t3.value
+ ) AS derived_table;
+DROP TABLE t1, t2, t3;
+
+set @rankno = 1;
+
+create table d(taxis_no int);
+
+insert into d values(1);
+insert into d values(1);
+insert into d values(1);
+
+SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d;
+
+set @rankno = 1;
+
+drop table d;
+create table d(taxis_no int);
+
+insert into d values(1);
+insert into d values(2);
+insert into d values(3);
+
+SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d;
+
+--echo # Dropping test database test_db_1696
+DROP DATABASE IF EXISTS test_db_1696;
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue1707.test b/mysql-test/suite/tianmu/t/issue1707.test
new file mode 100644
index 000000000..10e6a878e
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1707.test
@@ -0,0 +1,41 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+
+CREATE DATABASE IF NOT EXISTS test_db_1707;
+
+USE test_db_1707;
+
+CREATE TABLE tianmu_table (
+ id INT NOT NULL,
+ name VARCHAR(50) NOT NULL,
+ age INT NOT NULL,
+ gender VARCHAR(10) NOT NULL,
+ salary INT NOT NULL,
+ address VARCHAR(100) NOT NULL
+) ENGINE=tianmu;
+
+INSERT INTO tianmu_table
+ (id, name, age, gender, salary, address)
+VALUES
+ (1, 'John', 25, 'Male', 50000, '123 Main St'),
+ (2, 'Jane', 30, 'Female', 60000, '456 Elm St'),
+ (3, 'Bob', 35, 'Male', 70000, '789 Maple St');
+
+
+select @age_cutoff := age
+from (
+SELECT name, age, gender, salary
+FROM (
+ SELECT name, age, gender, salary
+ FROM tianmu_table
+ WHERE age < 30
+ UNION ALL
+ SELECT name, age, gender, salary
+ FROM tianmu_table
+ WHERE age >= 30
+) AS derived_table
+WHERE salary > 30 ) H;
+
+
+drop database test_db_1707;
diff --git a/mysql-test/suite/tianmu/t/issue1784.test b/mysql-test/suite/tianmu/t/issue1784.test
new file mode 100644
index 000000000..f77eefda8
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1784.test
@@ -0,0 +1,158 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1784_test;
+
+CREATE DATABASE issue1784_test;
+
+USE issue1784_test;
+
+### tianmu
+
+## no value
+
+create table t1 (age int) engine=tianmu;
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1 group by age;
+
+select age, sum(age) from (select * from t1) ta group by age;
+
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+
+## has value
+
+insert into t1 values(1);
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1 group by age;
+
+select age, sum(age) from (select * from t1) ta group by age;
+
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+
+### innodb
+
+## no value
+
+drop table t1;
+
+create table t1 (age int) engine=innodb;
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1 group by age;
+
+select age, sum(age) from (select * from t1) ta group by age;
+
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+
+## has value
+
+insert into t1 values(1);
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1 group by age;
+
+select age, sum(age) from (select * from t1) ta group by age;
+
+select case when age is not null then age else 33 end, sum(age) from t1 group by age;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta group by age;
+
+####
+
+drop table t1;
+
+SET sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+
+### tianmu
+
+## no value
+
+create table t1 (age int) engine=tianmu;
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1;
+
+select age, sum(age) from (select * from t1) ta;
+
+select case when age is not null then age else 33 end, sum(age) from t1;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+
+## has value
+
+insert into t1 values(1);
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1;
+
+select age, sum(age) from (select * from t1) ta;
+
+select case when age is not null then age else 33 end, sum(age) from t1;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+
+### innodb
+
+## no value
+
+drop table t1;
+
+create table t1 (age int) engine=innodb;
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1;
+
+select age, sum(age) from (select * from t1) ta;
+
+select case when age is not null then age else 33 end, sum(age) from t1;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+
+## has value
+
+insert into t1 values(1);
+
+select * from t1;
+
+select age from t1;
+
+select age, sum(age) from t1;
+
+select age, sum(age) from (select * from t1) ta;
+
+select case when age is not null then age else 33 end, sum(age) from t1;
+
+select case when age is not null then age else 33 end, sum(age) from (select * from t1) ta;
+
+## clean test database
+
+DROP DATABASE issue1784_test;
diff --git a/mysql-test/suite/tianmu/t/issue1808.test b/mysql-test/suite/tianmu/t/issue1808.test
new file mode 100644
index 000000000..90ae0798f
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1808.test
@@ -0,0 +1,20 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1808_test;
+
+CREATE DATABASE issue1808_test;
+
+USE issue1808_test;
+
+--enable_warnings
+--disable_query_log
+
+CREATE TABLE ttt(c1 decimal(18,0),c2 decimal(18,0));
+INSERT INTO ttt VALUES(3000000000027266,1),(3000000000027267,1),(3000000000027268,1),(3000000000027269,1),(3000000000027270,1);
+
+--enable_query_log
+SELECT c1 FROM ttt UNION ALL SELECT 'aaa' c1 FROM (SELECT c2 FROM ttt WHERE c1 IN (3000000000027265)) x ORDER BY c1;
+
+DROP DATABASE issue1808_test;
+
diff --git a/mysql-test/suite/tianmu/t/issue1848.test b/mysql-test/suite/tianmu/t/issue1848.test
new file mode 100644
index 000000000..cd8a38359
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1848.test
@@ -0,0 +1,43 @@
+-- source include/have_tianmu.inc
+
+--disable_warnings
+
+--disable_query_log
+
+DROP DATABASE IF EXISTS issue1848_test_db;
+CREATE DATABASE issue1848_test_db;
+
+USE issue1848_test_db;
+
+DROP TABLE IF EXISTS squence;
+
+CREATE TABLE sequence (
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
+ `created_date` datetime DEFAULT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=TIANMU AUTO_INCREMENT=3000000004910127 DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO `sequence`
+VALUES (3000000000010000,'2023-04-17 15:25:11'),
+(3000000000010001,'2023-04-17 15:29:14'),
+(3000000000010002,'2023-04-17 15:29:14'),
+(3000000000010003,'2023-04-17 15:29:14'),
+(3000000000010004,'2023-04-17 15:29:14'),
+(3000000000010005,'2023-04-17 15:29:14'),
+(3000000000010006,'2023-04-17 15:29:14'),
+(3000000000010007,'2023-04-17 15:29:14'),
+(3000000000010008,'2023-04-17 15:29:14'),
+(3000000000010009,'2023-04-17 15:29:14'),
+(3000000000010010,'2023-04-17 15:29:14');
+
+--enable_query_log
+
+SELECT GROUP_CONCAT(t.id) FROM sequence t;
+
+--disable_query_log
+DROP TABLE sequence;
+
+DROP DATABASE issue1848_test_db;
+--enable_query_log
+
+--enable_warnings
diff --git a/mysql-test/suite/tianmu/t/issue1855.test b/mysql-test/suite/tianmu/t/issue1855.test
new file mode 100644
index 000000000..914e401d2
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1855.test
@@ -0,0 +1,88 @@
+-- source include/have_tianmu.inc
+
+--disable_warnings
+
+--disable_query_log
+
+DROP DATABASE IF EXISTS issue1855_test_db;
+CREATE DATABASE issue1855_test_db;
+
+USE issue1855_test_db;
+
+DROP TABLE IF EXISTS squence;
+
+CREATE TABLE ttt (
+ p_id varchar(50) NOT NULL,
+ p_val int NOT NULL
+) ENGINE=TIANMU AUTO_INCREMENT=3000000004910127 DEFAULT CHARSET=utf8mb4;
+
+INSERT INTO `ttt`
+VALUES("THIS IS", 20),
+("THIS IS", 5),
+("A TEST", 2),
+("FOR SUM LENGTH", 10);
+--enable_query_log
+
+SELECT SUM(LENGTH(p_id)) FROM ttt;
+
+SELECT SUM(LENGTH(p_id)/2) FROM ttt;
+
+SELECT SUM(LENGTH(p_val)) FROM ttt;
+
+SELECT SUM(LENGTH(p_val)/2) FROM ttt;
+
+--disable_query_log
+
+--DELIMITER //
+CREATE PROCEDURE insert_data()
+wholeblock:BEGIN
+ DECLARE x INT;
+ DECLARE str VARCHAR(50);
+ DECLARE str1 VARCHAR(50);
+ SET x = 0;
+ SET str = 'this is ';
+ SET str1 = '';
+
+ loop_label: LOOP
+ IF x > 10000 THEN
+ LEAVE loop_label;
+ END IF;
+
+ SET str1 = substring(md5(rand()), 1, 10);
+ SET str = CONCAT(str,str1,',');
+ SET str = CONCAT(str,x,',');
+
+ INSERT INTO ttt VALUES (str, x);
+ SET str ='';
+ SET x = x + 1;
+ ITERATE loop_label;
+ END LOOP;
+END//
+
+--DELIMITER ;
+
+CALL insert_data();
+
+DROP PROCEDURE insert_data;
+
+SHOW VARIABLES LIKE "%tianmu_groupby_parallel%";
+
+SET GLOBAL tianmu_groupby_parallel_rows_minimum = 100;
+SET GLOBAL tianmu_groupby_parallel_degree = 4;
+
+SHOW VARIABLES LIKE "%tianmu_groupby_parallel%";
+
+SELECT SUM(LENGTH(p_id)) FROM ttt;
+
+SELECT SUM(LENGTH(p_id)/2) FROM ttt;
+
+SELECT SUM(LENGTH(p_val)) FROM ttt;
+
+SELECT SUM(LENGTH(p_val)/2) FROM ttt;
+
+
+DROP TABLE ttt;
+DROP DATABASE issue1855_test_db;
+--enable_query_log
+
+--enable_warnings
diff --git a/mysql-test/suite/tianmu/t/issue1860.test b/mysql-test/suite/tianmu/t/issue1860.test
new file mode 100644
index 000000000..3077ad01d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1860.test
@@ -0,0 +1,43 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1860_test;
+
+CREATE DATABASE issue1860_test;
+USE issue1860_test;
+--enable_warnings
+
+
+CREATE TABLE tt(id decimal(18,0), dt datetime) ENGINE =TIANMU;
+INSERT INTO tt VALUES(1111.0, '2023-01-01');
+
+SELECT id FROM tt UNION SELECT 2222 c1 FROM dual;
+
+INSERT INTO tt VALUES(2222.0, '2023-02-02');
+
+SELECT id FROM tt UNION SELECT 2222 c1 FROM dual;
+SELECT id FROM tt UNION ALL SELECT 2222 c1 FROM dual;
+
+SELECT id FROM tt UNION SELECT 2222 ;
+sELECT id FROM tt UNION ALL SELECT 2222;
+
+SELECT id, dt FROM tt UNION SELECT 2222, '2022-01-01';
+SELECT id, dt FROM tt UNION SELECT 2222, str_to_date('2022-02-03', '%Y-%m-%d');
+SELECT id, dt FROM tt UNION SELECT 2222, str_to_date('2023-02-02', '%Y-%m-%d');
+
+#ERROR 1105 (HY000): wrong types of columns
+--error 1105
+SELECT dt FROM tt UNION SELECT 2222;
+SELECT dt FROM tt UNION SELECT '2222';
+
+#ERROR 1222 (21000): The used SELECT statements have a different number of columns
+--error 1222
+SELECT * FROM tt UNION SELECT 222;
+--error 1222
+SELECT * FROM tt UNION ALL SELECT 222;
+
+
+DROP TABLE tt;
+
+DROP DATABASE issue1860_test;
+
diff --git a/mysql-test/suite/tianmu/t/issue1861.test b/mysql-test/suite/tianmu/t/issue1861.test
new file mode 100644
index 000000000..02ad68d0d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1861.test
@@ -0,0 +1,78 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1861_test;
+
+CREATE DATABASE issue1861_test;
+USE issue1861_test;
+--enable_warnings
+
+CREATE TABLE `c1fg_pool` (
+ `ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE `c1fg_pl_node` (
+ `ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ `POOL_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ `COMPANY_ID` decimal(18,0) DEFAULT '-1',
+ PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+
+CREATE TABLE `c1fg_pl_account` (
+ `ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ `NODE_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+CREATE TABLE `c1fg_pl_subsidiary` (
+ `ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ `ACCOUNT_ID` decimal(18,0) NOT NULL DEFAULT '-1',
+ `FISCAL_DATE` date DEFAULT NULL,
+ `DR_AMOUNT` decimal(16,2) NOT NULL DEFAULT '0.00' ,
+ PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+
+CREATE TABLE `c1md_company` (
+ `ROW_ID` decimal(18,0) NOT NULL DEFAULT '-1' ,
+ `SYS_ID` decimal(18,0) NOT NULL DEFAULT '-1' ,
+ PRIMARY KEY (`ROW_ID`)
+) ENGINE=TIANMU DEFAULT CHARSET=utf8mb4;
+
+#---------------------------------------------------
+SELECT B.company_id,
+ '上划日' ud_type,
+ 2 sort_no,
+ '合计' fiscal_date,
+ DATE_FORMAT('2023-06-06', '%Y-%m-%d') fiscal_date,
+ C.pl_amount
+ FROM c1fg_pool A
+ INNER JOIN c1fg_pl_node B
+ ON A.row_id = B.pool_id
+ LEFT JOIN (SELECT c.node_id, SUM(d.dr_amount) pl_amount
+ FROM c1fg_pool a,
+ c1fg_pl_node b,
+ c1fg_pl_account c,
+ c1fg_pl_subsidiary d
+ WHERE a.row_id = b.pool_id
+ AND b.row_id = c.node_id
+ AND c.row_id = d.account_id
+ AND b.company_id IN
+ (SELECT t1.row_id
+ FROM c1md_company t1, c1md_company t2
+ WHERE t1.sys_id = t2.sys_id)
+ GROUP BY c.node_id) C
+ON B.row_id = C.node_id
+ORDER BY B.company_id;
+
+
+
+DROP TABLE c1md_company;
+DROP TABLE c1fg_pl_subsidiary;
+DROP TABLE c1fg_pl_account;
+DROP TABLE c1fg_pl_node;
+DROP TABLE c1fg_pool;
+
+DROP DATABASE issue1861_test;
diff --git a/mysql-test/suite/tianmu/t/issue1864.test b/mysql-test/suite/tianmu/t/issue1864.test
new file mode 100644
index 000000000..a39f2c437
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1864.test
@@ -0,0 +1,32 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1864_test;
+
+CREATE DATABASE issue1864_test;
+
+USE issue1864_test;
+
+create table t1(c1 decimal(5,2)) engine=tianmu;
+insert into t1 values(111.22);
+
+create table t2(id int) engine=tianmu;
+insert into t2 values(11122);
+
+select xxx.x from (select c1 as x from t1 union all select 1 as x from t2) xxx;
+
+select xxx.x from ( select t1.c1 as x from t1 inner join t2 on t1.c1 != t2.id ) xxx;
+
+CREATE TABLE cs1 (d1 DECIMAL(17), d2 DECIMAL(17,10), d3 DECIMAL(17,17)) engine=tianmu;
+
+INSERT INTO cs1 VALUES (125, 1.25, 0.125);
+
+INSERT INTO cs1 VALUES (-125, -1.25, -0.125);
+
+select * from cs1;
+
+select * from cs1 union select * from cs1;
+
+SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1;
+
+DROP DATABASE issue1864_test;
diff --git a/mysql-test/suite/tianmu/t/issue1865.test b/mysql-test/suite/tianmu/t/issue1865.test
new file mode 100644
index 000000000..e308fae22
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue1865.test
@@ -0,0 +1,29 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue1865_test_db;
+--enable_warnings
+
+CREATE DATABASE issue1865_test_db;
+
+USE issue1865_test_db;
+
+create table t1 (a int default 100, b int, c varchar(60))engine=tianmu;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+
+alter table t1 alter column b drop default;
+alter table t1 alter column b set default 10;
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+
+alter table t1 modify c text;
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval load data infile '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue1865.dat' into table t1 (a, c);
+select * from t1;
+
+DROP DATABASE issue1865_test_db;
diff --git a/mysql-test/suite/tianmu/t/issue364.test.bak b/mysql-test/suite/tianmu/t/issue364.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/issue364.test.bak
rename to mysql-test/suite/tianmu/t/issue364.test
diff --git a/mysql-test/suite/tianmu/t/issue433.testbak b/mysql-test/suite/tianmu/t/issue433.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/issue433.testbak
rename to mysql-test/suite/tianmu/t/issue433.test
diff --git a/mysql-test/suite/tianmu/t/issue446.testbak b/mysql-test/suite/tianmu/t/issue446.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/issue446.testbak
rename to mysql-test/suite/tianmu/t/issue446.test
diff --git a/mysql-test/suite/tianmu/t/issue581.test.bak b/mysql-test/suite/tianmu/t/issue581.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/issue581.test.bak
rename to mysql-test/suite/tianmu/t/issue581.test
diff --git a/mysql-test/suite/tianmu/t/issue848-master.opt b/mysql-test/suite/tianmu/t/issue848-master.opt
new file mode 100644
index 000000000..4eb1b974d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/issue848-master.opt
@@ -0,0 +1,2 @@
+--sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+--tianmu_no_key_error=ON
\ No newline at end of file
diff --git a/mysql-test/suite/tianmu/t/issue848.test b/mysql-test/suite/tianmu/t/issue848.test
index 1fb1f3435..0ce3ff1e9 100644
--- a/mysql-test/suite/tianmu/t/issue848.test
+++ b/mysql-test/suite/tianmu/t/issue848.test
@@ -1,26 +1,34 @@
--source include/have_tianmu.inc
-create database test_issue848;
-use test_issue848;
+
+--disable_warnings
+DROP DATABASE IF EXISTS issue848_test;
+--enable_warnings
+
+CREATE DATABASE issue848_test;
+USE issue848_test;
+
CREATE TABLE `t1` (
`c_char` char(10) DEFAULT NULL COMMENT 'char',
`c_varchar` varchar(10) DEFAULT NULL COMMENT 'varchar',
`c_text` text COMMENT 'text')
ENGINE=TIANMU DEFAULT CHARSET=GBK;
+
show create table t1;
insert into t1(c_char,c_varchar,c_text) values(x'D6D0B9FA',x'D5E3BDAD',x'BABCD6DD');
+
ALTER TABLE t1 DEFAULT CHARACTER SET gbk;
show create table t1;
ALTER TABLE t1 CHARACTER SET latin1;
show create table t1;
-alter table t1 add column ex_column char(30);
+ALTER TABLE t1 ADD COLUMN ex_column char(30) AFTER c_text;
show create table t1;
-ALTER TABLE t1 MODIFY c_char char(10) CHARACTER SET UTF8MB4;
-ALTER TABLE t1 MODIFY c_varchar char(10) CHARACTER SET UTF8MB4;
-ALTER TABLE t1 MODIFY c_text char(10) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_char char(15) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_varchar char(15) CHARACTER SET UTF8MB4;
+ALTER TABLE t1 MODIFY c_text char(15) CHARACTER SET UTF8MB4;
show create table t1;
select hex(c_char),hex(c_varchar),hex(c_text) from t1;
@@ -30,5 +38,5 @@ ALTER TABLE t1 CHANGE c_text c_text char(10) CHARACTER SET GBK;
select hex(c_char),hex(c_varchar),hex(c_text) from t1;
show create table t1;
-drop table t1;
-drop database test_issue848;
+DROP TABLE t1;
+DROP DATABASE issue848_test;
diff --git a/mysql-test/suite/tianmu/t/issue880.test b/mysql-test/suite/tianmu/t/issue880.test
index 5eedb88ae..6aaa0972f 100644
--- a/mysql-test/suite/tianmu/t/issue880.test
+++ b/mysql-test/suite/tianmu/t/issue880.test
@@ -121,15 +121,15 @@ CREATE TABLE `issue880_t3` (
--disable_warnings
# load data issue880_t1
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t1.txt' INTO TABLE issue880_t1;
+eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t1.txt' INTO TABLE issue880_t1 FIELDS TERMINATED BY ';';
# load data issue880_t3
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t3.txt' INTO TABLE issue880_t3;
+eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t3.txt' INTO TABLE issue880_t3 FIELDS TERMINATED BY ';';
# load data issue880_t2
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t2.txt' INTO TABLE issue880_t2;
+eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/std_data/issue880_t2.txt' INTO TABLE issue880_t2 FIELDS TERMINATED BY ';';
--enable_warnings
# test timestamp union timestamp
diff --git a/mysql-test/suite/tianmu/t/issue956.test b/mysql-test/suite/tianmu/t/issue956.test
index 9994c8fb7..c596999a2 100644
--- a/mysql-test/suite/tianmu/t/issue956.test
+++ b/mysql-test/suite/tianmu/t/issue956.test
@@ -5,14 +5,14 @@
--enable_warnings
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo # default_storage_engine=innodb
--echo #
--echo [on slave]
--source include/sync_slave_sql_with_master.inc
set global default_storage_engine=innodb;
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
--enable_warnings
--echo [on master]
@@ -41,13 +41,13 @@ drop table t_issue956;
--echo #
---echo # sql_mode='MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo # default_storage_engine=innodb
--echo #
--echo [on slave]
set global default_storage_engine=innodb;
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
--enable_warnings
--echo [on master]
@@ -75,13 +75,13 @@ drop table t_issue956_2;
--source include/sync_slave_sql_with_master.inc
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo # default_storage_engine=tianmu
--echo #
--echo [on slave]
set global default_storage_engine=tianmu;
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
--enable_warnings
--echo [on master]
@@ -110,13 +110,13 @@ drop table t_issue956_3;
--source include/sync_slave_sql_with_master.inc
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU'
+--echo # tianmu_mandatory=ON
--echo # default_storage_engine=tianmu
--echo #
--echo [on slave]
set global default_storage_engine=tianmu;
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,MANDATORY_TIANMU';
+set global tianmu_mandatory=ON;
--enable_warnings
@@ -146,13 +146,13 @@ drop table t_issue956_4;
--source include/sync_slave_sql_with_master.inc
--echo #
---echo # sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'
+--echo # tianmu_mandatory=OFF
--echo # default_storage_engine=MyISAM
--echo #
--echo [on slave]
set global default_storage_engine=MyISAM;
--disable_warnings
-set global sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+set global tianmu_mandatory=OFF;
--enable_warnings
--echo [on master]
diff --git a/mysql-test/suite/tianmu/t/left_right_func.test b/mysql-test/suite/tianmu/t/left_right_func.test
new file mode 100644
index 000000000..31285a018
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/left_right_func.test
@@ -0,0 +1,36 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # left and right func test
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS left_right_func_test;
+--enable_warnings
+
+CREATE DATABASE left_right_func_test;
+USE left_right_func_test;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+CREATE TABLE t1 (`time_tk` INT(11) UNSIGNED NOT NULL) DEFAULT CHARSET=latin1;
+
+INSERT INTO t1 VALUES
+(2013113023),
+(1900010100),
+(2199123100),
+(2199123100),
+(2147483646),
+(2147483647),
+(2147483648);
+
+SELECT LEFT(time_tk,6) AS time_tk_left FROM t1;
+SELECT RIGHT(time_tk,6) AS time_tk_right FROM t1;
+
+DROP TABLE IF EXISTS t1;
+
+# Clean UP
+--disable_warnings
+DROP DATABASE left_right_func_test;
+--enable_warnings
diff --git a/mysql-test/suite/tianmu/t/like_not_like.test b/mysql-test/suite/tianmu/t/like_not_like.test
new file mode 100644
index 000000000..e1dd76904
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/like_not_like.test
@@ -0,0 +1,25 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # This test tests the (NOT) LIKE test in filters that is added
+--echo # to a FilterCommand in primproc.
+--echo # This is a very rare situation, yet somehow I managed to trigger it.
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS like_not_like;
+--enable_warnings
+
+CREATE DATABASE like_not_like;
+USE like_not_like;
+
+CREATE TABLE tcs(d1 CHAR(6), d2 CHAR(6));
+
+INSERT INTO tcs(d1, d2) VALUES ('a','a'), ('a', 'b');
+
+SELECT 'stonedb like', d1, d2 FROM tcs WHERE (d1 LIKE d2);
+
+SELECT 'stonedb not like', d1, d2 FROM tcs WHERE (d1 NOT LIKE d2);
+
+# clean up
+DROP DATABASE like_not_like;
diff --git a/mysql-test/suite/tianmu/t/load.testbak b/mysql-test/suite/tianmu/t/load.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/load.testbak
rename to mysql-test/suite/tianmu/t/load.test
diff --git a/mysql-test/suite/tianmu/t/multi_join.test b/mysql-test/suite/tianmu/t/multi_join.test
new file mode 100644
index 000000000..ec3b5a29a
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/multi_join.test
@@ -0,0 +1,36 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # right join/left join/inner join /full join
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS multi_join_test;
+--enable_warnings
+
+CREATE DATABASE multi_join_test;
+USE multi_join_test;
+
+drop table if exists all_datatype_table;
+create table all_datatype_table(id int not null,c_intger integer,c_char char(10));
+
+insert into all_datatype_table values(1,1000,1000);
+insert into all_datatype_table values(2,2000,1000);
+insert into all_datatype_table values(3,2001,null);
+insert into all_datatype_table values(4,2002,'a');
+
+select count(*) from all_datatype_table t1 right join all_datatype_table t2 on t1.id=t2.id
+inner join all_datatype_table t3 on t1.id=t3.id
+right join all_datatype_table t4 on t1.id=t4.id
+left join all_datatype_table t5 on t1.id=t5.id
+inner join all_datatype_table t6 on t1.id=t6.id
+left join all_datatype_table t7 on t1.id=t7.id
+right join all_datatype_table t8 on t1.id=t8.id
+right join all_datatype_table t10 on t1.id=t10.id
+right join all_datatype_table t11 on t1.id=t11.id
+right join all_datatype_table t13 on t1.id=t13.id
+right join all_datatype_table t15 on t1.id=t15.id
+right join all_datatype_table t16 on t1.id=t16.id;
+
+# Clean UP
+drop DATABASE multi_join_test;
diff --git a/mysql-test/suite/tianmu/t/order_by.test b/mysql-test/suite/tianmu/t/order_by.test
new file mode 100644
index 000000000..b4aa05f2d
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/order_by.test
@@ -0,0 +1,28 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS order_by;
+--enable_warnings
+
+CREATE DATABASE order_by;
+USE order_by;
+
+create table t1 (a int, b int) ;
+create table t2 (a int, b int) ;
+
+insert into t1 values (1, 2), (1, 3), (1, 4), (2, 5), (2, 6), (2, 7);
+insert into t2 values (1, 2), (1, 2), (1, 4), (2, 5), (2, 6), (2, 8);
+
+select * from t1, t2 where t1.a = t2.a and t2.b = (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+select * from t1, t2 where t1.a = t2.a and t2.b < (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+select * from t1, t2 where t1.a = t2.a and t2.b > (select max(b) from t2 where t1.a = t2.a) order by t1.a,t1.b,t2.b;
+
+select * from t1, t2 where t1.a = t2.a and t1.b = (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t2.b;
+select * from t1, t2 where t1.a = t2.a and t2.b < (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t1.a,t1.b,t2.b;
+select * from t1, t2 where t1.a = t2.a and t2.b > (select avg(t2.b) from t2 where t1.a = t2.a group by t2.a) order by t1.a,t1.b,t2.b;
+
+drop table t1;
+drop table t2;
+
+#clean up
+DROP DATABASE order_by;
diff --git a/mysql-test/suite/tianmu/t/range.test b/mysql-test/suite/tianmu/t/range.test
new file mode 100644
index 000000000..4bbcef53b
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/range.test
@@ -0,0 +1,971 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # Test range
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS range_test;
+--enable_warnings
+CREATE DATABASE range_test;
+USE range_test;
+
+--disable_warnings
+drop table if exists t1, t2, t3;
+--enable_warnings
+SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
+CREATE TABLE t1 (
+ event_date date DEFAULT '0000-00-00' NOT NULL,
+ type int(11) DEFAULT '0' NOT NULL,
+ event_id int(11) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (event_date,type,event_id)
+);
+
+INSERT INTO t1 VALUES ('1999-07-10',100100,24), ('1999-07-11',100100,25),
+('1999-07-13',100600,0), ('1999-07-13',100600,4), ('1999-07-13',100600,26),
+('1999-07-14',100600,10), ('1999-07-15',100600,16), ('1999-07-15',100800,45),
+('1999-07-15',101000,47), ('1999-07-16',100800,46), ('1999-07-20',100600,5),
+('1999-07-20',100600,27), ('1999-07-21',100600,11), ('1999-07-22',100600,17),
+('1999-07-23',100100,39), ('1999-07-24',100100,39), ('1999-07-24',100500,40),
+('1999-07-25',100100,39), ('1999-07-27',100600,1), ('1999-07-27',100600,6),
+('1999-07-27',100600,28), ('1999-07-28',100600,12), ('1999-07-29',100500,41),
+('1999-07-29',100600,18), ('1999-07-30',100500,41), ('1999-07-31',100500,41),
+('1999-08-01',100700,34), ('1999-08-03',100600,7), ('1999-08-03',100600,29),
+('1999-08-04',100600,13), ('1999-08-05',100500,42), ('1999-08-05',100600,19),
+('1999-08-06',100500,42), ('1999-08-07',100500,42), ('1999-08-08',100500,42),
+('1999-08-10',100600,2), ('1999-08-10',100600,9), ('1999-08-10',100600,30),
+('1999-08-11',100600,14), ('1999-08-12',100600,20), ('1999-08-17',100500,8),
+('1999-08-17',100600,31), ('1999-08-18',100600,15), ('1999-08-19',100600,22),
+('1999-08-24',100600,3), ('1999-08-24',100600,32), ('1999-08-27',100500,43),
+('1999-08-31',100600,33), ('1999-09-17',100100,37), ('1999-09-18',100100,37),
+('1999-09-19',100100,37), ('2000-12-18',100700,38);
+
+select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
+explain select event_date,type,event_id from t1 WHERE type = 100601 and event_date >= "1999-07-01" AND event_date < "1999-07-15" AND (type=100600 OR type=100100) ORDER BY event_date;
+select event_date,type,event_id from t1 WHERE event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND (type=100600 OR type=100100) or event_date >= "1999-07-01" AND event_date <= "1999-07-15" AND type=100099;
+drop table t1;
+
+CREATE TABLE t1 (
+ PAPER_ID smallint(6) DEFAULT '0' NOT NULL,
+ YEAR smallint(6) DEFAULT '0' NOT NULL,
+ ISSUE smallint(6) DEFAULT '0' NOT NULL,
+ CLOSED tinyint(4) DEFAULT '0' NOT NULL,
+ ISS_DATE date DEFAULT '0000-00-00' NOT NULL,
+ PRIMARY KEY (PAPER_ID,YEAR,ISSUE)
+);
+INSERT INTO t1 VALUES (3,1999,34,0,'1999-07-12'), (1,1999,111,0,'1999-03-23'),
+ (1,1999,222,0,'1999-03-23'), (3,1999,33,0,'1999-07-12'),
+ (3,1999,32,0,'1999-07-12'), (3,1999,31,0,'1999-07-12'),
+ (3,1999,30,0,'1999-07-12'), (3,1999,29,0,'1999-07-12'),
+ (3,1999,28,0,'1999-07-12'), (1,1999,40,1,'1999-05-01'),
+ (1,1999,41,1,'1999-05-01'), (1,1999,42,1,'1999-05-01'),
+ (1,1999,46,1,'1999-05-01'), (1,1999,47,1,'1999-05-01'),
+ (1,1999,48,1,'1999-05-01'), (1,1999,49,1,'1999-05-01'),
+ (1,1999,50,0,'1999-05-01'), (1,1999,51,0,'1999-05-01'),
+ (1,1999,200,0,'1999-06-28'), (1,1999,52,0,'1999-06-28'),
+ (1,1999,53,0,'1999-06-28'), (1,1999,54,0,'1999-06-28'),
+ (1,1999,55,0,'1999-06-28'), (1,1999,56,0,'1999-07-01'),
+ (1,1999,57,0,'1999-07-01'), (1,1999,58,0,'1999-07-01'),
+ (1,1999,59,0,'1999-07-01'), (1,1999,60,0,'1999-07-01'),
+ (3,1999,35,0,'1999-07-12');
+select YEAR,ISSUE from t1 where PAPER_ID=3 and (YEAR>1999 or (YEAR=1999 and ISSUE>28)) order by YEAR,ISSUE;
+drop table t1;
+
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ parent_id int(11) DEFAULT '0' NOT NULL,
+ level tinyint(4) DEFAULT '0' NOT NULL,
+ PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES (1,0,0), (3,1,1), (4,1,1), (8,2,2), (9,2,2), (17,3,2),
+(22,4,2), (24,4,2), (28,5,2), (29,5,2), (30,5,2), (31,6,2), (32,6,2), (33,6,2),
+(203,7,2), (202,7,2), (20,3,2), (157,0,0), (193,5,2), (40,7,2), (2,1,1),
+(15,2,2), (6,1,1), (34,6,2), (35,6,2), (16,3,2), (7,1,1), (36,7,2), (18,3,2),
+(26,5,2), (27,5,2), (183,4,2), (38,7,2), (25,5,2), (37,7,2), (21,4,2),
+(19,3,2), (5,1,1), (179,5,2);
+# The following select returned 0 rows in 3.23.8
+SELECT * FROM t1 WHERE level = 1 AND parent_id = 1 order by id;
+drop table t1;
+
+#
+# Testing of bug in range optimizer with many key parts and > and <
+#
+
+create table t1(
+ Satellite varchar(25) not null,
+ SensorMode varchar(25) not null,
+ FullImageCornersUpperLeftLongitude double not null,
+ FullImageCornersUpperRightLongitude double not null,
+ FullImageCornersUpperRightLatitude double not null,
+ FullImageCornersLowerRightLatitude double not null);
+
+insert into t1 values("OV-3","PAN1",91,-92,40,50);
+insert into t1 values("OV-4","PAN1",91,-92,40,50);
+
+select * from t1 where t1.Satellite = "OV-3" and t1.SensorMode = "PAN1" and t1.FullImageCornersUpperLeftLongitude > -90.000000 and t1.FullImageCornersUpperRightLongitude < -82.000000;
+drop table t1;
+
+create table t1 ( aString char(100) not null default "");
+insert t1 (aString) values ( "believe in myself" ), ( "believe" ), ("baaa" ), ( "believe in love");
+select * from t1 where aString < "believe in myself" order by aString;
+select * from t1 where aString > "believe in love" order by aString;
+select * from t1 where aString < "believe in myself" order by aString;
+select * from t1 where aString > "believe in love" order by aString;
+drop table t1;
+
+#
+# test for a bug with in() and unique key
+#
+
+create table t1 (id int(10) primary key);
+insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+select id from t1 where id in (2,5,9) ;
+select id from t1 where id=2 or id=5 or id=9 ;
+drop table t1;
+create table t1 ( id1 int not null, id2 int not null, idnull int null, c char(20), primary key (id1,id2));
+insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"),
+ (3,1,NULL,"aaa"), (4,1,NULL,"aaa"), (5,1,NULL,"aaa"),
+ (6,1,NULL,"aaa"), (7,1,NULL,"aaa"), (8,1,NULL,"aaa"),
+ (9,1,NULL,"aaa"), (10,1,NULL,"aaa"), (11,1,NULL,"aaa"),
+ (12,1,NULL,"aaa"), (13,1,NULL,"aaa"), (14,1,NULL,"aaa"),
+ (15,1,NULL,"aaa"), (16,1,NULL,"aaa"), (17,1,NULL,"aaa"),
+ (18,1,NULL,"aaa"), (19,1,NULL,"aaa"), (20,1,NULL,"aaa");
+select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1;
+drop table t1;
+
+
+#
+# Problem with optimizing !=
+#
+
+create table t1 (
+ id int not null auto_increment,
+ name char(1) not null,
+ uid int not null,
+ primary key (id));
+
+create table t2 (
+ id int not null auto_increment,
+ name char(1) not null,
+ uid int not null,
+ primary key (id));
+
+insert into t1(id, uid, name) values(1, 0, ' ');
+insert into t1(uid, name) values(0, ' ');
+
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t2(uid, name) select uid, name from t1;
+insert into t1(uid, name) select uid, name from t2;
+#bug1563select * from t1 order by id;
+#bug1563select * from t2 order by id;
+
+delete from t2;
+insert into t2(uid, name) values
+ (1, CHAR(64+1)),
+ (2, CHAR(64+2)),
+ (3, CHAR(64+3)),
+ (4, CHAR(64+4)),
+ (5, CHAR(64+5)),
+ (6, CHAR(64+6)),
+ (7, CHAR(64+7)),
+ (8, CHAR(64+8)),
+ (9, CHAR(64+9)),
+ (10, CHAR(64+10)),
+ (11, CHAR(64+11)),
+ (12, CHAR(64+12)),
+ (13, CHAR(64+13)),
+ (14, CHAR(64+14)),
+ (15, CHAR(64+15)),
+ (16, CHAR(64+16)),
+ (17, CHAR(64+17)),
+ (18, CHAR(64+18)),
+ (19, CHAR(64+19)),
+ (20, CHAR(64+20)),
+ (21, CHAR(64+21)),
+ (22, CHAR(64+22)),
+ (23, CHAR(64+23)),
+ (24, CHAR(64+24)),
+ (25, CHAR(64+25)),
+ (26, CHAR(64+26));
+
+insert into t1(uid, name) select uid, name from t2 order by uid;
+delete from t1;
+delete from t2;
+insert into t2(id, uid, name) select id, uid, name from t1;
+
+select count(*) from t1;
+select count(*) from t2;
+
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0;
+select * from t1, t2 where t1.uid=t2.uid AND t2.uid > 0;
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0;
+select * from t1, t2 where t1.uid=t2.uid AND t2.uid != 0;
+
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid > 0 order by t1.id;
+select * from t1, t2 where t1.uid=t2.uid AND t1.uid != 0 order by t1.id;
+
+drop table t1,t2;
+
+create table t1 (x bigint unsigned not null);
+insert into t1(x) values (0xfffffffffffff0);
+insert into t1(x) values (0xfffffffffffff1);
+select * from t1;
+select count(*) from t1 where x>0;
+select count(*) from t1 where x=0;
+select count(*) from t1 where x<0;
+select count(*) from t1 where x < -16;
+select count(*) from t1 where x = -16;
+select count(*) from t1 where x > -16;
+select count(*) from t1 where x = 18446744073709551601;
+
+
+create table t2 (x bigint not null);
+insert into t2(x) values (-16);
+insert into t2(x) values (-15);
+select * from t2;
+select count(*) from t2 where x>0;
+select count(*) from t2 where x=0;
+select count(*) from t2 where x<0;
+select count(*) from t2 where x < -16;
+select count(*) from t2 where x = -16;
+select count(*) from t2 where x > -16;
+#bug1564select count(*) from t2 where x = 18446744073709551601;
+drop table t1,t2;
+
+--disable_warnings
+create table t1 (x bigint unsigned not null primary key) engine=innodb;
+--enable_warnings
+insert into t1(x) values (0xfffffffffffff0);
+insert into t1(x) values (0xfffffffffffff1);
+select * from t1;
+select count(*) from t1 where x>0;
+select count(*) from t1 where x=0;
+select count(*) from t1 where x<0;
+select count(*) from t1 where x < -16;
+select count(*) from t1 where x = -16;
+select count(*) from t1 where x > -16;
+select count(*) from t1 where x = 18446744073709551601;
+
+drop table t1;
+
+#
+# Bug #11185 incorrect comparison of unsigned int to signed constant
+#
+create table t1 (a bigint unsigned);
+insert into t1 select 184467440737095515;
+insert into t1 select 184467440737095514;
+
+select * from t1 where a <> -1;
+select * from t1 where a > -1 or a < -1;
+select * from t1 where a > -1;
+select * from t1 where a < -1;
+
+drop table t1;
+
+#
+# Binary Comparison regression in MySQL 4.1
+# Binary searches didnt use a case insensitive index.
+#
+
+set names latin1;
+create table t1 (a char(10), b text) character set latin1;
+INSERT INTO t1 (a) VALUES
+('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb');
+drop table t1;
+
+--disable_warnings
+CREATE TABLE t1 (
+ `CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000',
+ `ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '',
+ `ARG2` char(3) character set latin1 collate latin1_bin NOT NULL default '',
+ `FUNCTION` varchar(10) character set latin1 collate latin1_bin NOT NULL default '',
+ `FUNCTINT` int(11) NOT NULL default '0'
+) DEFAULT CHARSET=latin1;
+--enable_warnings
+
+INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0),
+ ('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0),
+ ('001',' 3',' 0','Text 017',0);
+
+SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2');
+
+SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1');
+drop table t1;
+
+# Wrong range optimizer results, "Use_count: Wrong count ..."
+# warnings in server stderr.
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+CREATE TABLE t2 (
+ pk1 int(11) NOT NULL,
+ pk2 int(11) NOT NULL,
+ pk3 int(11) NOT NULL,
+ pk4 int(11) NOT NULL,
+ filler char(82),
+ PRIMARY KEY (pk1,pk2,pk3,pk4)
+) DEFAULT CHARSET=latin1;
+
+insert into t2 select 1, A.a+10*B.a, 432, 44, 'fillerZ' from t1 A, t1 B;
+INSERT INTO t2 VALUES (2621, 2635, 0, 0,'filler'), (2621, 2635, 1, 0,'filler'),
+ (2621, 2635, 10, 0,'filler'), (2621, 2635, 11, 0,'filler'),
+ (2621, 2635, 14, 0,'filler'), (2621, 2635, 1000015, 0,'filler');
+
+SELECT * FROM t2
+WHERE ((((pk4 =0) AND (pk1 =2621) AND (pk2 =2635)))
+OR ((pk4 =1) AND (((pk1 IN ( 7, 2, 1 ))) OR (pk1 =522)) AND ((pk2 IN ( 0, 2635))))
+) AND (pk3 >=1000000);
+drop table t1, t2;
+
+#
+# Partial index and long sjis search with '>' fails sometimes
+#
+
+create table t1(a char(2));
+insert into t1 values ('x'), ('xx');
+select a from t1 where a > 'x';
+drop table t1;
+
+# high mem usage (crash) in range optimizer (depends on order of fields in where)
+create table t1 (
+ c1 char(10), c2 char(10), c3 char(10), c4 char(10),
+ c5 char(10), c6 char(10), c7 char(10), c8 char(10),
+ c9 char(10), c10 char(10), c11 char(10), c12 char(10),
+ c13 char(10), c14 char(10), c15 char(10), c16 char(10)
+);
+insert into t1 (c1) values ('1'),('1'),('1'),('1');
+
+# This must run without crash and fast:
+select * from t1 where
+ c1 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c2 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c3 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c4 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c5 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c6 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c7 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c8 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c9 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC")
+ and c10 in ("abcdefgh", "123456789", "qwertyuio", "asddfgh",
+ "abcdefg1", "123456781", "qwertyui1", "asddfg1",
+ "abcdefg2", "123456782", "qwertyui2", "asddfg2",
+ "abcdefg3", "123456783", "qwertyui3", "asddfg3",
+ "abcdefg4", "123456784", "qwertyui4", "asddfg4",
+ "abcdefg5", "123456785", "qwertyui5", "asddfg5",
+ "abcdefg6", "123456786", "qwertyui6", "asddfg6",
+ "abcdefg7", "123456787", "qwertyui7", "asddfg7",
+ "abcdefg8", "123456788", "qwertyui8", "asddfg8",
+ "abcdefg9", "123456789", "qwertyui9", "asddfg9",
+ "abcdefgA", "12345678A", "qwertyuiA", "asddfgA",
+ "abcdefgB", "12345678B", "qwertyuiB", "asddfgB",
+ "abcdefgC", "12345678C", "qwertyuiC", "asddfgC");
+drop table t1;
+
+#
+# Test for optimization request: to use keys for
+# NOT IN (c1,...,cn) and NOT BETWEEN c1 AND c2
+#
+
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ status varchar(20),
+ PRIMARY KEY (id)
+);
+
+INSERT INTO t1 VALUES
+(1,'B'), (2,'B'), (3,'B'), (4,'B'), (5,'B'), (6,'B'),
+(7,'B'), (8,'B'), (9,'B'), (10,'B'), (11,'B'), (12,'B'),
+(13,'B'), (14,'B'), (15,'B'), (16,'B'), (17,'B'), (18,'B'),
+(19,'B'), (20,'B'), (21,'B'), (22,'B'), (23,'B'), (24,'B'),
+(25,'A'), (26,'A'), (27,'A'), (28,'A'), (29,'A'), (30,'A'),
+(31,'A'), (32,'A'), (33,'A'), (34,'A'), (35,'A'), (36,'A'),
+(37,'A'), (38,'A'), (39,'A'), (40,'A'), (41,'A'), (42,'A'),
+(43,'A'), (44,'A'), (45,'A'), (46,'A'), (47,'A'), (48,'A'),
+(49,'A'), (50,'A'), (51,'A'), (52,'A'), (53,'C'), (54,'C'),
+(55,'C'), (56,'C'), (57,'C'), (58,'C'), (59,'C'), (60,'C');
+
+SELECT * FROM t1 WHERE status <> 'A' AND status <> 'B';
+SELECT * FROM t1 WHERE status NOT IN ('A','B');
+SELECT * FROM t1 WHERE status NOT BETWEEN 'A' AND 'B';
+SELECT * FROM t1 WHERE status < 'A' OR status > 'B';
+
+DROP TABLE t1;
+
+#
+# Test for range to be used over a view
+#
+
+CREATE TABLE t1 (a int, b int, primary key(a,b));
+
+INSERT INTO t1 VALUES
+ (1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3),(4,1),(4,2),(4,3);
+
+CREATE VIEW v1 as SELECT a,b FROM t1 WHERE b=3;
+
+SELECT a,b FROM t1 WHERE a < 2 and b=3;
+SELECT a,b FROM v1 WHERE a < 2 and b=3;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+#
+# DELETE statement with a NOT (LIKE/<=>) where condition
+# for an indexed attribute
+#
+
+CREATE TABLE t1 (name varchar(15) NOT NULL);
+INSERT INTO t1 VALUES ('Betty'), ('Anna');
+
+SELECT * FROM t1;
+DELETE FROM t1 WHERE name NOT LIKE 'A%a';
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (NULL), (1), (2), (3);
+
+SELECT * FROM t1;
+DELETE FROM t1 WHERE NOT(a <=> 2);
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+#
+# BUG#13317: range optimization doesnt work for IN over VIEW.
+#
+create table t1 (a int, b int, primary key(a,b));
+create view v1 as select a, b from t1;
+
+INSERT INTO `t1` VALUES
+(0,0),(1,0),(2,0),(3,0),(4,0),(5,1),(6,1),(7,1),(8,1),(9,1),(10,2),(11,2),(12,2)
+,(13,2),(14,2),(15,3),(16,3),(17,3),(18,3),(19,3);
+
+drop view v1;
+drop table t1;
+
+# BUG#13455:
+create table t3 (a int);
+insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t1 (a varchar(10), filler char(200)) charset=binary;
+insert into t1 values ('a','');
+insert into t1 values ('a ','');
+insert into t1 values ('a ', '');
+insert into t1 select concat('a', 1000 + A.a + 10 * (B.a + 10 * C.a)), ''
+ from t3 A, t3 B, t3 C;
+
+create table t2 (a varchar(10), filler char(200));
+insert into t2 select * from t1;
+
+update t1 set a='b' where a<>'a';
+select a, hex(filler) from t1 where a not between 'b' and 'b';
+drop table t1,t2,t3;
+
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int);
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+set @a=concat(@a, ')');
+
+insert into t2 values (11),(13),(15);
+drop table t1, t2;
+
+#
+# range access for BETWEEN with a constant for the first argument
+#
+
+CREATE TABLE t1 (
+ id int NOT NULL DEFAULT '0',
+ b int NOT NULL DEFAULT '0',
+ c int NOT NULL DEFAULT '0');
+
+INSERT INTO t1(id) VALUES (1), (2), (3), (4), (5), (6), (7), (8);
+
+INSERT INTO t1(b,c) VALUES (3,4), (3,4);
+
+SELECT * FROM t1 WHERE b<=3 AND 3<=c;
+SELECT * FROM t1 WHERE 3 BETWEEN b AND c;
+
+SELECT * FROM t1 WHERE 0 < b OR 0 > c;
+SELECT * FROM t1 WHERE 0 NOT BETWEEN b AND c;
+
+DROP TABLE t1;
+
+--echo
+--echo "Comparison of DATE with DATETIME still not using indexes correctly"
+--echo
+CREATE TABLE t1 (
+ id int(11) NOT NULL auto_increment,
+ dateval date default NULL,
+ PRIMARY KEY (id)
+) AUTO_INCREMENT=173;
+
+INSERT INTO t1 VALUES
+(1,'2007-01-01'),(2,'2007-01-02'),(3,'2007-01-03'),(4,'2007-01-04'),
+(5,'2007-01-05'),(6,'2007-01-06'),(7,'2007-01-07'),(8,'2007-01-08'),
+(9,'2007-01-09'),(10,'2007-01-10'),(11,'2007-01-11');
+drop table t1;
+
+#
+# different or-ed predicates were erroneously merged into one that
+# resulted in ref access instead of range access and a wrong result set
+#
+
+CREATE TABLE t1 (
+ a varchar(32)
+) DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+
+INSERT INTO t1 VALUES
+ ('B'), ('A'), ('A'), ('C'), ('B'), ('A'), ('A');
+
+SELECT a FROM t1 WHERE a='b' OR a='B';
+DROP TABLE t1;
+
+#
+#highest possible value for INT erroneously filtered by WHERE
+#
+
+# test UNSIGNED. only occurs when indexed.
+CREATE TABLE t1 (f1 TINYINT(11) UNSIGNED NOT NULL, PRIMARY KEY (f1));
+
+INSERT INTO t1 VALUES (127),(254),(0),(1),(255);
+
+--disable_ps_protocol
+
+# test upper bound
+# count 5
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256;
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 256.0;
+# count 4
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 255;
+
+# show we dont fiddle with lower bound on UNSIGNED
+# count 0
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < -1;
+# count 5
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -1;
+
+DROP TABLE t1;
+
+
+# test signed. only occurs when index.
+CREATE TABLE t1 ( f1 TINYINT(11) NOT NULL, PRIMARY KEY (f1));
+
+INSERT INTO t1 VALUES (127),(126),(0),(-128),(-127);
+
+# test upper bound
+# count 5
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128;
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 128.0;
+# count 4
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 < 127;
+
+# test lower bound
+# count 5
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129;
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -129.0;
+# count 4
+SELECT SQL_NO_CACHE COUNT(*) FROM t1 WHERE f1 > -128;
+
+--enable_ps_protocol
+
+DROP TABLE t1;
+
+# End of 5.0 tests
+
+# Adjust 'ref' estimate if we have 'range' estimate for
+# a smaller scan interval
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2 (a int, b int, filler char(100));
+insert into t2 select A.a + 10 * (B.a + 10 * C.a), 10, 'filler' from t1 A,
+t1 B, t1 C where A.a < 5;
+
+insert into t2 select 1000, b, 'filler' from t2;
+
+drop table t1, t2;
+
+#
+# wrong result returned for range scan when using covering index
+#
+CREATE TABLE t1( a INT, b INT);
+
+CREATE TABLE t2( a INT, b INT );
+
+CREATE TABLE t3( a INT, b INT );
+
+INSERT INTO t1( a, b )
+VALUES (0, 1), (1, 2), (1, 4), (2, 3), (5, 0), (9, 7);
+
+INSERT INTO t2( a, b )
+VALUES ( 1, 1), ( 2, 1), ( 3, 1), ( 4, 1), ( 5, 1),
+ ( 6, 1), ( 7, 1), ( 8, 1), ( 9, 1), (10, 1),
+ (11, 1), (12, 1), (13, 1), (14, 1), (15, 1),
+ (16, 1), (17, 1), (18, 1), (19, 1), (20, 1);
+
+INSERT INTO t2 SELECT a, 2 FROM t2 WHERE b = 1;
+INSERT INTO t2 SELECT a, 3 FROM t2 WHERE b = 1;
+
+# To make range scan compelling to the optimizer
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+INSERT INTO t2 SELECT -1, -1 FROM t2;
+
+INSERT INTO t3
+VALUES (1, 0), (2, 0), (3, 0), (4, 0), (5, 0),
+ (6, 0), (7, 0), (8, 0), (9, 0), (10, 0);
+
+# To make range scan compelling to the optimizer
+INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
+INSERT INTO t3 SELECT * FROM t3 WHERE a = 10;
+
+
+#
+# Problem#1 Test queries. Will give missing results unless Problem#1 is fixed.
+# With one exception, they are independent of Problem#2.
+#
+SELECT * FROM t1 WHERE
+3 <= a AND a < 5 OR
+5 < a AND b = 3 OR
+3 <= a;
+
+#
+# Problem#2 Test queries.
+# These queries will give missing results if Problem#1 is fixed.
+# But Problem#1 also hides this bug.
+#
+SELECT * FROM t2 WHERE
+5 <= a AND a < 10 AND b = 1 OR
+15 <= a AND a < 20 AND b = 3
+OR
+1 <= a AND b = 1;
+
+SELECT * FROM t2 WHERE
+5 <= a AND a < 10 AND b = 2 OR
+15 <= a AND a < 20 AND b = 3
+OR
+1 <= a AND b = 1;
+
+
+SELECT * FROM t3 WHERE
+5 <= a AND a < 10 AND b = 3 OR
+a < 5 OR
+a < 10;
+
+DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # Endless 100% CPU loop with STRAIGHT_JOIN
+--echo #
+
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1), (NULL);
+SELECT * FROM t1 WHERE a <> NULL and (a <> NULL or a <= NULL);
+DROP TABLE t1;
+
+--echo #
+--echo # regression of range optimizer and date comparison in 5.1.39!
+--echo #
+CREATE TABLE t1 ( a DATE );
+CREATE TABLE t2 ( a DATETIME);
+
+--echo # Make optimizer choose range scan
+INSERT INTO t1 VALUES ('2009-09-22'), ('2009-09-22'), ('2009-09-22');
+INSERT INTO t1 VALUES ('2009-09-23'), ('2009-09-23'), ('2009-09-23');
+
+INSERT INTO t2 VALUES ('2009-09-22 12:00:00'), ('2009-09-22 12:00:00'),
+ ('2009-09-22 12:00:00');
+INSERT INTO t2 VALUES ('2009-09-23 12:00:00'), ('2009-09-23 12:00:00'),
+ ('2009-09-23 12:00:00');
+
+--echo # DATE vs DATE
+SELECT * FROM t1 WHERE a >= '2009/09/23';
+SELECT * FROM t1 WHERE a >= '20090923';
+#bug1567SELECT * FROM t1 WHERE a >= 20090923;
+SELECT * FROM t1 WHERE a >= '2009-9-23';
+SELECT * FROM t1 WHERE a >= '2009.09.23';
+SELECT * FROM t1 WHERE a >= '2009:09:23';
+
+--echo # DATE vs DATETIME
+SELECT * FROM t2 WHERE a >= '2009/09/23';
+SELECT * FROM t2 WHERE a >= '20090923';
+#SELECT * FROM t2 WHERE a >= 20090923;
+SELECT * FROM t2 WHERE a >= '2009-9-23';
+SELECT * FROM t2 WHERE a >= '2009.09.23';
+SELECT * FROM t2 WHERE a >= '2009:09:23';
+
+--echo # DATETIME vs DATETIME
+SELECT * FROM t2 WHERE a >= '2009/09/23 12:00:00';
+SELECT * FROM t2 WHERE a >= '20090923120000';
+#SELECT * FROM t2 WHERE a >= 20090923120000;
+SELECT * FROM t2 WHERE a >= '2009-9-23 12:00:00';
+SELECT * FROM t2 WHERE a >= '2009.09.23 12:00:00';
+SELECT * FROM t2 WHERE a >= '2009:09:23 12:00:00';
+
+--echo # DATETIME vs DATE
+SELECT * FROM t1 WHERE a >= '2009/09/23 00:00:00';
+SELECT * FROM t1 WHERE a >= '20090923000000';
+#SELECT * FROM t1 WHERE a >= 20090923000000;
+SELECT * FROM t1 WHERE a >= '2009-9-23 00:00:00';
+SELECT * FROM t1 WHERE a >= '2009.09.23 00:00:00';
+SELECT * FROM t1 WHERE a >= '2009:09:23 00:00:00';
+
+--echo # Test of the new get_date_from_str implementation
+--echo # Behavior differs slightly between the trunk and mysql-pe.
+--echo # The former may give errors for the truncated values, while the latter
+--echo # gives warnings. The purpose of this test is not to interfere, and only
+--echo # preserve existing behavior.
+SELECT str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
+ str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20';
+
+SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
+ str_to_date('2007-20-00', '%Y-%m-%d') <= '';
+
+SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
+SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
+
+SELECT str_to_date('', '%Y-%m-%d');
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # valgrind errors with query using 'Range checked for each
+--echo # record'
+--echo #
+CREATE TABLE t1 (
+ a INT,
+ b CHAR(2),
+ c INT,
+ d INT
+);
+
+INSERT INTO t1 VALUES ( NULL, 'a', 1, 2 ), ( NULL, 'a', 1, 2 ),
+ ( 1, 'a', 1, 2 ), ( 1, 'a', 1, 2 );
+
+CREATE TABLE t2 (
+ a INT,
+ c INT,
+ e INT
+);
+
+INSERT INTO t2 VALUES ( 1, 1, NULL ), ( 1, 1, NULL );
+
+--echo # Should not give Valgrind warnings
+SELECT 1
+FROM t1, t2
+WHERE t1.d <> '1' AND t1.b > '1'
+AND t1.a = t2.a AND t1.c = t2.c;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # sql-bench's insert test fails due to wrong result
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a));
+
+INSERT INTO t1 VALUES (0,0), (1,1);
+
+DROP TABLE t1;
+
+--echo #
+--echo # 'NOT BETWEEN' evaluation is incorrect
+--echo #
+
+CREATE TABLE t1 (c_key INT, c_notkey INT);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3);
+SELECT * FROM t1 WHERE 2 NOT BETWEEN c_notkey AND c_key;
+
+DROP TABLE t1;
+
+--echo #
+--echo # 'BETWEEN' evaluation is incorrect
+--echo #
+
+# Test some BETWEEN predicates which does *not* follow the
+# 'normal' pattern of BETWEEN AND
+
+CREATE TABLE t1(pk INT PRIMARY KEY, i4 INT);
+
+INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
+
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 10;
+
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND i4;
+
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND i4;
+
+SELECT * FROM t1 WHERE 10 BETWEEN i4 AND 10;
+
+SELECT * FROM t1 WHERE 10 BETWEEN 10 AND 10;
+
+SELECT * FROM t1 WHERE 10 BETWEEN 11 AND 11;
+
+SELECT * FROM t1 WHERE 10 BETWEEN 100 AND 0;
+
+SELECT * FROM t1 WHERE i4 BETWEEN 100 AND 0;
+
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND 99999999999999999;
+
+SELECT * FROM t1 WHERE i4 BETWEEN 999999999999999 AND 30;
+
+SELECT * FROM t1 WHERE i4 BETWEEN 10 AND '20';
+
+SELECT * FROM t1, t1 as t2 WHERE t2.pk BETWEEN t1.i4 AND t1.i4;
+
+SELECT * FROM t1, t1 as t2 WHERE t1.i4 BETWEEN t2.pk AND t2.pk;
+
+DROP TABLE t1;
+
+--echo #
+--echo # SELECT RESULTS VARY WITH VERSION AND
+--echo # WITH/WITHOUT INDEX RANGE SCAN
+--echo #
+
+create table t1 (id int unsigned not null auto_increment primary key);
+insert into t1 values (null);
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+insert into t1 select null from t1;
+create table t2 (
+ id int unsigned not null auto_increment,
+ val decimal(5,3) not null,
+ primary key (id,val));
+--disable_warnings
+insert into t2 select null,id*0.0009 from t1;
+--enable_warnings
+#bug1563select * from t2 order by id;
+
+#clean up
+drop database range_test;
diff --git a/mysql-test/suite/tianmu/t/ssb_small.test b/mysql-test/suite/tianmu/t/ssb_small.test
new file mode 100644
index 000000000..71f12441f
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/ssb_small.test
@@ -0,0 +1,96 @@
+--source include/have_tianmu.inc
+
+--disable_warnings
+DROP DATABASE IF EXISTS ssb_small_test;
+--enable_warnings
+
+CREATE DATABASE ssb_small_test;
+USE ssb_small_test;
+
+
+create table part (
+ p_partkey int,
+ p_name varchar (55),
+ p_mfgr char (25),
+ p_brand char (10),
+ p_type varchar (25),
+ p_size int,
+ p_container char (10),
+ p_retailprice decimal(12,2),
+ p_comment varchar (23)
+);
+
+create table lineitem (
+ l_orderkey int,
+ l_partkey int,
+ l_suppkey int,
+ l_linenumber bigint,
+ l_quantity decimal(12,2),
+ l_extendedprice decimal(12,2),
+ l_discount decimal(12,2),
+ l_tax decimal(12,2),
+ l_returnflag char (1),
+ l_linestatus char (1),
+ l_shipdate date,
+ l_commitdate date,
+ l_receiptdate date,
+ l_shipinstruct char (25),
+ l_shipmode char (10),
+ l_comment varchar (44)
+);
+
+INSERT INTO part VALUES
+(1, 'goldenrod lavender spring chocolate lace', 'Manufacturer#1', 'Brand#13', 'PROMO BURNISHED COPPER', 7, 'JUMBO PKG', 901.00, 'ly. slyly ironi'),
+(2, 'blush thistle blue yellow saddle', 'Manufacturer#1', 'Brand#13', 'LARGE BRUSHED BRASS', 1, 'LG CASE', 902.00, 'lar accounts amo'),
+(3, 'spring green yellow purple cornsilk', 'Manufacturer#4', 'Brand#42', 'STANDARD POLISHED BRASS', 21, 'WRAP CASE', 903.00, 'egular deposits hag'),
+(4, 'cornflower chocolate smoke green pink', 'Manufacturer#3', 'Brand#34', 'SMALL PLATED BRASS', 14, 'MED DRUM', 904.00, 'p furiously r'),
+(5, 'forest brown coral puff cream', 'Manufacturer#3', 'Brand#32', 'STANDARD POLISHED TIN', 15, 'SM PKG', 905.00, 'wake carefully');
+
+INSERT INTO lineitem VALUES
+(1, 156, 4, 1, 17, 17954.55, 0.04, 0.02, 'N', 'O', '1996-03-13', '1996-02-12', '1996-03-22', 'DELIVER IN PERSON', 'TRUCK', 'egular courts above the'),
+(1, 68, 9, 2, 36, 34850.16, 0.09, 0.06, 'N', 'O', '1996-04-12', '1996-02-28', '1996-04-20', 'TAKE BACK RETURN', 'MAIL', 'ly final dependencies: slyly bold'),
+(1, 64, 5, 3, 8, 7712.48, 0.10, 0.02, 'N', 'O', '1996-01-29', '1996-03-05', '1996-01-31', 'TAKE BACK RETURN', 'REG AIR', 'riously. regular, express dep'),
+(1, 3, 6, 4, 28, 25284.00, 0.09, 0.06, 'N', 'O', '1996-04-21', '1996-03-30', '1996-05-16', 'NONE', 'AIR', 'lites. fluffily even de'),
+(1, 25, 8, 5, 24, 22200.48, 0.10, 0.04, 'N', 'O', '1996-03-30', '1996-03-14', '1996-04-01', 'NONE', 'FOB', 'pending foxes. slyly re'),
+(1, 16, 3, 6, 32, 29312.32, 0.07, 0.02, 'N', 'O', '1996-01-30', '1996-02-07', '1996-02-03', 'DELIVER IN PERSON', 'MAIL', 'arefully slyly ex'),
+(2, 107, 2, 1, 38, 38269.80, 0.00, 0.05, 'N', 'O', '1997-01-28', '1997-01-14', '1997-02-02', 'TAKE BACK RETURN', 'RAIL', 'ven requests. deposits breach a');
+
+
+select
+ sum(l_extendedprice* (1 - l_discount)) as revenue
+from
+ lineitem,
+ part
+where
+ (
+ p_partkey = l_partkey
+ and p_brand = 'Brand#23'
+ and p_container in ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
+ and l_quantity >= 2 and l_quantity <= 2 + 10
+ and p_size between 1 and 5
+ and l_shipmode in ('AIR', 'AIR REG')
+ and l_shipinstruct = 'DELIVER IN PERSON'
+ )
+ or
+ (
+ p_partkey = l_partkey
+ and p_brand = 'Brand#24'
+ and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
+ and l_quantity >= 20 and l_quantity <= 20 + 10
+ and p_size between 1 and 10
+ and l_shipmode in ('AIR', 'AIR REG')
+ and l_shipinstruct = 'DELIVER IN PERSON'
+ )
+ or
+ (
+ p_partkey = l_partkey
+ and p_brand = 'Brand#44'
+ and p_container in ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
+ and l_quantity >= 26 and l_quantity <= 26 + 10
+ and p_size between 1 and 15
+ and l_shipmode in ('AIR', 'AIR REG')
+ and l_shipinstruct = 'DELIVER IN PERSON'
+ );
+
+#clean up
+DROP DATABASE ssb_small_test;
diff --git a/mysql-test/suite/tianmu/t/std_test.test b/mysql-test/suite/tianmu/t/std_test.test
new file mode 100644
index 000000000..4c94f55c0
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/std_test.test
@@ -0,0 +1,121 @@
+--source include/have_tianmu.inc
+
+--echo #
+--echo # std floor VAR_SAMP func test
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS std_test;
+--enable_warnings
+
+CREATE DATABASE std_test;
+USE std_test;
+
+create table t1 (
+ col_signed tinyint,
+ col_unsigned tinyint unsigned
+);
+
+--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
+eval LOAD DATA LOCAL infile '$MYSQL_TEST_DIR/suite/tianmu/std_data/tinyint_range.tbl' INTO TABLE t1 FIELDS TERMINATED BY '|';
+
+ALTER TABLE t1 ADD COLUMN col_small_signed SMALLINT;
+ALTER TABLE t1 ADD COLUMN col_small_unsigned SMALLINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_med_signed MEDIUMINT;
+ALTER TABLE t1 ADD COLUMN col_med_unsigned MEDIUMINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_int_signed INT;
+ALTER TABLE t1 ADD COLUMN col_int_unsigned INT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_big_signed BIGINT;
+ALTER TABLE t1 ADD COLUMN col_big_unsigned BIGINT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_dec_signed DECIMAL(17,0);
+ALTER TABLE t1 ADD COLUMN col_dec_unsigned DECIMAL(17,0) UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_float_signed FLOAT;
+ALTER TABLE t1 ADD COLUMN col_float_unsigned FLOAT UNSIGNED;
+ALTER TABLE t1 ADD COLUMN col_double_signed DOUBLE;
+ALTER TABLE t1 ADD COLUMN col_double_unsigned DOUBLE UNSIGNED;
+
+UPDATE t1 SET col_small_signed=col_signed + sign(col_signed) * 32000;
+UPDATE t1 SET col_small_unsigned=col_unsigned + 65000;
+UPDATE t1 SET col_med_signed=col_signed + sign(col_signed) * 8388000;
+UPDATE t1 SET col_med_unsigned=col_unsigned + 16776000;
+UPDATE t1 SET col_int_signed=col_signed + sign(col_signed) * 2147483000;
+UPDATE t1 SET col_int_unsigned=col_unsigned + 4294000000;
+
+UPDATE t1 SET col_big_signed=col_signed + sign(col_signed) * 9223372036854775000;
+#bug1485UPDATE t1 SET col_big_unsigned=col_unsigned + 9223372036854775000;
+#bug1485UPDATE t1 SET col_dec_signed=col_signed + sign(col_signed) * 80000000000000001;
+#bug1485UPDATE t1 SET col_dec_unsigned=col_unsigned + 8000000000000003;
+UPDATE t1 SET col_float_signed=col_signed + 0.637 + sign(col_signed) * 8388000;
+UPDATE t1 SET col_float_unsigned=col_unsigned + 0.637 + 16776000;
+UPDATE t1 SET col_double_signed=col_signed + 0.637 + sign(col_signed) * 2147483000;
+UPDATE t1 SET col_double_unsigned=col_unsigned + 0.637 + 4294000000;
+
+
+SELECT 'q1', floor(STD(col_signed)) FROM t1;
+SELECT 'q2', floor(STD(col_unsigned)) FROM t1;
+SELECT 'q3', floor(STD(col_small_signed)) FROM t1;
+SELECT 'q4', floor(STD(col_small_unsigned)) FROM t1;
+SELECT 'q5', floor(STD(col_med_signed)) FROM t1;
+SELECT 'q6', floor(STD(col_med_unsigned)) FROM t1;
+SELECT 'q7', floor(STD(col_int_signed)) FROM t1;
+SELECT 'q8', floor(STD(col_int_unsigned)) FROM t1;
+SELECT 'q9', floor(STD(col_big_signed)) FROM t1;
+#bug1485SELECT 'q10', floor(STD(col_big_unsigned)) FROM t1;
+#bug1485SELECT 'q11', floor(STD(col_dec_signed)) FROM t1;
+SELECT 'q13', floor(STD(col_float_signed)) FROM t1;
+SELECT 'q14', floor(STD(col_float_unsigned)) FROM t1;
+SELECT 'q15', floor(STD(col_double_signed)) FROM t1;
+SELECT 'q16', floor(STD(col_double_unsigned)) FROM t1;
+
+
+SELECT 'q17', floor(STDDEV_SAMP(col_signed)) FROM t1;
+SELECT 'q18', floor(STDDEV_SAMP(col_unsigned)) FROM t1;
+SELECT 'q19', floor(STDDEV_SAMP(col_small_signed)) FROM t1;
+SELECT 'q20', floor(STDDEV_SAMP(col_small_unsigned)) FROM t1;
+SELECT 'q21', floor(STDDEV_SAMP(col_med_signed)) FROM t1;
+SELECT 'q22', floor(STDDEV_SAMP(col_med_unsigned)) FROM t1;
+SELECT 'q23', floor(STDDEV_SAMP(col_int_signed)) FROM t1;
+SELECT 'q24', floor(STDDEV_SAMP(col_int_unsigned)) FROM t1;
+SELECT 'q25', floor(STDDEV_SAMP(col_big_signed)) FROM t1;
+#bug1485SELECT 'q26', floor(STDDEV_SAMP(col_big_unsigned)) FROM t1;
+#bug1485SELECT 'q27', floor(STDDEV_SAMP(col_dec_signed)) FROM t1;
+SELECT 'q29', floor(STDDEV_SAMP(col_float_signed)) FROM t1;
+SELECT 'q30', floor(STDDEV_SAMP(col_float_unsigned)) FROM t1;
+SELECT 'q31', floor(STDDEV_SAMP(col_double_signed)) FROM t1;
+SELECT 'q32', floor(STDDEV_SAMP(col_double_unsigned)) FROM t1;
+
+SELECT 'q33', floor(VAR_POP(col_signed)) FROM t1;
+SELECT 'q34', floor(VAR_POP(col_unsigned)) FROM t1;
+SELECT 'q35', floor(VAR_POP(col_small_signed)) FROM t1;
+SELECT 'q36', floor(VAR_POP(col_small_unsigned)) FROM t1;
+SELECT 'q37', floor(VAR_POP(col_med_signed)) FROM t1;
+SELECT 'q38', floor(VAR_POP(col_med_unsigned)) FROM t1;
+SELECT 'q39', floor(VAR_POP(col_int_signed)) FROM t1;
+SELECT 'q40', floor(VAR_POP(col_int_unsigned)) FROM t1;
+SELECT 'q41', floor(VAR_POP(col_big_signed)) FROM t1;
+#bug1485SELECT 'q42', floor(VAR_POP(col_big_unsigned)) FROM t1;
+#bug1485SELECT 'q43', floor(VAR_POP(col_dec_signed)) FROM t1;
+SELECT 'q45', floor(VAR_POP(col_float_signed)) FROM t1;
+SELECT 'q46', floor(VAR_POP(col_float_unsigned)) FROM t1;
+SELECT 'q47', floor(VAR_POP(col_double_signed)) FROM t1;
+SELECT 'q48', floor(VAR_POP(col_double_unsigned)) FROM t1;
+
+
+SELECT 'q49', floor(VAR_SAMP(col_signed)) FROM t1;
+SELECT 'q50', floor(VAR_SAMP(col_unsigned)) FROM t1;
+SELECT 'q51', floor(VAR_SAMP(col_small_signed)) FROM t1;
+SELECT 'q52', floor(VAR_SAMP(col_small_unsigned)) FROM t1;
+SELECT 'q53', floor(VAR_SAMP(col_med_signed)) FROM t1;
+SELECT 'q54', floor(VAR_SAMP(col_med_unsigned)) FROM t1;
+SELECT 'q55', floor(VAR_SAMP(col_int_signed)) FROM t1;
+SELECT 'q56', floor(VAR_SAMP(col_int_unsigned)) FROM t1;
+SELECT 'q57', floor(VAR_SAMP(col_big_signed)) FROM t1;
+#bug1485SELECT 'q58', floor(VAR_SAMP(col_big_unsigned)) FROM t1;
+#bug1485SELECT 'q59', floor(VAR_SAMP(col_dec_signed)) FROM t1;
+SELECT 'q61', floor(VAR_SAMP(col_float_signed)) FROM t1;
+SELECT 'q62', floor(VAR_SAMP(col_float_unsigned)) FROM t1;
+SELECT 'q63', floor(VAR_SAMP(col_double_signed)) FROM t1;
+SELECT 'q64', floor(VAR_SAMP(col_double_unsigned)) FROM t1;
+
+# Clean UP
+DROP DATABASE std_test;
diff --git a/mysql-test/suite/tianmu/t/trigger.test.bak b/mysql-test/suite/tianmu/t/trigger.test
similarity index 100%
rename from mysql-test/suite/tianmu/t/trigger.test.bak
rename to mysql-test/suite/tianmu/t/trigger.test
diff --git a/mysql-test/suite/tianmu/t/union_case.test b/mysql-test/suite/tianmu/t/union_case.test
new file mode 100644
index 000000000..e6485d5bc
--- /dev/null
+++ b/mysql-test/suite/tianmu/t/union_case.test
@@ -0,0 +1,51 @@
+--source include/have_tianmu.inc
+--echo # MCOL-641 Union Test Cases
+--echo # Once MCOL-5417 is supported, the errored out queries below should be fixed.
+
+--disable_warnings
+DROP DATABASE IF EXISTS union_case_test;
+--enable_warnings
+
+CREATE DATABASE union_case_test;
+USE union_case_test;
+
+SET SQL_MODE='ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
+
+CREATE TABLE cs1 (d1 DECIMAL(17), d2 DECIMAL(17,10), d3 DECIMAL(17,17)) ;
+CREATE TABLE cs2 (d1 DECIMAL(17) UNSIGNED, d2 DECIMAL(17,10) UNSIGNED, d3 DECIMAL(17,17) UNSIGNED) ;
+
+INSERT INTO cs1 VALUES (125, 1.25, 0.125);
+INSERT INTO cs1 VALUES (-125, -1.25, -0.125);
+INSERT INTO cs1 values (9999999999999998, 9999999.9999999998, 0.9999999999999998);
+INSERT INTO cs1 values (99999999999999999, 9999999.9999999999, 0.99999999999999999);
+INSERT INTO cs1 values (-9999999999999998, -9999999.9999999998, -0.9999999999999998);
+INSERT INTO cs1 values (-99999999999999999, -9999999.9999999999, -0.99999999999999999);
+#bug1868 select * from cs1;
+#bug1870 SELECT d1, d2, d3 FROM cs1 UNION SELECT d1, d2, d3 FROM cs1;
+
+CREATE TABLE cs3 (d1 int, d2 int, d3 int) ;
+INSERT INTO cs3 VALUES (12, 16, 56);
+INSERT INTO cs3 VALUES (7, 6, 45);
+INSERT INTO cs3 VALUES (0, 0, 0);
+SELECT d1, d1, d2 FROM cs3 UNION SELECT d2, d3, d3 FROM cs3;
+
+INSERT INTO cs2 VALUES (125, 1.25, 0.125);
+INSERT INTO cs2 values (9999999999999998, 9999999.9999999998, 0.9999999999999998);
+INSERT INTO cs2 values (99999999999999999, 9999999.9999999999, 0.99999999999999999);
+
+#bug1870 SELECT d1, d2, d3 FROM cs2 UNION SELECT d1, d2, d3 FROM cs2;
+
+DROP TABLE cs1, cs2;
+CREATE TABLE cs1 (d1 DECIMAL(17, 0), d2 DECIMAL(17, 14), d3 DECIMAL(17, 14)) ;
+CREATE TABLE cs2 (d1 DECIMAL(17, 0) UNSIGNED, d2 DECIMAL(17, 14) UNSIGNED, d3 DECIMAL(17, 14) UNSIGNED) ;
+INSERT INTO cs1 VALUES (12345678901234567, 12.34567890123456, 0.1234567890123456);
+INSERT INTO cs1 VALUES (-12345678901234567, -12.34567890123456, -0.1234567890123456);
+INSERT INTO cs1 VALUES (99999999999999999, 99.999999999999999, 0.999999999999999);
+INSERT INTO cs1 VALUES (-99999999999999999, -99.999999999999999, -0.999999999999999);
+INSERT INTO cs2 VALUES (12345678901234567, 12.34567890123456, 0.1234567890123456);
+INSERT INTO cs2 VALUES (99999999999999999, 99.999999999999999, 0.999999999999999);
+
+#bug1870 SELECT d1, d1, d2 FROM cs1 UNION SELECT d2, d3, d3 FROM cs1;
+
+# Clean UP
+DROP DATABASE union_case_test;
diff --git a/mysql-test/suite/tianmu/t/unsigned_support_issue1267.test b/mysql-test/suite/tianmu/t/unsigned_support_issue1267.test
index 5495070d9..78ca69220 100644
--- a/mysql-test/suite/tianmu/t/unsigned_support_issue1267.test
+++ b/mysql-test/suite/tianmu/t/unsigned_support_issue1267.test
@@ -272,7 +272,7 @@ select * from load_unsigned;
eval select * into outfile "$MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt" from load_unsigned;
truncate table load_unsigned;
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
-eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt' INTO TABLE load_unsigned FIELDS TERMINATED BY ';';
+eval LOAD DATA LOCAL INFILE '$MYSQL_TEST_DIR/suite/tianmu/tmp/unsigned_outfile-test.txt' INTO TABLE load_unsigned;
select * from load_unsigned;
drop table load_unsigned;
diff --git a/mysql-test/suite/tianmu/t/various_join.test b/mysql-test/suite/tianmu/t/various_join.test
index ddf70f28b..363614f5a 100644
--- a/mysql-test/suite/tianmu/t/various_join.test
+++ b/mysql-test/suite/tianmu/t/various_join.test
@@ -32,37 +32,37 @@ insert into t7 values (1, 3);
insert into t8 values (1, 3);
insert into t9 values (1, 2);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a = 1 or t3.a = 3);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a > 1);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) order by t3.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a) order by t4.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a = 1 or t3.a = 3) order by t3.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) where (t3.a > 1) order by t3.a;
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t2.a = t3.a) left join t4 on (t3.a = t4.a and t1.b = t4.b) order by t3.a;
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t2.a = t3.a) left join t4 on (t3.a = t4.a and t2.b = t4.b) order by t3.a;
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t1.a);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t2.a and t3.a > t1.a);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.b > t2.a and t3.a < t1.b);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t1.a) order by t3.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.a > t2.a and t3.a > t1.a) order by t3.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b and t3.b > t2.a and t3.a < t1.b) order by t3.a;
# Below query is disabled until fixed #925
-#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a);
+#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a) order by t6.a;
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) order by t3.a;
select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) right join t4 on (t3.a = t4.a and t2.a = t4.a) order by t3.a;
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) left join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) right join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) left join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a) order by t3.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a) right join t4 on (t3.a = t4.a and t1.a = t4.a and t2.a = t4.a) order by t4.a;
# Below query is disabled until fixed #925
-#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a) left join t7 on (t7.a = t3.a) left join t8 on (t8.a = t7.a and t8.a = t2.a);
+#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a) left join t7 on (t7.a = t3.a) left join t8 on (t8.a = t7.a and t8.a = t2.a) order by t8.a;
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) left join t5 on (t4.a = t5.a and t3.b = t5.b);
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) left join t5 on (t4.a = t5.a and t3.b = t5.b) order by t5.a;
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) order by t5.a;
# Below query is disabled until fixed #925
-#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a) left join t7 on (t7.a = t3.a) left join t8 on (t8.a = t7.a and t8.a = t2.a) left join t9 on (t7.a = t9.a and t4.a = t9.a);
+#select * from t1 left join t2 on (t1.a = t2.a) left join t3 on (t2.a = t3.a) left join t4 on (t4.a = t3.a) left join t5 on (t5.a = t2.a) left join t6 on (t5.a = t6.a and t6.a = t4.a) left join t7 on (t7.a = t3.a) left join t8 on (t8.a = t7.a and t8.a = t2.a) left join t9 on (t7.a = t9.a and t4.a = t9.a) order by t9.a;
-select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) right join t6 on (t5.a = t6.a and t4.a = t6.a);
+select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) right join t6 on (t5.a = t6.a and t4.a = t6.a) order by t6.a;
# Below query is disabled until fixed #925
-#select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) left join t6 on (t5.a = t6.a and t4.a = t6.a);
+#select * from t1 inner join t2 on (t1.a = t2.a) right join t3 on (t1.a = t3.a and t2.b = t3.b) left join t4 on (t3.a = t4.a and t2.a = t4.a) right join t5 on (t4.a = t5.a and t3.b = t5.b) left join t6 on (t5.a = t6.a and t4.a = t6.a) order by t6.a;
drop table t1;
drop table t2;
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index dd6333073..2dbb48969 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -79,7 +79,7 @@ CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsign
CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=INNODB STATS_PERSISTENT=0 CHARACTER SET utf8 comment='Leap seconds information for time zones';
-CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(93) collate utf8_bin DEFAULT '' NOT NULL, created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH', 'MANDATORY_TIANMU', 'NO_KEY_ERROR') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
+CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(93) collate utf8_bin DEFAULT '' NOT NULL, created timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures';
CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(32) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(93) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges';
@@ -89,7 +89,7 @@ CREATE TABLE IF NOT EXISTS general_log (event_time TIMESTAMP(6) NOT NULL DEFAULT
-- Create slow_log
CREATE TABLE IF NOT EXISTS slow_log (start_time TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), user_host MEDIUMTEXT NOT NULL, query_time TIME(6) NOT NULL, lock_time TIME(6) NOT NULL, rows_sent INTEGER NOT NULL, rows_examined INTEGER NOT NULL, db VARCHAR(512) NOT NULL, last_insert_id INTEGER NOT NULL, insert_id INTEGER NOT NULL, server_id INTEGER UNSIGNED NOT NULL, sql_text MEDIUMBLOB NOT NULL, thread_id BIGINT(21) UNSIGNED NOT NULL) engine=CSV CHARACTER SET utf8 comment="Slow log";
-CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH', 'MANDATORY_TIANMU', 'NO_KEY_ERROR') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
+CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(93) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, modified TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','NOT_USED','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events';
CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts INT UNSIGNED NOT NULL, updates INT UNSIGNED NOT NULL, deletes INT UNSIGNED NOT NULL, schemaops INT UNSIGNED NOT NULL, orig_server_id INT UNSIGNED NOT NULL, orig_epoch BIGINT UNSIGNED NOT NULL, gci INT UNSIGNED NOT NULL, next_position BIGINT UNSIGNED NOT NULL, next_file VARCHAR(255) NOT NULL, PRIMARY KEY(epoch, orig_server_id, orig_epoch)) ENGINE=MYISAM;
diff --git a/scripts/mysql_system_tables_fix.sql b/scripts/mysql_system_tables_fix.sql
index e781ddb74..9af709c74 100644
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -476,9 +476,7 @@ ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
'NO_AUTO_CREATE_USER',
'HIGH_NOT_PRECEDENCE',
'NO_ENGINE_SUBSTITUTION',
- 'PAD_CHAR_TO_FULL_LENGTH',
- 'MANDATORY_TIANMU',
- 'NO_KEY_ERROR'
+ 'PAD_CHAR_TO_FULL_LENGTH'
) DEFAULT '' NOT NULL,
DEFAULT CHARACTER SET utf8;
@@ -598,9 +596,7 @@ ALTER TABLE event MODIFY sql_mode
'NO_AUTO_CREATE_USER',
'HIGH_NOT_PRECEDENCE',
'NO_ENGINE_SUBSTITUTION',
- 'PAD_CHAR_TO_FULL_LENGTH',
- 'MANDATORY_TIANMU',
- 'NO_KEY_ERROR'
+ 'PAD_CHAR_TO_FULL_LENGTH'
) DEFAULT '' NOT NULL AFTER on_completion;
ALTER TABLE event MODIFY name char(64) CHARACTER SET utf8 NOT NULL default '';
diff --git a/sql/auth/sql_authorization.cc b/sql/auth/sql_authorization.cc
index 2874fa0da..a40aa5b93 100644
--- a/sql/auth/sql_authorization.cc
+++ b/sql/auth/sql_authorization.cc
@@ -4389,10 +4389,10 @@ bool check_fk_parent_table_access(THD *thd,
// Return if engine does not support Foreign key Constraint.
if (!ha_check_storage_engine_flag(db_type, HTON_SUPPORTS_FOREIGN_KEYS)) {
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
if (db_type == tianmu_hton &&
- (alter_info->flags & Alter_info::ADD_FOREIGN_KEY) &&
- (!(sql_mode & MODE_NO_KEY_ERROR))) {
+ (alter_info->flags & Alter_info::ADD_FOREIGN_KEY) && !tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_SUPPORTED_FOREIGN_KEY, MYF(0));
return true;
}
diff --git a/sql/item.h b/sql/item.h
index f094b81bd..e848302d0 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -3570,7 +3570,7 @@ class Item_decimal :public Item_num
enum_field_types field_type() const { return MYSQL_TYPE_NEWDECIMAL; }
longlong val_int();
double val_real();
- String *val_str(String*);
+ virtual String *val_str(String*);
my_decimal *val_decimal(my_decimal *val) { return &decimal_value; }
bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate)
{
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 73e35a69a..bb9204de0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -179,9 +179,6 @@ enum enum_binlog_format {
#define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2)
#define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2)
#define MODE_PAD_CHAR_TO_FULL_LENGTH (1ULL << 31)
-//Force the engine to be tianmu when acting as a slave library
-#define MODE_MANDATORY_TIANMU (1ULL << 32)
-#define MODE_NO_KEY_ERROR (1ULL << 33)
/*
Replication uses 8 bytes to store SQL_MODE in the binary log. The day you
@@ -584,6 +581,17 @@ typedef struct system_variables
'COLUMN_TYPE' field.
*/
my_bool show_old_temporals;
+
+ /*
+ Specifies whether to enable mandatory Tianmu engine in table.
+ if yes ,set tianmu_mandatory to ON, otherwise set the variable to OFF.
+ */
+ my_bool tianmu_mandatory;
+ /*
+ Specifies whether to to directly skip DDL statements that are not supported by the SQL layer,
+ instead of reporting errors. if yes ,set tianmu_no_key_error to ON, otherwise set the variable to OFF.
+ */
+ my_bool tianmu_no_key_error;
} SV;
diff --git a/sql/sql_load.cc b/sql/sql_load.cc
index ecd40a27b..01b883fab 100644
--- a/sql/sql_load.cc
+++ b/sql/sql_load.cc
@@ -51,7 +51,7 @@
#include
-#include "../storage/tianmu/handler/ha_my_tianmu.h" // tianmu code
+#include "../storage/tianmu/sql/ha_my_tianmu.h" // tianmu code
using std::min;
using std::max;
diff --git a/sql/sql_optimizer.cc b/sql/sql_optimizer.cc
index 2e670e6d3..ad2a548e5 100644
--- a/sql/sql_optimizer.cc
+++ b/sql/sql_optimizer.cc
@@ -228,7 +228,7 @@ JOIN::optimize(OptimizePhase phase)
if (phase == OptimizePhase::Before_LOJ_Transform)
{
if (tl->is_view_or_derived() && tl->optimize_derived_for_tianmu(thd))
- DBUG_RETURN(1);
+ DBUG_RETURN(0);
}
}
}
@@ -5142,23 +5142,8 @@ bool JOIN::make_join_plan()
trace_table_dependencies(trace, join_tab, primary_tables);
// Build the key access information, which is the basis for ref access.
- if (where_cond || select_lex->outer_join)
- {
- /*
- The primary key of the tianmu engine does not support delete and update statements.
- The following codes can be deleted after subsequent support
- */
- TABLE *const table= join_tab->table();
- bool check_if_tianmu_engine = table && table->s &&
- (table->s->db_type() ? (table->s->db_type()->db_type == DB_TYPE_TIANMU): false);
- enum_sql_command sql_command = SQLCOM_END;
- if(thd->lex) sql_command = thd->lex->sql_command;
- bool check_tianmu_delete_or_update = (check_if_tianmu_engine && ((sql_command == SQLCOM_DELETE) ||
- (sql_command == SQLCOM_DELETE_MULTI) ||
- (sql_command == SQLCOM_UPDATE) ||
- (sql_command == SQLCOM_UPDATE_MULTI)));
-
- if (!check_tianmu_delete_or_update && update_ref_and_keys(thd, &keyuse_array, join_tab, tables, where_cond,
+ if (where_cond || select_lex->outer_join) {
+ if (update_ref_and_keys(thd, &keyuse_array, join_tab, tables, where_cond,
cond_equal, ~select_lex->outer_join, select_lex,
&sargables))
DBUG_RETURN(true);
@@ -6901,19 +6886,17 @@ merge_key_fields(Key_field *start, Key_field *new_fields, Key_field *end,
old->val= new_fields->val;
/* The referred expression can be NULL: */
old->null_rejecting= 0;
- }
- else
- {
- /*
- We are comparing two different const. In this case we can't
- use a key-lookup on this so it's better to remove the value
- and let the range optimizer handle it
- */
- if (old == --first_free) // If last item
- break;
- *old= *first_free; // Remove old value
- old--; // Retry this value
- }
+ } else {
+ /*
+ We are comparing two different const. In this case we can't
+ use a key-lookup on this so it's better to remove the value
+ and let the range optimizer handle it
+ */
+ if (old == --first_free) // If last item
+ break;
+ *old = *first_free; // Remove old value
+ old--; // Retry this value
+ }
}
}
}
@@ -9404,13 +9387,11 @@ static bool make_join_select(JOIN *join, Item *cond)
get_quick_record_count().
*/
assert(tab->quick()->is_valid());
- }
- else
- {
+ } else {
delete tab->quick();
- tab->set_quick(NULL);
+ tab->set_quick(NULL);
}
- }
+ }
if ((tab->type() == JT_ALL || tab->type() == JT_RANGE ||
tab->type() == JT_INDEX_MERGE || tab->type() == JT_INDEX_SCAN) &&
@@ -10126,7 +10107,7 @@ bool optimize_cond(THD *thd, Item **cond, COND_EQUAL **cond_equal,
DBUG_EXECUTE("where",print_where(*cond,"after const change", QT_ORDINARY););
}
}
- if (*cond)
+ if ((*cond) && (!( (int64)(*cond) & 0x1)))
{
Opt_trace_object step_wrapper(trace);
step_wrapper.add_alnum("transformation", "trivial_condition_removal");
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e486cfc89..4e534fd81 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -118,7 +118,7 @@
#include "rpl_group_replication.h"
#include
-#include "../storage/tianmu/handler/ha_my_tianmu.h" // tianmu code
+#include "../storage/tianmu/sql/ha_my_tianmu.h" // tianmu code
using std::max;
/**
@@ -2774,18 +2774,14 @@ mysql_execute_command(THD *thd, bool first_level)
if (!thd->in_sub_stmt)
thd->query_plan.set_query_plan(lex->sql_command, lex,
!thd->stmt_arena->is_conventional());
- /*
- the (sql_mode) of (MANDATORY_TIANMU) is set,
- the engine will be forcibly converted to the tianmu engine.
- */
+
if(lex && ((lex->sql_command == SQLCOM_CREATE_TABLE) ||
(lex->sql_command == SQLCOM_ALTER_TABLE)) &&
!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)){
- sql_mode_t sql_mode = thd->variables.sql_mode;
- if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
- if(sql_mode & MODE_MANDATORY_TIANMU){
+ my_bool tianmu_mandatory = thd->slave_thread ? global_system_variables.tianmu_mandatory : thd->variables.tianmu_mandatory;
+ if(tianmu_mandatory){
lex->create_info.db_type = ha_default_handlerton(thd);
old_db_type = lex->create_info.db_type->db_type;
lex->create_info.db_type->db_type = DB_TYPE_TIANMU;
diff --git a/sql/sql_resolver.cc b/sql/sql_resolver.cc
index 44d3971f4..447f3267d 100644
--- a/sql/sql_resolver.cc
+++ b/sql/sql_resolver.cc
@@ -1037,9 +1037,7 @@ bool SELECT_LEX::resolve_subquery(THD *thd)
for (TABLE_LIST *p_table_list = parent_tables.first; p_table_list;
p_table_list = p_table_list->next_local) {
TABLE* p_table = p_table_list->table;
- if (p_table && p_table->s && p_table->s->db_type() &&
- p_table->s->db_type()->db_type == DB_TYPE_TIANMU &&
- p_table->key_info) {
+ if (p_table && p_table->reginfo.join_tab && p_table->reginfo.join_tab->quick()) {
tianmu_table_has_index = true;
break;
}
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 837ac4d37..1dec5be78 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -77,7 +77,7 @@
#include
#include
-#include "../storage/tianmu/handler/ha_my_tianmu.h" // TIANMU UPGRADE
+#include "../storage/tianmu/sql/ha_my_tianmu.h" // TIANMU UPGRADE
using std::max;
using std::min;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index db9000529..f55c3877e 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3933,17 +3933,16 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name,
}
(*key_count)++;
tmp=file->max_key_parts();
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
if ((create_info->db_type->db_type == DB_TYPE_TIANMU)) {
if ((file->ha_table_flags() & HA_NON_SECONDARY_KEY) &&
- (key->type == KEYTYPE_MULTIPLE) &&
- !(sql_mode & MODE_NO_KEY_ERROR)) {
+ (key->type == KEYTYPE_MULTIPLE) && !tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_SUPPORTED_SECONDARY_INDEX, MYF(0));
DBUG_RETURN(TRUE);
}
if ((file->ha_table_flags() & HA_NON_UNIQUE_KEY) &&
- (key->type == KEYTYPE_UNIQUE) &&
- (!(sql_mode & MODE_NO_KEY_ERROR))) {
+ (key->type == KEYTYPE_UNIQUE) && !tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_SUPPORTED_UNIQUE_INDEX, MYF(0));
DBUG_RETURN(TRUE);
}
@@ -4081,8 +4080,9 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name,
DBUG_RETURN(TRUE);
}
if (create_info->db_type->db_type == DB_TYPE_TIANMU){
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
- if(!(sql_mode & MODE_NO_KEY_ERROR)) {
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
+ if(!tianmu_no_key_error) {
my_message(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX,
ER(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX), MYF(0));
DBUG_RETURN(TRUE);
@@ -8318,9 +8318,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
!my_strcasecmp(system_charset_info,key_name, drop->name)) {
// for issue 1342 and 1343, if sql_mode does not contains NO_KEY_ERROR,
// drop unique key, sencondary index, and fulltext index will return an error.
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
- if ((create_info->db_type->db_type == DB_TYPE_TIANMU) &&
- !(sql_mode & MODE_NO_KEY_ERROR)) {
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
+ if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && !tianmu_no_key_error) {
if (key_info->flags & HA_SPATIAL){
//key_type= KEYTYPE_SPATIAL;
//do nothing
@@ -8524,12 +8524,12 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
// Now this contains only DROP for foreign keys and not-found objects
Alter_drop *drop;
drop_it.rewind();
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
while ((drop=drop_it++)) {
switch (drop->type) {
case Alter_drop::KEY:
- if ((create_info->db_type->db_type == DB_TYPE_TIANMU) &&
- (!(sql_mode & MODE_NO_KEY_ERROR))) {
+ if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && !tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0));
goto err;
}
@@ -8539,8 +8539,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
alter_info->drop_list.head()->name);
goto err;
case Alter_drop::FOREIGN_KEY:
- if ((create_info->db_type->db_type == DB_TYPE_TIANMU) &&
- (!(sql_mode & MODE_NO_KEY_ERROR))) {
+ if ((create_info->db_type->db_type == DB_TYPE_TIANMU) && !tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_SUPPORTED_FOREIGN_KEY, MYF(0));
}
break;
@@ -8555,8 +8554,9 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (rename_key_list.elements)
{
if (create_info->db_type->db_type == DB_TYPE_TIANMU){
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
- if(!(sql_mode & MODE_NO_KEY_ERROR)){
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
+ if(!tianmu_no_key_error){
my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0));
goto err;
}
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 8388c8ce2..aeeab2cca 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -227,8 +227,9 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
table= tables->table;
table->pos_in_table_list= tables;
if ((table->file && table->file->ht == tianmu_hton)){
- sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
- if(!(sql_mode & MODE_NO_KEY_ERROR)) {
+ my_bool tianmu_no_key_error = thd->slave_thread ? global_system_variables.tianmu_no_key_error :
+ thd->variables.tianmu_no_key_error;
+ if(!tianmu_no_key_error) {
my_error(ER_TIANMU_NOT_SUPPORTED_TRIGGER, MYF(0));
goto end;
}
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 44ef56180..cc59db135 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -956,7 +956,7 @@ bool st_select_lex_unit::cleanup(bool full)
#ifndef NDEBUG
void st_select_lex_unit::assert_not_fully_clean()
{
- assert(cleaned < UC_CLEAN);
+ assert(cleaned <= UC_CLEAN);
SELECT_LEX *sl= first_select();
for (;;)
{
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 452b2481c..779b0836a 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -3904,7 +3904,7 @@ static const char *sql_mode_names[]=
"STRICT_ALL_TABLES", "NO_ZERO_IN_DATE", "NO_ZERO_DATE",
"ALLOW_INVALID_DATES", "ERROR_FOR_DIVISION_BY_ZERO", "TRADITIONAL",
"NO_AUTO_CREATE_USER", "HIGH_NOT_PRECEDENCE", "NO_ENGINE_SUBSTITUTION",
- "PAD_CHAR_TO_FULL_LENGTH", "MANDATORY_TIANMU", "NO_KEY_ERROR",
+ "PAD_CHAR_TO_FULL_LENGTH",
0
};
export bool sql_mode_string_representation(THD *thd, sql_mode_t sql_mode,
@@ -5996,6 +5996,24 @@ static Sys_var_mybool Sys_show_old_temporals(
ON_CHECK(0), ON_UPDATE(0),
DEPRECATED_VAR(""));
+static Sys_var_mybool Sys_tianmu_mandatory(
+ "tianmu_mandatory",
+ "Specifies whether to enable mandatory Tianmu engine in table."
+ "if yes ,set tianmu_mandatory to ON, otherwise set the variable to OFF.",
+ SESSION_VAR(tianmu_mandatory),
+ CMD_LINE(OPT_ARG),
+ DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+ ON_CHECK(0), ON_UPDATE(0));
+
+static Sys_var_mybool Sys_tianmu_no_key_error(
+ "tianmu_no_key_error",
+ "Specifies whether to to directly skip DDL statements that are not supported by the SQL layer,"
+ "instead of reporting errors. if yes ,set tianmu_no_key_error to ON, otherwise set the variable to OFF.",
+ SESSION_VAR(tianmu_no_key_error),
+ CMD_LINE(OPT_ARG),
+ DEFAULT(FALSE), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+ ON_CHECK(0), ON_UPDATE(0));
+
static Sys_var_charptr Sys_disabled_storage_engines(
"disabled_storage_engines",
"Limit CREATE TABLE for the storage engines listed",
diff --git a/storage/tianmu/CMakeLists.txt b/storage/tianmu/CMakeLists.txt
index 3302e1e6b..9449b05bd 100644
--- a/storage/tianmu/CMakeLists.txt
+++ b/storage/tianmu/CMakeLists.txt
@@ -55,6 +55,14 @@ AUX_SOURCE_DIRECTORY(base/core SOURCE_base_core)
AUX_SOURCE_DIRECTORY(base/fmt SOURCE_base_fmt)
AUX_SOURCE_DIRECTORY(base/net SOURCE_base_net)
AUX_SOURCE_DIRECTORY(base/util SOURCE_base_util)
+AUX_SOURCE_DIRECTORY(optimizer SOURCE_optimizer)
+AUX_SOURCE_DIRECTORY(optimizer/compile SOURCE_compile)
+AUX_SOURCE_DIRECTORY(optimizer/iterators SOURCE_iterators)
+AUX_SOURCE_DIRECTORY(optimizer/statistics SOURCE_statistics)
+AUX_SOURCE_DIRECTORY(optimizer/plan SOURCE_plan)
+AUX_SOURCE_DIRECTORY(executor SOURCE_executor)
+AUX_SOURCE_DIRECTORY(data SOURCE_data)
+AUX_SOURCE_DIRECTORY(sql SOURCE_sql)
SET(TIANMU_SOURCES ${SOURCE_common}
${SOURCE_compress}
@@ -72,7 +80,16 @@ SET(TIANMU_SOURCES ${SOURCE_common}
${SOURCE_base_core}
${SOURCE_base_fmt}
${SOURCE_base_net}
- ${SOURCE_base_util})
+ ${SOURCE_base_util}
+ ${SOURCE_optimizer}
+ ${SOURCE_compile}
+ ${SOURCE_iterators}
+ ${SOURCE_statistics}
+ ${SOURCE_plan}
+ ${SOURCE_executor}
+ ${SOURCE_data}
+ ${SOURCE_sql}
+ )
MYSQL_ADD_PLUGIN(tianmu ${TIANMU_SOURCES}
STORAGE_ENGINE
diff --git a/storage/tianmu/async_tests/task_executor.cpp b/storage/tianmu/async_tests/task_executor.cpp
index 57d65c9ee..dcb0933c2 100644
--- a/storage/tianmu/async_tests/task_executor.cpp
+++ b/storage/tianmu/async_tests/task_executor.cpp
@@ -19,7 +19,7 @@
#include "base/core/app_template.h"
#include "base/core/future.h"
-#include "core/task_executor.h"
+#include "executor/task_executor.h"
#ifndef DISABLE_USED_FOR_TIANMU
#include "core/engine.h"
diff --git a/storage/tianmu/common/common_definitions.h b/storage/tianmu/common/common_definitions.h
index db184b386..7dabc51e8 100644
--- a/storage/tianmu/common/common_definitions.h
+++ b/storage/tianmu/common/common_definitions.h
@@ -59,8 +59,7 @@ enum class ColumnType : unsigned char {
BIN, // free binary (BLOB), no encoding
BYTE, // free binary, fixed size, no encoding
VARBYTE, // free binary, variable size, no encoding
- REAL, // double (stored as non-interpreted int64_t, null value is
- // NULL_VALUE_64)
+ REAL, // double (stored as non-interpreted int64_t, null value is NULL_VALUE_64)
DATETIME,
TIMESTAMP,
DATETIME_N,
diff --git a/storage/tianmu/common/defs.h b/storage/tianmu/common/defs.h
index d4f8b8335..595e65bf4 100644
--- a/storage/tianmu/common/defs.h
+++ b/storage/tianmu/common/defs.h
@@ -18,6 +18,7 @@
#define TIANMU_COMMON_DEFS_H_
#pragma once
+#include
#include
namespace Tianmu {
@@ -42,19 +43,17 @@ constexpr const char *COL_FILTER_HIST_DIR = "hist";
constexpr const char *COL_KN_FILE = "KN";
constexpr const char *COL_META_FILE = "META";
constexpr const char *COL_DN_FILE = "DN";
-/*
- The size of the file where the DPN metadata resides, in bytes
- At present, the size of a single DPN is 88 bytes, and the storage limit is 8.589 billion lines
-*/
-constexpr size_t COL_DN_FILE_SIZE = 11 * 1024 * 1024;
+
+constexpr uint8_t MAX_PSS = 16; // max pack size shift
+constexpr uint8_t DFT_PSS = 16;
+constexpr size_t MAX_ROW_NUMS_EACH_PACK = 1 << common::MAX_PSS; // max 64K rows per pack
+
+constexpr size_t MAX_CMPR_SIZE = 0x007D000000;
constexpr const char *COL_DATA_FILE = "DATA";
constexpr const char *COL_VERSION_DIR = "v";
constexpr uint32_t COL_FILE_VERSION = 3;
constexpr uint32_t MAX_COLUMNS_PER_TABLE = 4000;
-
-constexpr uint8_t MAX_PSS = 16;
-constexpr uint8_t DFT_PSS = 16;
-constexpr size_t MAX_CMPR_SIZE = 0x007D000000;
+constexpr uint32_t MAX_ROW_NUM_SHIFT = 33; // max 8G (1 << 33) rows per storage limitation
using PACK_INDEX = uint32_t;
constexpr PACK_INDEX INVALID_PACK_INDEX = -1;
diff --git a/storage/tianmu/compress/basic_data_filt.h b/storage/tianmu/compress/basic_data_filt.h
index e195b6d09..5db0a147b 100644
--- a/storage/tianmu/compress/basic_data_filt.h
+++ b/storage/tianmu/compress/basic_data_filt.h
@@ -22,8 +22,8 @@
#include "compress/data_filt.h"
#include "compress/dictionary.h"
-#include "core/bin_tools.h"
#include "core/quick_math.h"
+#include "util/bin_tools.h"
namespace Tianmu {
namespace compress {
diff --git a/storage/tianmu/compress/dictionary.cpp b/storage/tianmu/compress/dictionary.cpp
index 03ca77927..1a0ce71d7 100644
--- a/storage/tianmu/compress/dictionary.cpp
+++ b/storage/tianmu/compress/dictionary.cpp
@@ -19,7 +19,7 @@
#include
-#include "core/bin_tools.h"
+#include "util/bin_tools.h"
#include "util/qsort.h"
namespace Tianmu {
diff --git a/storage/tianmu/compress/num_compressor.h b/storage/tianmu/compress/num_compressor.h
index 4bf01e771..0405030a7 100644
--- a/storage/tianmu/compress/num_compressor.h
+++ b/storage/tianmu/compress/num_compressor.h
@@ -25,8 +25,8 @@
#include "compress/range_code.h"
#include "compress/top_bit_dict.h"
#include "core/quick_math.h"
-#include "core/tools.h"
#include "system/fet.h"
+#include "util/tools.h"
namespace Tianmu {
namespace compress {
diff --git a/storage/tianmu/compress/range_code.h b/storage/tianmu/compress/range_code.h
index b0c2b47dd..bb5a3b83f 100644
--- a/storage/tianmu/compress/range_code.h
+++ b/storage/tianmu/compress/range_code.h
@@ -23,7 +23,7 @@
#include "common/assert.h"
#include "common/exception.h"
#include "compress/defs.h"
-#include "core/bin_tools.h"
+#include "util/bin_tools.h"
namespace Tianmu {
namespace compress {
diff --git a/storage/tianmu/core/data_cache.cpp b/storage/tianmu/core/data_cache.cpp
index 632d44ba7..9b3cbba61 100644
--- a/storage/tianmu/core/data_cache.cpp
+++ b/storage/tianmu/core/data_cache.cpp
@@ -17,7 +17,7 @@
#include "data_cache.h"
-#include "core/tianmu_attr.h"
+#include "vc/tianmu_attr.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/data_cache.h b/storage/tianmu/core/data_cache.h
index 6997eb384..2340fd486 100644
--- a/storage/tianmu/core/data_cache.h
+++ b/storage/tianmu/core/data_cache.h
@@ -24,7 +24,7 @@
#include
#include
-#include "core/pack.h"
+#include "data/pack.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/delta_table.cpp b/storage/tianmu/core/delta_table.cpp
index 3f2b5a6bb..f572c3c39 100644
--- a/storage/tianmu/core/delta_table.cpp
+++ b/storage/tianmu/core/delta_table.cpp
@@ -28,7 +28,10 @@ namespace core {
/// DeltaTable
DeltaTable::DeltaTable(const std::string &name, uint32_t delta_id, uint32_t cf_id)
- : fullname_(name), delta_tid_(delta_id), cf_handle_(ha_kvstore_->GetCfHandleByID(cf_id)) {
+ : fullname_(name), delta_tid_(delta_id) {
+ index::KVStore *store = (reinterpret_cast(tianmu_hton->data))->getStore();
+ cf_handle_ = store->GetCfHandleByID(cf_id);
+
ASSERT(cf_handle_, "column family handle not exist " + name);
}
@@ -40,7 +43,9 @@ std::shared_ptr DeltaTable::CreateDeltaTable(const std::shared_ptr delta = ha_kvstore_->FindDeltaTable(normalized_name);
+
+ index::KVStore *store = (reinterpret_cast(tianmu_hton->data))->getStore();
+ std::shared_ptr delta = store->FindDeltaTable(normalized_name);
if (delta)
return delta;
@@ -48,10 +53,12 @@ std::shared_ptr DeltaTable::CreateDeltaTable(const std::shared_ptrGetCfHandle(cf_name)->GetID();
- uint32_t delta_id = ha_kvstore_->GetNextIndexId();
+
+ uint32_t cf_id = store->GetCfHandle(cf_name)->GetID();
+ uint32_t delta_id = store->GetNextIndexId();
delta = std::make_shared(normalized_name, delta_id, cf_id);
- ha_kvstore_->KVWriteDeltaMeta(delta);
+ store->KVWriteDeltaMeta(delta);
+
TIANMU_LOG(LogCtl_Level::INFO, "Create Delta Store: %s, CF ID: %d, Delta Store ID: %u", normalized_name.c_str(),
cf_id, delta_id);
@@ -63,11 +70,13 @@ common::ErrorCode DeltaTable::Rename(const std::string &to) {
if (!index::NormalizeName(to, dname)) {
return common::ErrorCode::FAILED;
}
- if (ha_kvstore_->FindDeltaTable(dname)) {
+
+ index::KVStore *store = (reinterpret_cast(tianmu_hton->data))->getStore();
+ if (store->FindDeltaTable(dname)) {
return common::ErrorCode::FAILED;
}
- ha_kvstore_->KVRenameDeltaMeta(fullname_, dname);
+ store->KVRenameDeltaMeta(fullname_, dname);
fullname_ = dname;
return common::ErrorCode::SUCCESS;
}
@@ -75,18 +84,22 @@ common::ErrorCode DeltaTable::Rename(const std::string &to) {
void DeltaTable::FillRowByRowid(Transaction *tx, TABLE *table, int64_t obj) {
uchar key[sizeof(uint32_t) + sizeof(uint64_t)];
size_t key_pos = 0;
+
index::KVTransaction &kv_trans = tx->KVTrans();
// table id
index::be_store_index(key + key_pos, delta_tid_);
key_pos += sizeof(uint32_t);
+
// row id
index::be_store_uint64(key + key_pos, obj);
key_pos += sizeof(uint64_t);
+
std::string delta_record;
rocksdb::Status status = kv_trans.GetData(cf_handle_, {(char *)key, key_pos}, &delta_record);
if (!status.ok()) {
throw common::Exception("Error, kv_trans.GetData failed, key: %s" + std::string((char *)key, key_pos));
}
+
core::Engine::DecodeInsertRecordToField(delta_record.data(), table->field);
}
@@ -96,31 +109,38 @@ common::ErrorCode DeltaTable::DropDeltaTable(const std::string &table_name) {
throw common::Exception("Normalized memtable name failed " + table_name);
return common::ErrorCode::FAILED;
}
- auto delta = ha_kvstore_->FindDeltaTable(normalized_name);
+
+ index::KVStore *store = (reinterpret_cast(tianmu_hton->data))->getStore();
+ auto delta = store->FindDeltaTable(normalized_name);
if (!delta)
return common::ErrorCode::SUCCESS;
TIANMU_LOG(LogCtl_Level::INFO, "Dropping RowStore: %s, CF ID: %d, RowStore ID: %u", normalized_name.c_str(),
delta->GetCFHandle()->GetID(), delta->GetDeltaTableID());
- return ha_kvstore_->KVDelDeltaMeta(normalized_name);
+ return store->KVDelDeltaMeta(normalized_name);
}
void DeltaTable::Init(uint64_t base_row_num) {
index::KVTransaction kv_trans;
uchar entry_key[sizeof(uint32_t)];
+
index::be_store_index(entry_key, delta_tid_);
+
rocksdb::Slice prefix((char *)entry_key, sizeof(uint32_t));
rocksdb::ReadOptions read_options;
read_options.total_order_seek = true;
std::unique_ptr iter(kv_trans.GetDataIterator(read_options, cf_handle_));
iter->Seek(prefix);
+
row_id.store(base_row_num);
- if (iter->Valid() && iter->key().starts_with(prefix)) {
+
+ while (iter->Valid() && iter->key().starts_with(prefix)) {
// row_id
auto type = *reinterpret_cast(const_cast(iter->value().data()));
if (type == RecordType::kInsert) {
row_id.fetch_add(1);
}
+
// load_id
uint32_t load_num = *reinterpret_cast(const_cast(iter->value().data()) + sizeof(RecordType));
load_id.fetch_add(load_num);
@@ -151,9 +171,9 @@ void DeltaTable::AddInsertRecord(Transaction *tx, uint64_t row_id, std::unique_p
kv_trans.Acquiresnapshot();
tx->ResetInsertRowNum();
}
- load_id++;
- stat.write_cnt++;
- stat.write_bytes += size;
+ load_id.fetch_add(1);
+ stat.write_cnt.fetch_add(1);
+ stat.write_bytes.fetch_add(size);
}
void DeltaTable::AddRecord(Transaction *tx, uint64_t row_id, std::unique_ptr buf, uint32_t size) {
@@ -172,9 +192,9 @@ void DeltaTable::AddRecord(Transaction *tx, uint64_t row_id, std::unique_ptr &attrs) : table_(table), attrs_(attrs) {
// get snapshot for rocksdb, snapshot will release when DeltaIterator is destructured
- auto snapshot = ha_kvstore_->GetRdbSnapshot();
+ index::KVStore *store = (reinterpret_cast(tianmu_hton->data))->getStore();
+ auto snapshot = store->GetRdbSnapshot();
+
rocksdb::ReadOptions read_options;
read_options.total_order_seek = true;
read_options.snapshot = snapshot;
- it_ = std::unique_ptr(ha_kvstore_->GetRdb()->NewIterator(read_options, table_->GetCFHandle()));
+ it_ = std::unique_ptr(store->GetRdb()->NewIterator(read_options, table_->GetCFHandle()));
+
uchar entry_key[sizeof(uint32_t)];
uint32_t table_id = table_->GetDeltaTableID();
index::be_store_index(entry_key, table_id);
rocksdb::Slice prefix = rocksdb::Slice((char *)entry_key, sizeof(uint32_t));
it_->Seek(prefix);
+
if (RdbKeyValid()) {
position_ = CurrentRowId();
start_position_ = position_;
@@ -259,6 +283,7 @@ bool DeltaIterator::operator!=(const DeltaIterator &other) { return !(*this == o
void DeltaIterator::Next() {
it_->Next();
+
if (RdbKeyValid()) {
position_ = CurrentRowId();
} else {
diff --git a/storage/tianmu/core/delta_table.h b/storage/tianmu/core/delta_table.h
index 9751c87df..b1d27f05d 100644
--- a/storage/tianmu/core/delta_table.h
+++ b/storage/tianmu/core/delta_table.h
@@ -22,13 +22,13 @@
#include "common/exception.h"
#include "core/delta_record_head.h"
-#include "core/tianmu_attr.h"
#include "index/kv_store.h"
#include "rocksdb/db.h"
#include "rocksdb/iterator.h"
#include "rocksdb/slice.h"
#include "types/tianmu_data_types.h"
#include "util/bitset.h"
+#include "vc/tianmu_attr.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/dimension_group.h b/storage/tianmu/core/dimension_group.h
index e8aeeb792..4968192d6 100644
--- a/storage/tianmu/core/dimension_group.h
+++ b/storage/tianmu/core/dimension_group.h
@@ -18,10 +18,10 @@
#define TIANMU_CORE_DIMENSION_GROUP_H_
#pragma once
-#include "core/bin_tools.h"
#include "core/dimension_vector.h"
-#include "core/filter.h"
-#include "core/index_table.h"
+#include "executor/filter.h"
+#include "index/index_table.h"
+#include "util/bin_tools.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/dimension_group_multiple.h b/storage/tianmu/core/dimension_group_multiple.h
index 2ae523d2f..442fbd117 100644
--- a/storage/tianmu/core/dimension_group_multiple.h
+++ b/storage/tianmu/core/dimension_group_multiple.h
@@ -20,10 +20,10 @@
#include
-#include "core/bin_tools.h"
#include "core/dimension_group.h"
-#include "core/filter.h"
-#include "core/index_table.h"
+#include "executor/filter.h"
+#include "index/index_table.h"
+#include "util/bin_tools.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/engine.cpp b/storage/tianmu/core/engine.cpp
index ab20bb40c..60ac7b280 100644
--- a/storage/tianmu/core/engine.cpp
+++ b/storage/tianmu/core/engine.cpp
@@ -28,10 +28,9 @@
#include "common/mysql_gate.h"
#include "core/delta_table.h"
#include "core/table_share.h"
-#include "core/task_executor.h"
#include "core/temp_table.h"
-#include "core/tools.h"
#include "core/transaction.h"
+#include "executor/task_executor.h"
#include "mm/initializer.h"
#include "mm/memory_statistics.h"
#include "mysql/thread_pool_priv.h"
@@ -43,6 +42,7 @@
#include "util/bitset.h"
#include "util/fs.h"
#include "util/thread_pool.h"
+#include "util/tools.h"
namespace Tianmu {
namespace DBHandler {
@@ -81,10 +81,11 @@ static int setup_sig_handler() {
fs::path Engine::GetNextDataDir() {
std::scoped_lock guard(v_mtx);
+ core::Engine *eng = reinterpret_cast(tianmu_hton->data);
if (tianmu_data_dirs.empty()) {
// fall back to use MySQL data directory
- auto p = ha_tianmu_engine_->tianmu_data_dir / TIANMU_DATA_DIR;
+ auto p = eng->tianmu_data_dir / TIANMU_DATA_DIR;
if (!fs::is_directory(p))
fs::create_directory(p);
return p;
@@ -117,6 +118,7 @@ fs::path Engine::GetNextDataDir() {
}
return v[std::rand() % v.size()];
}
+
// round-robin
static int idx = 0;
return tianmu_data_dirs[idx++ % sz];
@@ -127,22 +129,27 @@ static int has_pack(const LEX_STRING &comment) {
std::string str(comment.str, comment.length);
boost::to_upper(str);
std::string val;
+
auto pos = str.find("PACK");
if (pos == std::string::npos)
return ret;
+
size_t val_pos = str.find(':', pos);
if (val_pos == std::string::npos)
return ret;
+
size_t term_pos = str.find(';', val_pos);
if (term_pos == std::string::npos) {
val = str.substr(val_pos + 1);
} else {
val = str.substr(val_pos + 1, term_pos - val_pos - 1);
}
+
boost::trim(val);
ret = atoi(val.c_str());
if (ret > common::DFT_PSS || ret <= 0)
ret = common::DFT_PSS;
+
return ret;
}
@@ -150,12 +157,15 @@ static std::string has_mem_name(const LEX_STRING &comment) {
std::string name = "";
std::string str(comment.str, comment.length);
boost::to_upper(str);
+
auto pos = str.find("ROWSTORE");
if (pos == std::string::npos)
return name;
+
size_t val_pos = str.find(':', pos);
if (val_pos == std::string::npos)
return name;
+
size_t term_pos = str.find(';', val_pos);
if (term_pos == std::string::npos) {
name = str.substr(val_pos + 1);
@@ -199,27 +209,32 @@ Engine::Engine()
: std::thread::hardware_concurrency()),
insert_buffer(BUFFER_FILE, tianmu_sysvar_insert_buffer_size) {
tianmu_data_dir = mysql_real_data_home;
+ store_ = nullptr;
}
int Engine::Init(uint engine_slot) {
m_slot = engine_slot;
ConfigureRCControl();
+
if (tianmu_sysvar_controlquerylog > 0) {
tianmu_querylog_.setOn();
} else {
tianmu_querylog_.setOff();
}
+
std::srand(unsigned(time(nullptr)));
if (tianmu_sysvar_servermainheapsize == 0) {
long pages = sysconf(_SC_PHYS_PAGES);
long pagesize = sysconf(_SC_PAGESIZE);
+
if (pagesize > 0 && pages > 0) {
tianmu_sysvar_servermainheapsize = pages * pagesize / 1_MB / 2;
} else {
tianmu_sysvar_servermainheapsize = 10000;
}
}
+
size_t main_size = size_t(tianmu_sysvar_servermainheapsize) << 20;
std::string hugefiledir = tianmu_sysvar_hugefiledir;
@@ -236,13 +251,14 @@ int Engine::Init(uint engine_slot) {
boost::trim_if(cachefolder_path, boost::is_any_of("\""));
if (SetUpCacheFolder(cachefolder_path) != 0)
return 1;
+
system::ClearDirectory(cachefolder_path);
m_resourceManager = new system::ResourceManager();
// init the tianmu key-value store, aka, rocksdb engine.
- ha_kvstore_ = new index::KVStore();
- ha_kvstore_->Init();
+ store_ = new index::KVStore();
+ store_->Init();
#ifdef FUNCTIONS_EXECUTION_TIMES
fet = new FunctionsExecutionTimes();
@@ -275,9 +291,11 @@ int Engine::Init(uint engine_slot) {
[this]() {
for (auto &delta : m_table_deltas) {
TIANMU_LOG(LogCtl_Level::INFO,
- "delta table id: %d delta_size: %d, current load id: %d, merge id: %d, current row_id: %d",
- delta.second->GetDeltaTableID(), delta.second->load_id.load() - delta.second->merge_id.load(),
- delta.second->load_id.load(), delta.second->merge_id.load(), delta.second->row_id.load());
+ "table name: %s, delta table id: %d delta_size: %ld, current load id: %ld, merge id: %ld, "
+ "current row_id: %ld",
+ delta.second->FullName().c_str(), delta.second->GetDeltaTableID(),
+ delta.second->load_id.load() - delta.second->merge_id.load(), delta.second->load_id.load(),
+ delta.second->merge_id.load(), delta.second->row_id.load());
}
}},
{tianmu_sysvar_log_loop_interval * 5,
@@ -311,6 +329,7 @@ int Engine::Init(uint engine_slot) {
}
TIANMU_LOG(LogCtl_Level::INFO, "Tianmu monitor thread exiting...");
});
+
m_load_thread = std::thread([this] { ProcessInsertBufferMerge(); });
m_merge_thread = std::thread([this] { ProcessDeltaStoreMerge(); });
m_purge_thread = std::thread([this] {
@@ -378,8 +397,21 @@ Engine::~Engine() {
table_share_map.clear();
m_table_deltas.clear();
m_table_keys.clear();
- delete m_resourceManager;
- delete the_filter_block_owner;
+
+ if (m_resourceManager) {
+ delete m_resourceManager;
+ m_resourceManager = nullptr;
+ }
+
+ if (store_) {
+ delete store_;
+ store_ = nullptr;
+ }
+
+ if (the_filter_block_owner) {
+ delete the_filter_block_owner;
+ the_filter_block_owner = nullptr;
+ }
try {
mm::MemoryManagerInitializer::EnsureNoLeakedTraceableObject();
@@ -388,10 +420,8 @@ Engine::~Engine() {
} catch (...) {
TIANMU_LOG(LogCtl_Level::ERROR, "Unkown exception caught");
}
- if (tianmu_control_.isOn())
- mm::MemoryManagerInitializer::deinit(true);
- else
- mm::MemoryManagerInitializer::deinit(false);
+
+ mm::MemoryManagerInitializer::deinit(tianmu_control_.isOn() ? true : false);
TIANMU_LOG(LogCtl_Level::INFO, "Tianmu engine destroyed.");
}
@@ -738,14 +768,19 @@ uint32_t Engine::GetNextTableId() {
if (!fs::exists(p)) {
TIANMU_LOG(LogCtl_Level::INFO, "Creating table id file");
std::ofstream seq_file(p.string());
- if (seq_file)
+ if (seq_file) {
seq_file << 0;
+ seq_file.flush(); // sync to disk mandatory.
+ }
+
if (!seq_file) {
throw common::FileException("Failed to write to table id file");
}
+
+ return 0; // fast return if it's a new-created tianmu.tid file.
}
- uint32_t seq;
+ uint32_t seq{0};
std::fstream seq_file(p.string());
if (seq_file)
seq_file >> seq;
@@ -755,6 +790,7 @@ uint32_t Engine::GetNextTableId() {
seq++;
seq_file.seekg(0);
seq_file << seq;
+ seq_file.flush(); // sync to disk mandatory.
if (!seq_file) {
throw common::FileException("Failed to write to table id file");
}
@@ -920,9 +956,18 @@ AttributeTypeInfo Engine::GetAttrTypeInfo(const Field &field) {
}
void Engine::CommitTx(THD *thd, bool all) {
+ /*
+ Currently, the tianmu engine does not support manual transactions,
+ and there is a problem with the current determination of automatic commit.
+ After auto commit is turned off, tianmu will not commit the transaction.
+ Therefore, it is modified to the default automatic commit statement level transaction.
+ In the future, this logic will be modified after manual transactions are supported.
+
if (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT)) {
GetTx(thd)->Commit(thd);
}
+ */
+ GetTx(thd)->Commit(thd);
ClearTx(thd);
}
@@ -937,15 +982,20 @@ void Engine::Rollback(THD *thd, bool all, bool force_error_message) {
}
int Engine::DeleteTable(const char *table, [[maybe_unused]] THD *thd) {
+ DBUG_ENTER("Engine::DeleteTable");
+
{
std::unique_lock mem_guard(mem_table_mutex);
DeltaTable::DropDeltaTable(table);
m_table_deltas.erase(table);
}
+
if (DeleteTableIndex(table, thd)) {
TIANMU_LOG(LogCtl_Level::ERROR, "DeleteTable failed");
- return 1;
+ DBUG_RETURN(1);
}
+ DBUG_EXECUTE_IF("TIANMU_DELETE_TABLE_AFTER_INDEX", { DBUG_RETURN(1); });
+
UnRegisterTable(table);
std::string p = table;
p += common::TIANMU_EXT;
@@ -960,20 +1010,25 @@ int Engine::DeleteTable(const char *table, [[maybe_unused]] THD *thd) {
system::DeleteDirectory(p);
TIANMU_LOG(LogCtl_Level::INFO, "Drop table %s, ID = %u", table, id);
- return 0;
+ DBUG_RETURN(0);
}
void Engine::TruncateTable(const std::string &table_path, [[maybe_unused]] THD *thd) {
+ DBUG_ENTER("Engine::TruncateTable");
+
auto indextab = GetTableIndex(table_path);
if (indextab != nullptr) {
indextab->TruncateIndexTable();
}
+
auto tab = current_txn_->GetTableByPath(table_path);
tab->Truncate();
auto id = tab->GetID();
cache.ReleaseTable(id);
filter_cache.RemoveIf([id](const FilterCoordinate &c) { return c[0] == int(id); });
TIANMU_LOG(LogCtl_Level::INFO, "Truncated table %s, ID = %u", table_path.c_str(), id);
+
+ DBUG_VOID_RETURN;
}
std::shared_ptr Engine::GetTableRD(const std::string &table_path) {
@@ -1347,6 +1402,7 @@ static void HandleDelayedLoad(uint32_t table_id, std::vectoris_error() ? trans_rollback_stmt(thd) : trans_commit_stmt(thd);
thd->get_stmt_da()->set_overwrite_status(false);
close_thread_tables(thd);
+
if (thd->transaction_rollback_request) {
trans_rollback_implicit(thd);
thd->mdl_context.release_transactional_locks();
@@ -1359,17 +1415,22 @@ static void HandleDelayedLoad(uint32_t table_id, std::vectoris_fatal_error) {
TIANMU_LOG(LogCtl_Level::ERROR, "LOAD DATA failed on table '%s'", tab_name.c_str());
}
+
thd->release_resources();
thd_manager->remove_thd(thd);
delete thd;
+
my_thread_end();
}
void DistributeLoad(std::unordered_map>> &tm) {
utils::result_set res;
+ core::Engine *eng = reinterpret_cast(tianmu_hton->data);
+
for (auto &it : tm) {
- res.insert(ha_tianmu_engine_->bg_load_thread_pool.add_task(HandleDelayedLoad, it.first, std::ref(it.second)));
+ res.insert(eng->bg_load_thread_pool.add_task(HandleDelayedLoad, it.first, std::ref(it.second)));
}
+
res.get_all();
tm.clear();
}
@@ -1435,6 +1496,7 @@ void Engine::ProcessDeltaStoreMerge() {
while (!mysqld_server_started) {
struct timespec abstime;
set_timespec(&abstime, 1);
+
mysql_cond_timedwait(&COND_server_started, &LOCK_server_started, &abstime);
if (exiting) {
mysql_mutex_unlock(&LOCK_server_started);
@@ -1445,6 +1507,8 @@ void Engine::ProcessDeltaStoreMerge() {
std::map sleep_cnts;
TIANMU_LOG(LogCtl_Level::INFO, "Tianmu merge delta store thread start...");
+ core::Engine *eng = reinterpret_cast(tianmu_hton->data);
+
while (!exiting) {
if (!tianmu_sysvar_enable_rowstore) {
std::unique_lock lk(cv_merge_mtx);
@@ -1460,16 +1524,21 @@ void Engine::ProcessDeltaStoreMerge() {
uint64_t record_count = delta_table->CountRecords();
if ((record_count >= tianmu_sysvar_insert_numthreshold ||
(sleep_cnts.count(name) && sleep_cnts[name] > tianmu_sysvar_insert_cntthreshold))) {
- auto share = ha_tianmu_engine_->getTableShare(name);
+ auto share = eng->getTableShare(name);
auto table_id = share->TabID();
+
utils::BitSet null_mask(share->NumOfCols());
+
std::unique_ptr buf(new char[sizeof(uint32_t) + name.size() + 1 + null_mask.data_size()]);
char *ptr = buf.get();
*(uint32_t *)ptr = table_id; // table id
ptr += sizeof(uint32_t);
+
std::memcpy(ptr, name.c_str(), name.size());
ptr += name.size();
+
*ptr++ = 0; // end with NUL
+
std::memcpy(ptr, null_mask.data(), null_mask.data_size());
need_merge_table[table_id].emplace_back(std::move(buf));
sleep_cnts[name] = 0;
@@ -1492,6 +1561,7 @@ void Engine::ProcessDeltaStoreMerge() {
continue;
}
}
+
if (!need_merge_table.empty())
DistributeLoad(need_merge_table);
else {
@@ -1499,6 +1569,7 @@ void Engine::ProcessDeltaStoreMerge() {
cv_merge.wait_for(lk, std::chrono::milliseconds(tianmu_sysvar_insert_wait_ms));
}
}
+
TIANMU_LOG(LogCtl_Level::INFO, "Tianmu merge delta store thread exiting...");
}
@@ -1532,16 +1603,8 @@ void Engine::LogStat() {
// commands we are interested in
static const enum_sql_command cmds[] = {
- SQLCOM_SELECT,
- // SQLCOM_CREATE_TABLE,
- // SQLCOM_ALTER_TABLE,
- SQLCOM_UPDATE,
- SQLCOM_INSERT,
- // SQLCOM_INSERT_SELECT,
- // SQLCOM_DELETE,
- // SQLCOM_TRUNCATE,
- // SQLCOM_DROP_TABLE,
- SQLCOM_LOAD,
+ SQLCOM_SELECT, SQLCOM_CREATE_TABLE, SQLCOM_ALTER_TABLE, SQLCOM_UPDATE, SQLCOM_INSERT,
+ SQLCOM_INSERT_SELECT, SQLCOM_DELETE, SQLCOM_TRUNCATE, SQLCOM_DROP_TABLE, SQLCOM_LOAD,
};
STATUS_VAR sv;
@@ -1644,21 +1707,23 @@ void Engine::InsertDelayed(const std::string &table_path, TABLE *table) {
}
}
-void Engine::InsertToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table) {
+int Engine::InsertToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table) {
my_bitmap_map *org_bitmap = dbug_tmp_use_all_columns(table, table->read_set);
std::shared_ptr defer(nullptr,
[table, org_bitmap](...) { dbug_tmp_restore_column_map(table->read_set, org_bitmap); });
auto tm_table = share->GetSnapshot();
uint64_t row_id = tm_table->NextRowId();
// Insert primary key first
- tm_table->InsertIndexForDelta(table, row_id);
-
+ int ret = tm_table->InsertIndexForDelta(table, row_id);
+ if (ret != 0)
+ return ret;
// check & encode
uint32_t buf_sz = 0;
std::unique_ptr buf;
EncodeInsertRecord(table_path, table->field, table->s->fields, table->s->blob_fields, buf, buf_sz, table->in_use);
// insert to delta
tm_table->InsertToDelta(row_id, std::move(buf), buf_sz);
+ return ret;
}
void Engine::UpdateToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table,
@@ -1729,7 +1794,7 @@ int Engine::InsertRow(const std::string &table_path, [[maybe_unused]] Transactio
try {
if (tianmu_sysvar_insert_delayed && table->s->tmp_table == NO_TMP_TABLE) {
if (tianmu_sysvar_enable_rowstore) {
- InsertToDelta(table_path, share, table);
+ ret = InsertToDelta(table_path, share, table);
} else {
InsertDelayed(table_path, table);
}
@@ -1743,7 +1808,6 @@ int Engine::InsertRow(const std::string &table_path, [[maybe_unused]] Transactio
} catch (common::DupKeyException &e) {
ret = HA_ERR_FOUND_DUPP_KEY;
TIANMU_LOG(LogCtl_Level::ERROR, "delayed inserting failed: %s", e.what());
- my_message(static_cast(common::ErrorCode::DUPP_KEY), e.what(), MYF(0));
} catch (common::Exception &e) {
TIANMU_LOG(LogCtl_Level::ERROR, "delayed inserting failed. %s %s", e.what(), e.trace().c_str());
} catch (std::exception &e) {
@@ -1762,6 +1826,7 @@ int Engine::InsertRow(const std::string &table_path, [[maybe_unused]] Transactio
int Engine::UpdateRow(const std::string &table_path, TABLE *table, std::shared_ptr &share, uint64_t row_id,
const uchar *old_data, uchar *new_data) {
+ // DBUG_ENTER("Engine::UpdateRow");
int ret = 0;
if (tianmu_sysvar_insert_delayed && table->s->tmp_table == NO_TMP_TABLE && tianmu_sysvar_enable_rowstore) {
UpdateToDelta(table_path, share, table, row_id, old_data, new_data);
@@ -1771,14 +1836,12 @@ int Engine::UpdateRow(const std::string &table_path, TABLE *table, std::shared_p
ret = tm_table->Update(table, row_id, old_data, new_data);
}
return ret;
- if (tianmu_sysvar_insert_delayed) {
- tianmu_stat.failed_delta_update++;
- ret = 1;
- }
+ // DBUG_RETURN(ret);
}
int Engine::DeleteRow(const std::string &table_path, TABLE *table, std::shared_ptr &share,
uint64_t row_id) {
+ DBUG_ENTER("Engine::DeleteRow");
int ret = 0;
if (tianmu_sysvar_insert_delayed && table->s->tmp_table == NO_TMP_TABLE && tianmu_sysvar_enable_rowstore) {
DeleteToDelta(share, table, row_id);
@@ -1787,11 +1850,8 @@ int Engine::DeleteRow(const std::string &table_path, TABLE *table, std::shared_p
auto tm_table = current_txn_->GetTableByPath(table_path);
ret = tm_table->Delete(table, row_id);
}
- return ret;
- if (tianmu_sysvar_insert_delayed) {
- tianmu_stat.failed_delta_delete++;
- ret = 1;
- }
+
+ DBUG_RETURN(ret);
}
common::TianmuError Engine::RunLoader(THD *thd, sql_exchange *ex, TABLE_LIST *table_list, void *arg) {
@@ -1957,12 +2017,13 @@ std::unique_ptr Engine::CreateIOParameters(const std::stri
std::string data_dir;
std::string data_path;
+ core::Engine *eng = reinterpret_cast(tianmu_hton->data);
if (fs::path(path).is_absolute()) {
data_dir = "";
data_path = path;
} else {
- data_dir = ha_tianmu_engine_->tianmu_data_dir;
+ data_dir = eng->tianmu_data_dir;
std::string db_name, tab_name;
std::tie(db_name, tab_name) = GetNames(path);
data_path += db_name;
@@ -1997,6 +2058,7 @@ void Engine::ComputeTimeZoneDiffInMinutes(THD *thd, short &sign, short &minutes)
minutes = common::NULL_VALUE_SH;
return;
}
+
MYSQL_TIME client_zone, utc;
utc.year = 1970;
utc.month = 1;
@@ -2012,8 +2074,10 @@ void Engine::ComputeTimeZoneDiffInMinutes(THD *thd, short &sign, short &minutes)
long msecs;
sign = 1;
minutes = 0;
+
if (calc_time_diff(&utc, &client_zone, 1, &secs, &msecs))
sign = -1;
+
minutes = (short)(secs / 60);
}
@@ -2071,6 +2135,7 @@ common::TianmuError Engine::GetIOP(std::unique_ptr &io_par
tdb = (char *)thd.db().str;
io_params = CreateIOParameters(&thd, table, arg);
+
short sign, minutes;
ComputeTimeZoneDiffInMinutes(&thd, sign, minutes);
io_params->SetTimeZone(sign, minutes);
@@ -2141,10 +2206,10 @@ common::TianmuError Engine::GetIOP(std::unique_ptr &io_par
if (ex.field.escaped->alloced_length() != 0)
io_params->SetEscapeCharacter(*ex.field.escaped->ptr());
- if (ex.field.field_term->alloced_length() != 0)
+ if (ex.field.field_term->ptr() && strlen(ex.field.field_term->ptr()))
io_params->SetDelimiter(ex.field.field_term->ptr());
- if (ex.line.line_term->alloced_length() != 0)
+ if (ex.line.line_term->ptr() && strlen(ex.line.line_term->ptr()))
io_params->SetLineTerminator(ex.line.line_term->ptr());
if (ex.field.enclosed->length()) {
@@ -2229,7 +2294,10 @@ std::shared_ptr Engine::GetTableShare(const TABLE_SHARE *table_share
table_share_map[name] = share;
return share;
}
+
return it->second;
+ } catch (common::DatabaseException &e) {
+ TIANMU_LOG(LogCtl_Level::ERROR, "Failed to create table share: %s", e.getExceptionMsg());
} catch (common::Exception &e) {
TIANMU_LOG(LogCtl_Level::ERROR, "Failed to create table share: %s", e.what());
} catch (std::exception &e) {
@@ -2261,6 +2329,7 @@ bool Engine::DeleteTableIndex(const std::string &table_path, [[maybe_unused]] TH
if (index::TianmuTableIndex::FindIndexTable(table_path)) {
index::TianmuTableIndex::DropIndexTable(table_path);
}
+
if (m_table_keys.find(table_path) != m_table_keys.end()) {
m_table_keys.erase(table_path);
}
diff --git a/storage/tianmu/core/engine.h b/storage/tianmu/core/engine.h
index 1c90ece31..af38c6841 100644
--- a/storage/tianmu/core/engine.h
+++ b/storage/tianmu/core/engine.h
@@ -18,6 +18,7 @@
#define TIANMU_CORE_ENGINE_H_
#pragma once
+#include
#include
#include
#include
@@ -26,13 +27,13 @@
#include "common/assert.h"
#include "common/exception.h"
-#include "core/combined_iterator.h"
#include "core/data_cache.h"
#include "core/object_cache.h"
#include "core/query.h"
#include "core/table_share.h"
#include "core/temp_table.h"
#include "core/tianmu_table.h"
+#include "executor/combined_iterator.h"
#include "exporter/data_exporter.h"
#include "exporter/export2file.h"
#include "index/tianmu_table_index.h"
@@ -79,6 +80,8 @@ class Engine final {
~Engine();
int Init(uint engine_slot);
+ index::KVStore *getStore() const { return store_; }
+
void CreateTable(const std::string &table, TABLE *from, HA_CREATE_INFO *create_info);
int DeleteTable(const char *table, THD *thd);
void TruncateTable(const std::string &table_path, THD *thd);
@@ -117,7 +120,7 @@ class Engine final {
const uchar *old_data, uchar *new_data);
int DeleteRow(const std::string &tablename, TABLE *table, std::shared_ptr &share, uint64_t row_id);
void InsertDelayed(const std::string &table_path, TABLE *table);
- void InsertToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table);
+ int InsertToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table);
void UpdateToDelta(const std::string &table_path, std::shared_ptr &share, TABLE *table, uint64_t row_id,
const uchar *old_data, uchar *new_data);
void DeleteToDelta(std::shared_ptr &share, TABLE *table, uint64_t row_id);
@@ -176,6 +179,9 @@ class Engine final {
static const char *StrToFiled(const char *ptr, Field *field, DeltaRecordHead *deltaRecord, int col_num);
static char *FiledToStr(char *ptr, Field *field, DeltaRecordHead *deltaRecord, int col_num, THD *thd);
+ void setExtra(ha_extra_function extra) { extra_info = extra; }
+ ha_extra_function getExtra() { return extra_info; }
+
private:
void AddTx(Transaction *tx);
void RemoveTx(Transaction *tx);
@@ -241,6 +247,8 @@ class Engine final {
system::ResourceManager *m_resourceManager = nullptr;
uint m_slot = 0;
+ //?????
+ // atomic_uint32_t tableID_;
struct TrxCmp {
bool operator()(Transaction *l, Transaction *r) const;
@@ -282,6 +290,9 @@ class Engine final {
std::unique_ptr task_executor;
uint64_t m_mem_available_ = 0;
uint64_t m_swap_used_ = 0;
+ index::KVStore *store_;
+
+ ha_extra_function extra_info;
};
class ResultSender {
@@ -291,7 +302,7 @@ class ResultSender {
void Send(TempTable *t);
void Send(TempTable::RecordIterator &iter);
- void SendRow(const std::vector> &record, TempTable *owner);
+ void SendRow(std::vector> &record, TempTable *owner);
void SetLimits(int64_t *_offset, int64_t *_limit) {
offset = _offset;
@@ -304,12 +315,14 @@ class ResultSender {
void Finalize(TempTable *result);
int64_t SentRows() const { return rows_sent; }
+ public:
+ List- &fields;
+
protected:
THD *thd;
Query_result *res;
std::map items_backup;
uint *buf_lens;
- List
- &fields;
bool is_initialized;
int64_t *offset;
int64_t *limit;
@@ -317,7 +330,7 @@ class ResultSender {
int64_t affect_rows;
virtual void Init(TempTable *t);
- virtual void SendRecord(const std::vector> &record);
+ virtual void SendRecord(std::vector> &record);
};
class ResultExportSender final : public ResultSender {
@@ -329,7 +342,7 @@ class ResultExportSender final : public ResultSender {
protected:
void Init(TempTable *t) override;
- void SendRecord(const std::vector> &record) override;
+ void SendRecord(std::vector> &record) override;
exporter::select_tianmu_export *export_res_;
std::unique_ptr tianmu_data_exp_;
diff --git a/storage/tianmu/core/engine_execute.cpp b/storage/tianmu/core/engine_execute.cpp
index c8be65a3f..78fe836bd 100644
--- a/storage/tianmu/core/engine_execute.cpp
+++ b/storage/tianmu/core/engine_execute.cpp
@@ -19,8 +19,11 @@
#include
#include
-#include "core/compilation_tools.h"
-#include "core/compiled_query.h"
+#include "optimizer/compile//compiled_query.h"
+#include "optimizer/compile/compilation_tools.h"
+#include "optimizer/compile/compiler.h"
+#include "optimizer/plan/query_plan.h"
+
#include "core/engine.h"
#include "core/query.h"
#include "core/transaction.h"
@@ -71,12 +74,9 @@ class KillTimer {
/*
Handles a single query
-If an error appears during query preparation/optimization
-query structures are cleaned up and the function returns information about the
-error through res'. If the query can not be compiled by Tianmu engine
-QueryRouteTo::kToMySQL is returned and MySQL engine continues query
-execution.
-*/
+If an error appears during query preparation/optimization query structures are cleaned up and the function returns
+information about the error through res'. If the query can not be compiled by Tianmu engine QueryRouteTo::kToMySQL is
+returned and MySQL engine continues query execution.*/
QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulong setup_tables_done_option, int &res,
int &is_optimize_after_tianmu, int &tianmu_free_join, int with_insert) {
KillTimer timer(thd, tianmu_sysvar_max_execution_time);
@@ -111,35 +111,34 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
// at this point all tables are in RCBase engine, so we can proceed with the
// query and we know that if the result goes to the file, the TIANMU_DATAFORMAT is
// one of TIANMU formats
+ core::Engine *eng = reinterpret_cast(tianmu_hton->data);
QueryRouteTo route = QueryRouteTo::kToTianmu;
SELECT_LEX *save_current_select = lex->current_select();
- List derived_optimized; // collection to remember derived
- // tables that are optimized
+ List derived_optimized; // collection to remember derived tables that are optimized
+
if (thd->fill_derived_tables() && lex->derived_tables) {
- // Derived tables are processed completely in the function
- // open_and_lock_tables(...). To avoid execution of derived tables in
- // open_and_lock_tables(...) the function mysql_derived_filling(..)
- // optimizing and executing derived tables is passed over, then optimization
- // of derived tables must go here.
+ // Derived tables are processed completely in the function open_and_lock_tables(...). To avoid execution of derived
+ // tables in open_and_lock_tables(...) the function mysql_derived_filling(..) optimizing and executing derived
+ // tables is passed over, then optimization of derived tables must go here.
res = FALSE;
int tianmu_free_join = FALSE;
lex->thd->derived_tables_processing = TRUE;
+
for (SELECT_LEX *sl = lex->all_selects_list; sl; sl = sl->next_select_in_list()) // for all selects
for (TABLE_LIST *cursor = sl->get_table_list(); cursor; cursor = cursor->next_local) // for all tables
if (cursor->table && cursor->is_view_or_derived()) { // data source (view or FROM subselect)
// optimize derived table
SELECT_LEX *first_select = cursor->derived_unit()->first_select();
if (first_select->next_select() && first_select->next_select()->linkage == UNION_TYPE) { //?? only if union
- if (lex->is_explain() || cursor->derived_unit()->item) { //??called for explain
- // OR there is subselect(?)
+ if (lex->is_explain() || cursor->derived_unit()->item) { //??called for explain OR there is subselect(?)
route = QueryRouteTo::kToMySQL;
goto ret_derived;
}
+
if (!cursor->derived_unit()->is_executed() ||
- cursor->derived_unit()->uncacheable) { //??not already executed (not
- // materialized?)
- // OR not cacheable (meaning not yet in cache, i.e. not
- // materialized it seems to boil down to NOT MATERIALIZED(?)
+ cursor->derived_unit()->uncacheable) { //??not already executed (not materialized?)
+ // OR not cacheable (meaning not yet in cache, i.e. not materialized it seems to boil down to NOT
+ // MATERIALIZED(?)
res = cursor->derived_unit()->optimize_for_tianmu(); //===exec()
derived_optimized.push_back(cursor->derived_unit());
}
@@ -147,17 +146,21 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
cursor->derived_unit()->set_limit(first_select);
if (cursor->derived_unit()->select_limit_cnt == HA_POS_ERROR)
first_select->remove_base_options(OPTION_FOUND_ROWS);
+
lex->set_current_select(first_select);
int optimize_derived_after_tianmu = FALSE;
res = optimize_select(
thd, ulong(first_select->active_options() | thd->variables.option_bits | SELECT_NO_UNLOCK),
(Query_result *)cursor->derived_result, first_select, optimize_derived_after_tianmu, tianmu_free_join);
+
if (optimize_derived_after_tianmu)
derived_optimized.push_back(cursor->derived_unit());
}
+
lex->set_current_select(save_current_select);
if (!res && tianmu_free_join) // no error &
route = QueryRouteTo::kToMySQL;
+
if (res || route == QueryRouteTo::kToMySQL)
goto ret_derived;
}
@@ -167,6 +170,7 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
se = dynamic_cast(result);
if (se != nullptr)
result = new exporter::select_tianmu_export(se);
+
// prepare, optimize and execute the main query
select_lex = lex->select_lex;
unit = lex->unit;
@@ -174,11 +178,9 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
if (!(res = unit->prepare(thd, result, (ulong)(SELECT_NO_UNLOCK | setup_tables_done_option), 0))) {
// similar to mysql_union(...) from sql_union.cpp
- /* FIXME: create_table is private in mysql5.6
- select_create* sc = dynamic_cast(result);
- if (sc && sc->create_table->table && sc->create_table->table->db_stat
- != 0) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0),
- sc->create_table->table_name); res = 1; } else
+ /* FIXME: create_table is private in mysql5.6 select_create* sc = dynamic_cast(result);
+ if (sc && sc->create_table->table && sc->create_table->table->db_stat != 0) { my_error(ER_TABLE_EXISTS_ERROR,
+ MYF(0), sc->create_table->table_name); res = 1; } else
*/
if (lex->is_explain() || unit->item) // explain or sth was already computed - go to mysql
route = QueryRouteTo::kToMySQL;
@@ -188,18 +190,13 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
is_optimize_after_tianmu = TRUE;
if (!res) {
try {
- route = ha_tianmu_engine_->Execute(unit->thd, unit->thd->lex, result, unit);
+ route = eng->Execute(unit->thd, unit->thd->lex, result, unit);
if (route == QueryRouteTo::kToMySQL) {
if (in_case_of_failure_can_go_to_mysql)
- if (old_executed)
- unit->set_executed();
- else
- unit->reset_executed();
-
+ (old_executed) ? unit->set_executed() : unit->reset_executed();
else {
const char *err_msg =
- "Error: Query syntax not implemented in Tianmu, can "
- "export "
+ "Error: Query syntax not implemented in Tianmu, can export "
"only to MySQL format (set TIANMU_DATAFORMAT to 'MYSQL').";
TIANMU_LOG(LogCtl_Level::ERROR, err_msg);
my_message(ER_SYNTAX_ERROR, err_msg, MYF(0));
@@ -213,37 +210,34 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
}
}
}
+
if (res || route == QueryRouteTo::kToTianmu) {
res |= (int)unit->cleanup(0);
is_optimize_after_tianmu = FALSE;
}
} else {
- unit->set_limit(unit->global_parameters()); // the fragment of original
- // handle_select(...)
- //(until the first part of optimization)
- // used for non-union select
+ unit->set_limit(unit->global_parameters()); // the fragment of original handle_select(...)
+ //(until the first part of optimization) used for non-union select
- //'options' of mysql_select will be set in JOIN, as far as JOIN for
- // every PS/SP execution new, we will not need reset this flag if
- // setup_tables_done_option changed for next rexecution
+ //'options' of mysql_select will be set in JOIN, as far as JOIN for every PS/SP execution new, we will not need
+ // reset this flag if setup_tables_done_option changed for next rexecution
int err;
err = optimize_select(thd,
ulong(select_lex->active_options() | thd->variables.option_bits | setup_tables_done_option),
result, select_lex, is_optimize_after_tianmu, tianmu_free_join);
- // RCBase query engine entry point
+ // query engine entry point
if (!err) {
try {
route = Execute(thd, lex, result);
if (route == QueryRouteTo::kToMySQL && !in_case_of_failure_can_go_to_mysql) {
TIANMU_LOG(LogCtl_Level::ERROR,
- "Error: Query syntax not implemented in Tianmu, can export "
- "only to MySQL format (set TIANMU_DATAFORMAT to 'MYSQL').");
+ "Error: Query syntax not implemented in Tianmu, can export only to MySQL format (set "
+ "TIANMU_DATAFORMAT to 'MYSQL').");
my_message(ER_SYNTAX_ERROR,
- "Query syntax not implemented in Tianmu, can export only "
- "to MySQL "
- "format (set TIANMU_DATAFORMAT to 'MYSQL').",
+ "Query syntax not implemented in Tianmu, can export only to MySQL format (set TIANMU_DATAFORMAT "
+ "to 'MYSQL').",
MYF(0));
throw ReturnMeToMySQLWithError();
}
@@ -266,17 +260,16 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
}
if (select_lex->join && Query::IsLOJ(select_lex->join_list))
is_optimize_after_tianmu = TRUE; // optimize partially (phase=Doneoptimization), since part of LOJ
- // optimization was already done
- res |= (int)thd->is_error(); // the ending of original handle_select(...) */
+ // optimization was already done // the ending of original handle_select(...) */
+ res |= (int)thd->is_error();
if (unlikely(res)) {
// If we had a another error reported earlier then this will be ignored //
result->send_error(ER_UNKNOWN_ERROR, ER(ER_UNKNOWN_ERROR));
result->abort_result_set();
}
if (se != nullptr) {
- // free the tianmu export object,
- // restore the original mysql export object
- // and prepare if it is expected to be prepared
+ // free the tianmu export object, restore the original mysql export object and prepare if it is expected to be
+ // prepared
if (!select_lex->next_select() && select_lex->join != 0 && select_lex->query_result() == result) {
select_lex->set_query_result(se);
if (((exporter::select_tianmu_export *)result)->IsPrepared())
@@ -287,9 +280,8 @@ QueryRouteTo Engine::HandleSelect(THD *thd, LEX *lex, Query_result *&result, ulo
result = se;
}
ret_derived:
- // if the query is redirected to MySQL engine
- // optimization of derived tables must be completed
- // and derived tables must be filled
+ // if the query is redirected to MySQL engine optimization of derived tables must be completed and derived tables must
+ // be filled
if (route == QueryRouteTo::kToMySQL) {
for (SELECT_LEX *sl = lex->all_selects_list; sl; sl = sl->next_select_in_list())
for (TABLE_LIST *cursor = sl->get_table_list(); cursor; cursor = cursor->next_local)
@@ -341,12 +333,14 @@ int optimize_select(THD *thd, ulong select_options, Query_result *result, SELECT
}
if (!(join = new JOIN(thd, select_lex)))
return TRUE; /* purecov: inspected */
+
select_lex->set_join(join);
}
join->best_rowcount = 2;
is_optimize_after_tianmu = TRUE;
if ((err = join->optimize(OptimizePhase::Before_LOJ_Transform)))
return err;
+
return FALSE;
}
@@ -356,6 +350,7 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
DEBUG_ASSERT(thd->lex == lex);
SELECT_LEX *selects_list = lex->select_lex;
SELECT_LEX *last_distinct = nullptr;
+
if (unit_for_union != nullptr)
last_distinct = unit_for_union->union_distinct;
@@ -367,9 +362,10 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
return QueryRouteTo::kToMySQL;
}
- auto join_exec = ([&selects_list, &result_output] {
+ auto join_exec = ([&thd, &selects_list, &result_output] {
selects_list->set_query_result(result_output);
ASSERT(selects_list->join);
+ thd->lex->set_current_select(selects_list->join->select_lex);
selects_list->join->exec();
return QueryRouteTo::kToTianmu;
});
@@ -379,7 +375,7 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
List_iterator_fast
- li(selects_list->fields_list);
for (Item *item = li++; item; item = li++) {
if ((item->type() == Item::Type::FUNC_ITEM) &&
- (down_cast(item)->functype() == Item_func::Functype::FUNC_SP)) {
+ ((down_cast(item)->functype() == Item_func::Functype::FUNC_SP))) {
return join_exec();
}
}
@@ -422,10 +418,33 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
}
}
- for (SELECT_LEX *sl = selects_list; sl; sl = sl->next_select()) {
- if (sl->join->m_select_limit == 0) {
- exec_direct = true;
- break;
+ if (!exec_direct) {
+ for (SELECT_LEX *sl = selects_list; sl; sl = sl->next_select()) {
+ if ((!sl->join->m_select_limit) && (!sl->join->where_cond)) {
+ exec_direct = true;
+ break;
+ }
+ }
+ }
+
+ if (exec_direct) {
+ if ((selects_list->fields_list.elements)) {
+ List_iterator_fast
- li(selects_list->fields_list);
+ for (Item *item = li++; item; item = li++) {
+ if (Item::Type::FUNC_ITEM != item->type()) {
+ continue;
+ }
+
+ if (Item_func::Functype::SUSERVAR_FUNC == down_cast(item)->functype()) {
+ exec_direct = false;
+ break;
+ }
+
+ if (dynamic_cast(item)) {
+ exec_direct = false;
+ break;
+ }
+ }
}
}
@@ -463,6 +482,7 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
std::string table_path = Engine::GetTablePath(((Query_tables_list *)lex)->query_tables->table);
rct = current_txn_->GetTableByPathIfExists(table_path);
}
+
if ((unit_for_union != nullptr) && (lex->sql_command != SQLCOM_CREATE_TABLE)) { // for exclude CTAS
int res = result_output->prepare(unit_for_union->item_list, unit_for_union);
if (res) {
@@ -470,15 +490,16 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
my_message(ER_UNKNOWN_ERROR, "Tianmu: unsupported UNION", MYF(0));
throw ReturnMeToMySQLWithError();
}
- if (export_file_name)
- sender.reset(new ResultExportSender(unit_for_union->thd, result_output, unit_for_union->item_list));
- else
- sender.reset(new ResultSender(unit_for_union->thd, result_output, unit_for_union->item_list));
+
+ sender.reset(export_file_name
+ ? new ResultExportSender(unit_for_union->thd, result_output, unit_for_union->item_list)
+ : new ResultSender(unit_for_union->thd, result_output, unit_for_union->item_list));
+
} else {
- if (export_file_name)
- sender.reset(new ResultExportSender(selects_list->master_unit()->thd, result_output, selects_list->item_list));
- else
- sender.reset(new ResultSender(selects_list->master_unit()->thd, result_output, selects_list->item_list));
+ sender.reset(
+ export_file_name
+ ? new ResultExportSender(selects_list->master_unit()->thd, result_output, selects_list->item_list)
+ : new ResultSender(selects_list->master_unit()->thd, result_output, selects_list->item_list));
}
TempTable *result = query.Preexecute(cqu, sender.get());
@@ -500,6 +521,7 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
rct.reset();
}
sender.reset();
+
} catch (...) {
bool with_error = false;
if (sender) {
@@ -511,6 +533,7 @@ QueryRouteTo Engine::Execute(THD *thd, LEX *lex, Query_result *result_output, SE
}
return (handle_exceptions(thd, current_txn_, with_error));
}
+
return QueryRouteTo::kToTianmu;
}
@@ -522,12 +545,12 @@ QueryRouteTo handle_exceptions(THD *thd, Transaction *cur_connection, bool with_
throw;
} catch (common::NotImplementedException const &x) {
tianmu_control_.lock(cur_connection->GetThreadID()) << "Switched to MySQL: " << x.what() << system::unlock;
- my_message(ER_UNKNOWN_ERROR,
- (std::string("The query includes syntax that is not supported "
- "by the storage engine. Tianmu: ") +
- x.what())
- .c_str(),
- MYF(0));
+ my_message(
+ ER_UNKNOWN_ERROR,
+ (std::string("The query includes syntax that is not supported by the storage engine. Tianmu: ") + x.what())
+ .c_str(),
+ MYF(0));
+
if (with_error) {
std::string msg(x.what());
msg.append(" Can't switch to MySQL execution path");
@@ -569,6 +592,7 @@ QueryRouteTo handle_exceptions(THD *thd, Transaction *cur_connection, bool with_
}
return QueryRouteTo::kToMySQL;
}
+
} // namespace core
} // namespace Tianmu
@@ -619,8 +643,7 @@ int st_select_lex_unit::optimize_for_tianmu() {
set_limit(sl);
if (sl == global_parameters() || thd->lex->is_explain()) {
offset_limit_cnt = 0;
- // We can't use LIMIT at this stage if we are using ORDER BY for the
- // whole query
+ // We can't use LIMIT at this stage if we are using ORDER BY for the whole query
if (sl->order_list.first || thd->lex->is_explain())
select_limit_cnt = HA_POS_ERROR;
}
diff --git a/storage/tianmu/core/engine_results.cpp b/storage/tianmu/core/engine_results.cpp
index bba6a519d..8d0eb4dfa 100644
--- a/storage/tianmu/core/engine_results.cpp
+++ b/storage/tianmu/core/engine_results.cpp
@@ -240,7 +240,7 @@ void ResultSender::Send(TempTable::RecordIterator &iter) {
rows_sent++;
}
-void ResultSender::SendRow(const std::vector> &record, TempTable *owner) {
+void ResultSender::SendRow(std::vector> &record, TempTable *owner) {
if (current_txn_->Killed())
throw common::KilledException();
@@ -270,7 +270,7 @@ void ResultSender::SendRow(const std::vector> &r) {
+void ResultSender::SendRecord(std::vector> &r) {
Item *item;
Field *f;
Item_field *ifield;
@@ -297,7 +297,17 @@ void ResultSender::SendRecord(const std::vectortable->write_set, f->field_index);
- auto is_null = Engine::ConvertToField(f, tianmu_dt, nullptr);
+ auto is_null = false;
+ if (((f->type() == MYSQL_TYPE_VARCHAR) || (f->type() == MYSQL_TYPE_STRING) ||
+ (f->type() == MYSQL_TYPE_BLOB)) &&
+ (Tianmu::types::ValueTypeEnum::STRING_TYPE != tianmu_dt.GetValueType())) {
+ std::unique_ptr tianmu_dt_unq(new types::BString(tianmu_dt.ToBString()));
+ tianmu_dt_unq.swap(r[col_id]);
+ types::TianmuDataType &tianmu_dt_new(*r[col_id]);
+ is_null = Engine::ConvertToField(f, tianmu_dt_new, nullptr);
+ } else {
+ is_null = Engine::ConvertToField(f, tianmu_dt, nullptr);
+ }
SetFieldState(f, is_null);
}
break;
@@ -507,7 +517,7 @@ void ResultExportSender::Init(TempTable *t) {
}
// send to Exporter
-void ResultExportSender::SendRecord(const std::vector> &r) {
+void ResultExportSender::SendRecord(std::vector> &r) {
List_iterator_fast
- li(fields);
Item *l_item;
li.rewind();
diff --git a/storage/tianmu/core/ftree.h b/storage/tianmu/core/ftree.h
index 679e53c7f..6dd182c87 100644
--- a/storage/tianmu/core/ftree.h
+++ b/storage/tianmu/core/ftree.h
@@ -20,9 +20,9 @@
#define TIANMU_CORE_FTREE_H_
#pragma once
-#include "core/bin_tools.h"
#include "mm/traceable_object.h"
#include "types/tianmu_data_types.h"
+#include "util/bin_tools.h"
#include "util/fs.h"
namespace Tianmu {
diff --git a/storage/tianmu/core/hash_table.cpp b/storage/tianmu/core/hash_table.cpp
index dea5cc62b..9a7978f95 100644
--- a/storage/tianmu/core/hash_table.cpp
+++ b/storage/tianmu/core/hash_table.cpp
@@ -19,8 +19,8 @@
#include "common/assert.h"
#include "core/hash_table.h"
-#include "core/rough_multi_index.h"
#include "core/transaction.h"
+#include "index/rough_multi_index.h"
#include "system/fet.h"
namespace Tianmu {
diff --git a/storage/tianmu/core/hash_table.h b/storage/tianmu/core/hash_table.h
index 3baa980a4..aa2b23e0b 100644
--- a/storage/tianmu/core/hash_table.h
+++ b/storage/tianmu/core/hash_table.h
@@ -22,8 +22,8 @@
#include
#include "base/util/spinlock.h"
-#include "core/bin_tools.h"
#include "mm/traceable_object.h"
+#include "util/bin_tools.h"
namespace Tianmu {
namespace core {
diff --git a/storage/tianmu/core/item_tianmu_field.cpp b/storage/tianmu/core/item_tianmu_field.cpp
index 090a5c89d..e567d5563 100644
--- a/storage/tianmu/core/item_tianmu_field.cpp
+++ b/storage/tianmu/core/item_tianmu_field.cpp
@@ -18,9 +18,9 @@
#include "item_tianmu_field.h"
#include "common/assert.h"
-#include "core/compilation_tools.h"
#include "core/quick_math.h"
#include "core/transaction.h"
+#include "optimizer/compile/compilation_tools.h"
namespace Tianmu {
namespace core {
@@ -238,6 +238,7 @@ Item_tianmudecimal::Item_tianmudecimal(DataType t) : Item_decimal(0, false) {
}
void Item_tianmudecimal::Set(int64_t val) {
+ std::scoped_lock guard(mtx);
std::fill(decimal_value.buf, decimal_value.buf + decimal_value.len, 0);
if (val) {
int2my_decimal((uint)-1, val, 0, &decimal_value);
@@ -248,6 +249,11 @@ void Item_tianmudecimal::Set(int64_t val) {
decimal_value.frac = scale;
}
+String *Item_tianmudecimal::val_str(String *str) {
+ std::scoped_lock guard(mtx);
+ return Item_decimal::val_str(str);
+}
+
my_decimal *Item_tianmudatetime_base::val_decimal(my_decimal *d) {
int2my_decimal((uint)-1, val_int(), 0, d);
return d;
@@ -260,8 +266,10 @@ bool Item_tianmudatetime_base::get_time(MYSQL_TIME *ltime) {
}
longlong Item_tianmudatetime::val_int() {
- return dt.year * 10000000000LL + dt.month * 100000000 + dt.day * 1000000 + dt.hour * 10000 + dt.minute * 100 +
- dt.second;
+ MYSQL_TIME ltime;
+ dt.Store(<ime, MYSQL_TIMESTAMP_DATETIME);
+ longlong tmp = (longlong)TIME_to_ulonglong_datetime_round(<ime);
+ return dt.Neg() ? -tmp : tmp;
}
String *Item_tianmudatetime::val_str(String *s) {
@@ -311,7 +319,12 @@ bool Item_tianmudate::get_time(MYSQL_TIME *ltime) {
return false;
}
-longlong Item_tianmutime::val_int() { return dt.hour * 10000 + dt.minute * 100 + dt.second; }
+longlong Item_tianmutime::val_int() {
+ MYSQL_TIME ltime;
+ dt.Store(<ime, MYSQL_TIMESTAMP_TIME);
+ longlong tmp = (longlong)TIME_to_ulonglong_time_round(<ime);
+ return dt.Neg() ? -tmp : tmp;
+}
String *Item_tianmutime::val_str(String *s) {
MYSQL_TIME ltime;
get_time(<ime);
diff --git a/storage/tianmu/core/item_tianmu_field.h b/storage/tianmu/core/item_tianmu_field.h
index a2e834054..f72bbe0ec 100644
--- a/storage/tianmu/core/item_tianmu_field.h
+++ b/storage/tianmu/core/item_tianmu_field.h
@@ -19,12 +19,13 @@
#pragma once
#include