Skip to content

chore: add more transaction test #14746

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Feb 27, 2024
113 changes: 113 additions & 0 deletions tests/sqllogictests/suites/stage/copy_into_txn.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#################################################################################################################
# test avoiding duplicates when copy stage files into a table
#################################################################################################################

statement ok
create or replace database test_txn_copy;

statement ok
use test_txn_copy;

statement ok
create table t1(c int);

onlyif mysql
statement ok
begin;

query
copy into t1 from @data/csv/numbers.csv file_format = (type = CSV);
----
csv/numbers.csv 18 0 NULL NULL

query I
select count(*) from t1;
----
18

query
copy into t1 from @data/csv/numbers.csv file_format = (type = CSV);
----


query I
select count(*) from t1;
----
18

onlyif mysql
statement ok
commit;

query I
select count(*) from t1;
----
18

query
copy into t1 from @data/csv/numbers.csv file_format = (type = CSV);
----


query I
select count(*) from t1;
----
18

#################################################################################################################
# test when txn is aborted, the stage files are not purged
#################################################################################################################

statement ok
create or replace database test_txn_copy_1;

statement ok
use test_txn_copy_1;

statement ok
create table t1(c int);

onlyif mysql
statement ok
begin;

onlyif mysql
query
copy into t1 from @data/csv/numbers.csv file_format = (type = CSV) purge = true;
----
csv/numbers.csv 18 0 NULL NULL

onlyif mysql
statement error 1025
select * from t100;

onlyif mysql
statement error 4002
select * from t1;

onlyif mysql
statement ok
commit;

onlyif mysql
query I
select count(*) from t1;
----
0

onlyif mysql
statement ok
create table t2(c int);

onlyif mysql
query
copy into t2 from @data/csv/numbers.csv file_format = (type = CSV);
----
csv/numbers.csv 18 0 NULL NULL

onlyif mysql
query I
select count(*) from t2;
----
18