Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita9101d1

Browse files
committed
add regression tests for copied foreign keys
1 parent562cab6 commita9101d1

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

‎expected/pg_pathman.out

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,3 +1707,62 @@ EXPLAIN (COSTS OFF) SELECT * FROM messages;
17071707
-> Seq Scan on messages_2
17081708
(3 rows)
17091709

1710+
/* Check primary keys generation */
1711+
CREATE TABLE test_ref(comment TEXT UNIQUE);
1712+
INSERT INTO test_ref VALUES('test');
1713+
CREATE TABLE test_fkey(
1714+
idINT NOT NULL,
1715+
commentTEXT,
1716+
FOREIGN KEY (comment) REFERENCES test_ref(comment));
1717+
INSERT INTO test_fkey SELECT generate_series(1, 1000), 'test';
1718+
SELECT create_range_partitions('test_fkey', 'id', 1, 100);
1719+
NOTICE: sequence "test_fkey_seq" does not exist, skipping
1720+
create_range_partitions
1721+
-------------------------
1722+
10
1723+
(1 row)
1724+
1725+
INSERT INTO test_fkey VALUES(1, 'wrong');
1726+
ERROR: insert or update on table "test_fkey_1" violates foreign key constraint "test_fkey_1_comment_fkey"
1727+
SELECT drop_partitions('test_fkey');
1728+
NOTICE: function public.test_fkey_upd_trig_func() does not exist, skipping
1729+
NOTICE: 100 rows copied from test_fkey_10
1730+
NOTICE: 100 rows copied from test_fkey_9
1731+
NOTICE: 100 rows copied from test_fkey_8
1732+
NOTICE: 100 rows copied from test_fkey_7
1733+
NOTICE: 100 rows copied from test_fkey_6
1734+
NOTICE: 100 rows copied from test_fkey_5
1735+
NOTICE: 100 rows copied from test_fkey_4
1736+
NOTICE: 100 rows copied from test_fkey_3
1737+
NOTICE: 100 rows copied from test_fkey_2
1738+
NOTICE: 100 rows copied from test_fkey_1
1739+
drop_partitions
1740+
-----------------
1741+
10
1742+
(1 row)
1743+
1744+
SELECT create_hash_partitions('test_fkey', 'id', 10);
1745+
create_hash_partitions
1746+
------------------------
1747+
10
1748+
(1 row)
1749+
1750+
INSERT INTO test_fkey VALUES(1, 'wrong');
1751+
ERROR: insert or update on table "test_fkey_0" violates foreign key constraint "test_fkey_0_comment_fkey"
1752+
SELECT drop_partitions('test_fkey');
1753+
NOTICE: function public.test_fkey_upd_trig_func() does not exist, skipping
1754+
NOTICE: 94 rows copied from test_fkey_9
1755+
NOTICE: 108 rows copied from test_fkey_8
1756+
NOTICE: 118 rows copied from test_fkey_7
1757+
NOTICE: 95 rows copied from test_fkey_6
1758+
NOTICE: 90 rows copied from test_fkey_5
1759+
NOTICE: 101 rows copied from test_fkey_4
1760+
NOTICE: 116 rows copied from test_fkey_3
1761+
NOTICE: 90 rows copied from test_fkey_2
1762+
NOTICE: 90 rows copied from test_fkey_1
1763+
NOTICE: 98 rows copied from test_fkey_0
1764+
drop_partitions
1765+
-----------------
1766+
10
1767+
(1 row)
1768+

‎sql/pg_pathman.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,3 +644,23 @@ SELECT create_range_partitions('messages', 'id', 1, 100, 2);
644644
ALTERTABLE replies DROPCONSTRAINT replies_message_id_fkey;
645645
SELECT create_range_partitions('messages','id',1,100,2);
646646
EXPLAIN (COSTS OFF)SELECT*FROM messages;
647+
648+
/* Check primary keys generation*/
649+
CREATETABLEtest_ref(commentTEXT UNIQUE);
650+
INSERT INTO test_refVALUES('test');
651+
652+
CREATETABLEtest_fkey(
653+
idINTNOT NULL,
654+
commentTEXT,
655+
FOREIGN KEY (comment)REFERENCES test_ref(comment));
656+
657+
INSERT INTO test_fkeySELECT generate_series(1,1000),'test';
658+
659+
SELECT create_range_partitions('test_fkey','id',1,100);
660+
INSERT INTO test_fkeyVALUES(1,'wrong');
661+
INSERT INTO test_fkeyVALUES(1,'test');
662+
SELECT drop_partitions('test_fkey');
663+
664+
SELECT create_hash_partitions('test_fkey','id',10);
665+
INSERT INTO test_fkeyVALUES(1,'test');
666+
SELECT drop_partitions('test_fkey');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp