aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/tests/postgresql/cases/truncate.out
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 14:11:52 +0300
committerudovichenko-r <udovichenko-r@yandex-team.com>2024-11-19 14:22:01 +0300
commit72b3cd51dc3fb9d16975d353ea82fd85701393cc (patch)
tree318141940b8bf6bdb37ad6154e745e2ebfe3613f /yql/essentials/tests/postgresql/cases/truncate.out
parent223625eed56ec3e2808c010eac46dba1c9a64d13 (diff)
downloadydb-72b3cd51dc3fb9d16975d353ea82fd85701393cc.tar.gz
YQL-19206 Move contrib/ydb/library/yql/tests/postgresql -> yql/essentials/tests/postgresql
commit_hash:46fdf59714b20cf2b61233a06e58365227d3c8b2
Diffstat (limited to 'yql/essentials/tests/postgresql/cases/truncate.out')
-rw-r--r--yql/essentials/tests/postgresql/cases/truncate.out87
1 files changed, 87 insertions, 0 deletions
diff --git a/yql/essentials/tests/postgresql/cases/truncate.out b/yql/essentials/tests/postgresql/cases/truncate.out
new file mode 100644
index 0000000000..4468549224
--- /dev/null
+++ b/yql/essentials/tests/postgresql/cases/truncate.out
@@ -0,0 +1,87 @@
+-- Test basic TRUNCATE functionality.
+CREATE TABLE truncate_a (col1 integer primary key);
+INSERT INTO truncate_a VALUES (1);
+INSERT INTO truncate_a VALUES (2);
+SELECT * FROM truncate_a;
+ col1
+------
+ 1
+ 2
+(2 rows)
+
+-- Roll truncate back
+BEGIN;
+ROLLBACK;
+SELECT * FROM truncate_a;
+ col1
+------
+ 1
+ 2
+(2 rows)
+
+-- Commit the truncate this time
+BEGIN;
+COMMIT;
+CREATE TABLE trunc_c (a serial PRIMARY KEY);
+-- Add some data to verify that truncating actually works ...
+INSERT INTO trunc_c VALUES (1);
+INSERT INTO truncate_a VALUES (1);
+-- Add data again to test TRUNCATE ... CASCADE
+INSERT INTO trunc_c VALUES (1);
+INSERT INTO truncate_a VALUES (1);
+-- Test TRUNCATE with inheritance
+CREATE TABLE trunc_f (col1 integer primary key);
+INSERT INTO trunc_f VALUES (1);
+INSERT INTO trunc_f VALUES (2);
+BEGIN;
+ROLLBACK;
+BEGIN;
+ROLLBACK;
+BEGIN;
+ROLLBACK;
+BEGIN;
+SELECT * FROM trunc_f;
+ col1
+------
+ 1
+ 2
+(2 rows)
+
+ROLLBACK;
+-- Test ON TRUNCATE triggers
+CREATE TABLE trunc_trigger_test (f1 int, f2 text, f3 text);
+CREATE TABLE trunc_trigger_log (tgop text, tglevel text, tgwhen text,
+ tgargv text, tgtable name, rowcount bigint);
+-- basic before trigger
+INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux');
+SELECT count(*) as "Row count in test table" FROM trunc_trigger_test;
+ Row count in test table
+-------------------------
+ 2
+(1 row)
+
+SELECT * FROM trunc_trigger_log;
+ tgop | tglevel | tgwhen | tgargv | tgtable | rowcount
+------+---------+--------+--------+---------+----------
+(0 rows)
+
+-- same test with an after trigger
+INSERT INTO trunc_trigger_test VALUES(1, 'foo', 'bar'), (2, 'baz', 'quux');
+SELECT * FROM trunc_trigger_log;
+ tgop | tglevel | tgwhen | tgargv | tgtable | rowcount
+------+---------+--------+--------+---------+----------
+(0 rows)
+
+DROP TABLE trunc_trigger_test;
+DROP TABLE trunc_trigger_log;
+CREATE TABLE truncate_a (id serial,
+ id1 integer default nextval('truncate_a_id1'));
+-- check rollback of a RESTART IDENTITY operation
+BEGIN;
+ROLLBACK;
+DROP TABLE truncate_a;
+SELECT nextval('truncate_a_id1'); -- fail, seq should have been dropped
+ERROR: relation "truncate_a_id1" does not exist
+LINE 1: SELECT nextval('truncate_a_id1');
+ ^
+CREATE TABLE truncprim (a int PRIMARY KEY);