This repository has been archived by the owner on Dec 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add generated columns test case
- Loading branch information
Showing
8 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create schema gencol; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
create table nested ( | ||
a int not null primary key, | ||
b int as (a + 1) virtual unique, | ||
c int as (b + 1) stored unique, | ||
d int as (c + 1) virtual unique, | ||
e int as (d + 1) stored unique | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
insert into nested (a) values (1), (10), (100), (1000); |
15 changes: 15 additions & 0 deletions
15
tests/generated_columns/data/gencol.various_types-schema.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
create table various_types ( | ||
int64 bigint as (1 + 2) stored, | ||
uint64 bigint unsigned as (pow(7, 8)) stored, -- 5764801 | ||
float32 float as (9 / 16) stored, | ||
float64 double as (5e222) stored, | ||
string text as (sha1(repeat('x', uint64))) stored, -- '6ad8402ba6610f04d3ec5c9875489a7bc8e259c5' | ||
bytes blob as (unhex(string)) stored, | ||
`decimal` decimal(8, 4) as (1234.5678) stored, | ||
duration time as ('1:2:3') stored, | ||
enum enum('a','b','c') as ('c') stored, | ||
bit bit(4) as (int64) stored, | ||
`set` set('a','b','c') as (enum) stored, | ||
time timestamp(3) as ('1987-06-05 04:03:02.100') stored, | ||
json json as (json_object(string, float32)) stored | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
insert into various_types () values (); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
|
||
for BACKEND in 'tidb' 'importer' 'local'; do | ||
if [ "$BACKEND" = 'local' ]; then | ||
check_cluster_version 4 0 0 'local backend' || continue | ||
fi | ||
|
||
run_sql 'DROP DATABASE IF EXISTS gencol' | ||
|
||
run_lightning --backend $BACKEND | ||
|
||
run_sql 'SELECT * FROM gencol.nested WHERE a = 100' | ||
check_contains 'a: 100' | ||
check_contains 'b: 101' | ||
check_contains 'c: 102' | ||
check_contains 'd: 103' | ||
check_contains 'e: 104' | ||
|
||
run_sql --binary-as-hex 'SELECT * FROM gencol.various_types' | ||
check_contains 'int64: 3' | ||
check_contains 'uint64: 5764801' | ||
check_contains 'float32: 0.5625' | ||
check_contains 'float64: 5e222' | ||
check_contains 'string: 6ad8402ba6610f04d3ec5c9875489a7bc8e259c5' | ||
check_contains 'bytes: 0x6AD8402BA6610F04D3EC5C9875489A7BC8E259C5' | ||
check_contains 'decimal: 1234.5678' | ||
check_contains 'duration: 01:02:03' | ||
check_contains 'enum: c' | ||
check_contains 'bit: 0x03' | ||
check_contains 'set: c' | ||
check_contains 'time: 1987-06-05 04:03:02.100' | ||
check_contains 'json: {"6ad8402ba6610f04d3ec5c9875489a7bc8e259c5": 0.5625}' | ||
done |