|
27 | 27 | temperature double precision null);
|
28 | 28 | }
|
29 | 29 | );
|
30 |
| -is($result, '', 'create table'); |
31 | 30 |
|
32 | 31 | # Create hypertable
|
33 | 32 | $result = $node->safe_psql(
|
34 | 33 | 'postgres', q{
|
35 |
| - SELECT FROM create_hypertable('sensor_data','time', chunk_time_interval => INTERVAL '1 month'); |
| 34 | + SELECT table_name FROM create_hypertable('sensor_data','time', chunk_time_interval => INTERVAL '1 month'); |
36 | 35 | }
|
37 | 36 | );
|
38 |
| -is($result, '', 'create hypertable'); |
| 37 | +is($result, 'sensor_data', 'create hypertable'); |
39 | 38 |
|
40 | 39 | # Insert data
|
41 | 40 | $result = $node->safe_psql(
|
|
52 | 51 | ORDER BY time;
|
53 | 52 | }
|
54 | 53 | );
|
55 |
| -is($result, '', 'insert data'); |
56 | 54 |
|
57 | 55 | # Define count query
|
58 | 56 | my $count_query = "SELECT count(*) FROM sensor_data;";
|
|
72 | 70 | ALTER TABLE sensor_data SET (timescaledb.compress, timescaledb.compress_segmentby = 'sensor_id');
|
73 | 71 | }
|
74 | 72 | );
|
75 |
| -is($result, '', 'enable compression'); |
76 | 73 |
|
77 | 74 | # Get number of chunks
|
78 | 75 | my $n_chunks = $node->safe_psql(
|
|
87 | 84 | # SET session 1 behaviour to `truncate_or_delete`
|
88 | 85 | $result = $s1->query_safe(
|
89 | 86 | "SET timescaledb.compress_truncate_behaviour TO truncate_or_delete;");
|
90 |
| -isnt($result, '', "session 1: set truncate_or_delete"); |
91 | 87 |
|
92 | 88 | # Run tests
|
93 | 89 |
|
|
97 | 93 |
|
98 | 94 | # Begin txns in both sessions
|
99 | 95 | $result = $s1->query_safe("BEGIN");
|
100 |
| -isnt($result, '', "session 1: begin"); |
101 | 96 |
|
102 | 97 | $result = $s2->query_safe("BEGIN");
|
103 |
| -isnt($result, '', "session 2: begin"); |
104 | 98 |
|
105 | 99 | # The aggregation query takes an AccessShareLock on the chunk, preventing truncate
|
106 | 100 | $result = $s2->query_safe($count_query);
|
|
123 | 117 | is($result, $num_rows, "session 2: validate row count again");
|
124 | 118 |
|
125 | 119 | $result = $s2->query_safe("COMMIT");
|
126 |
| -isnt($result, '', "session 2: commit"); |
127 | 120 |
|
128 | 121 | # No AccessExclusiveLock on the uncompressed chunk
|
129 | 122 | $result = $s1->query_safe(
|
|
134 | 127 |
|
135 | 128 |
|
136 | 129 | $result = $s1->query_safe("ROLLBACK");
|
137 |
| -isnt($result, '', "session 1: rollback"); |
138 | 130 |
|
139 | 131 | ##########################################################################
|
140 | 132 |
|
|
143 | 135 |
|
144 | 136 | # Begin txns in both sessions
|
145 | 137 | $result = $s1->query_safe("BEGIN");
|
146 |
| -isnt($result, '', "session 1: begin"); |
147 | 138 |
|
148 | 139 | $result = $s2->query_safe("BEGIN");
|
149 |
| -isnt($result, '', "session 2: begin"); |
150 | 140 |
|
151 | 141 | $result = $s2->query_safe($count_query);
|
152 | 142 | is($result, $num_rows, "session 2: validate row count");
|
|
157 | 147 |
|
158 | 148 | # Session 2 immediately commits, releasing the AccessShareLock on the table
|
159 | 149 | $result = $s2->query_safe("COMMIT");
|
160 |
| -isnt($result, '', "session 2: commit"); |
161 | 150 |
|
162 | 151 | # The result from the previous query_until() is returned with the next query
|
163 | 152 | # so perform a dummy query on s1 to discard the result
|
|
179 | 168 | is($result, $expected, "verify AccessExclusiveLock was taken");
|
180 | 169 |
|
181 | 170 | $result = $s1->query_safe("ROLLBACK");
|
182 |
| -isnt($result, '', "session 1: rollback"); |
183 | 171 |
|
184 | 172 | $s1->quit();
|
185 | 173 | $s2->quit();
|
|
0 commit comments