|
| 1 | +\set VERBOSITY terse |
| 2 | +CREATE EXTENSION pg_pathman; |
| 3 | +CREATE SCHEMA copy_stmt_hooking; |
| 4 | +CREATE TABLE copy_stmt_hooking.test(val int not null, comment text); |
| 5 | +INSERT INTO copy_stmt_hooking.test SELECT generate_series(1, 20), 'comment'; |
| 6 | +/* test for RANGE partitioning */ |
| 7 | +SELECT create_range_partitions('copy_stmt_hooking.test', 'val', 1, 5); |
| 8 | +NOTICE: sequence "test_seq" does not exist, skipping |
| 9 | + create_range_partitions |
| 10 | +------------------------- |
| 11 | + 4 |
| 12 | +(1 row) |
| 13 | + |
| 14 | +/* perform VACUUM */ |
| 15 | +VACUUM FULL copy_stmt_hooking.test_1; |
| 16 | +VACUUM FULL copy_stmt_hooking.test_2; |
| 17 | +VACUUM FULL copy_stmt_hooking.test_3; |
| 18 | +VACUUM FULL copy_stmt_hooking.test_4; |
| 19 | +/* COPY TO */ |
| 20 | +COPY copy_stmt_hooking.test TO stdout; |
| 21 | +1 comment |
| 22 | +2 comment |
| 23 | +3 comment |
| 24 | +4 comment |
| 25 | +5 comment |
| 26 | +6 comment |
| 27 | +7 comment |
| 28 | +8 comment |
| 29 | +9 comment |
| 30 | +10 comment |
| 31 | +11 comment |
| 32 | +12 comment |
| 33 | +13 comment |
| 34 | +14 comment |
| 35 | +15 comment |
| 36 | +16 comment |
| 37 | +17 comment |
| 38 | +18 comment |
| 39 | +19 comment |
| 40 | +20 comment |
| 41 | +\copy copy_stmt_hooking.test to stdout (format csv) |
| 42 | +1,comment |
| 43 | +2,comment |
| 44 | +3,comment |
| 45 | +4,comment |
| 46 | +5,comment |
| 47 | +6,comment |
| 48 | +7,comment |
| 49 | +8,comment |
| 50 | +9,comment |
| 51 | +10,comment |
| 52 | +11,comment |
| 53 | +12,comment |
| 54 | +13,comment |
| 55 | +14,comment |
| 56 | +15,comment |
| 57 | +16,comment |
| 58 | +17,comment |
| 59 | +18,comment |
| 60 | +19,comment |
| 61 | +20,comment |
| 62 | +\copy copy_stmt_hooking.test(comment) to stdout |
| 63 | +comment |
| 64 | +comment |
| 65 | +comment |
| 66 | +comment |
| 67 | +comment |
| 68 | +comment |
| 69 | +comment |
| 70 | +comment |
| 71 | +comment |
| 72 | +comment |
| 73 | +comment |
| 74 | +comment |
| 75 | +comment |
| 76 | +comment |
| 77 | +comment |
| 78 | +comment |
| 79 | +comment |
| 80 | +comment |
| 81 | +comment |
| 82 | +comment |
| 83 | +/* DELETE ROWS, COPY FROM */ |
| 84 | +DELETE FROM copy_stmt_hooking.test; |
| 85 | +COPY copy_stmt_hooking.test FROM stdin; |
| 86 | +SELECT count(*) FROM ONLY copy_stmt_hooking.test; |
| 87 | + count |
| 88 | +------- |
| 89 | + 0 |
| 90 | +(1 row) |
| 91 | + |
| 92 | +SELECT *, tableoid::REGCLASS FROM copy_stmt_hooking.test ORDER BY val; |
| 93 | + val | comment | tableoid |
| 94 | +-----+---------+-------------------------- |
| 95 | + 1 | test_1 | copy_stmt_hooking.test_1 |
| 96 | + 6 | test_2 | copy_stmt_hooking.test_2 |
| 97 | + 7 | test_2 | copy_stmt_hooking.test_2 |
| 98 | + 11 | test_3 | copy_stmt_hooking.test_3 |
| 99 | + 16 | test_4 | copy_stmt_hooking.test_4 |
| 100 | +(5 rows) |
| 101 | + |
| 102 | +/* COPY TO (partition does not exist) */ |
| 103 | +COPY copy_stmt_hooking.test FROM stdin; |
| 104 | +ERROR: no suitable partition for key '21' |
| 105 | +COPY copy_stmt_hooking.test(comment) FROM stdin; |
| 106 | +ERROR: partitioned column's value should not be NULL |
| 107 | +/* delete all data */ |
| 108 | +SELECT drop_partitions('copy_stmt_hooking.test', true); |
| 109 | +NOTICE: function copy_stmt_hooking.test_upd_trig_func() does not exist, skipping |
| 110 | + drop_partitions |
| 111 | +----------------- |
| 112 | + 4 |
| 113 | +(1 row) |
| 114 | + |
| 115 | +/* test for HASH partitioning */ |
| 116 | +SELECT create_hash_partitions('copy_stmt_hooking.test', 'val', 5); |
| 117 | + create_hash_partitions |
| 118 | +------------------------ |
| 119 | + 5 |
| 120 | +(1 row) |
| 121 | + |
| 122 | +/* DELETE ROWS, COPY FROM */ |
| 123 | +DELETE FROM copy_stmt_hooking.test; |
| 124 | +COPY copy_stmt_hooking.test FROM stdin; |
| 125 | +SELECT count(*) FROM ONLY copy_stmt_hooking.test; |
| 126 | + count |
| 127 | +------- |
| 128 | + 0 |
| 129 | +(1 row) |
| 130 | + |
| 131 | +SELECT * FROM copy_stmt_hooking.test ORDER BY val; |
| 132 | + val | comment |
| 133 | +-----+--------- |
| 134 | + 1 | hash_1 |
| 135 | + 6 | hash_2 |
| 136 | +(2 rows) |
| 137 | + |
| 138 | +DROP SCHEMA copy_stmt_hooking CASCADE; |
| 139 | +NOTICE: drop cascades to 7 other objects |
| 140 | +DROP EXTENSION pg_pathman; |
0 commit comments