diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:00:34 +0000 |
commit | 3f619478f796eddbba6e39502fe941b285dd97b1 (patch) | |
tree | e2c7b5777f728320e5b5542b6213fd3591ba51e2 /mysql-test/main/win_insert_select.test | |
parent | Initial commit. (diff) | |
download | mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.tar.xz mariadb-3f619478f796eddbba6e39502fe941b285dd97b1.zip |
Adding upstream version 1:10.11.6.upstream/1%10.11.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/main/win_insert_select.test')
-rw-r--r-- | mysql-test/main/win_insert_select.test | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/mysql-test/main/win_insert_select.test b/mysql-test/main/win_insert_select.test new file mode 100644 index 00000000..6b2e0da4 --- /dev/null +++ b/mysql-test/main/win_insert_select.test @@ -0,0 +1,79 @@ +CREATE TABLE t1 (c1 INT, c2 VARCHAR(30)); + +PREPARE populate_table FROM "INSERT into t1 values (1, 'manual_insert_1'), + (4, 'manual_insert_2')"; + +INSERT INTO t1 SELECT row_number() over(), "should_not_add_any_rows" FROM t1; +INSERT INTO t1 SELECT 1 + row_number() over(), "should_not_add_any_rows" FROM t1; + +EXECUTE populate_table; + +INSERT INTO t1 SELECT 10 + row_number() over(), "should repeat 2 times [11-12]" FROM t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + + +INSERT INTO t1 + SELECT 10 + (dense_rank() over(order by c1)), "dense_rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 100 + (rank() over(order by c1)), "rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 100 + (ntile(10) over(order by c1)), "ntile_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (percent_rank() over(order by c1)), "percent_rank_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (count(*) over(order by c1)), "count_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +--echo # +--echo # Test how avg interacts when the results need to be rounded. +--echo # +SELECT 1000 + (avg(c1) over(order by c1)) as avg_expr, c1, "This will be inserted into t1" from t1; + +INSERT INTO t1 + SELECT 1000 + (avg(c1) over(order by c1)), "avg_insert" from t1; + +SELECT c1, c2 FROM t1 ORDER BY c2, c1; + +DELETE FROM t1; +EXECUTE populate_table; + +INSERT INTO t1 + SELECT 1000 + (sum(c1) over(order by c1)), "sum_insert" from t1; + +SELECT c1, c2 +FROM t1 +ORDER BY c2, c1; + +DROP table t1; |