@@ -1707,3 +1707,62 @@ EXPLAIN (COSTS OFF) SELECT * FROM messages;
1707
1707
-> Seq Scan on messages_2
1708
1708
(3 rows)
1709
1709
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
+