|
36 | 36 | invalid_entry_columns_order_test();
|
37 | 37 | inconsistent_with_parent_key__parent_key_corrupted_test();
|
38 | 38 | inconsistent_with_parent_key__child_key_corrupted_test();
|
| 39 | +inconsistent_with_parent_key__parent_key_corrupted_posting_tree_test(); |
39 | 40 |
|
40 | 41 | sub invalid_entry_order_leaf_page_test
|
41 | 42 | {
|
@@ -237,6 +238,44 @@ sub inconsistent_with_parent_key__child_key_corrupted_test
|
237 | 238 | like($stderr, qr/$expected/);
|
238 | 239 | }
|
239 | 240 |
|
| 241 | +sub inconsistent_with_parent_key__parent_key_corrupted_posting_tree_test |
| 242 | +{ |
| 243 | + my $relname = "test"; |
| 244 | + my $indexname = "test_gin_idx"; |
| 245 | + |
| 246 | + $node->safe_psql( |
| 247 | + 'postgres', qq( |
| 248 | + DROP TABLE IF EXISTS $relname; |
| 249 | + CREATE TABLE $relname (a text[]); |
| 250 | + INSERT INTO $relname (a) select ('{aaaaa}') from generate_series(1,10000); |
| 251 | + CREATE INDEX $indexname ON $relname USING gin (a); |
| 252 | + )); |
| 253 | + my $relpath = relation_filepath($indexname); |
| 254 | + |
| 255 | + $node->stop; |
| 256 | + |
| 257 | + my $blkno = 2; # posting tree root |
| 258 | + |
| 259 | + # we have a posting tree for 'aaaaa' key with the root at 2nd block |
| 260 | + # and two leaf pages 3 and 4. replace 4th page's high key with (1,1) |
| 261 | + # so that there are tid's in leaf page that are larger then the new high key. |
| 262 | + my $find = pack('S*', 0, 4, 0) . '....'; |
| 263 | + my $replace = pack('S*', 0, 4, 0, 1, 1); |
| 264 | + string_replace_block( |
| 265 | + $relpath, |
| 266 | + $find, |
| 267 | + $replace, |
| 268 | + $blkno |
| 269 | + ); |
| 270 | + |
| 271 | + $node->start; |
| 272 | + |
| 273 | + my ($result, $stdout, $stderr) = $node->psql('postgres', qq(SELECT gin_index_check('$indexname'))); |
| 274 | + my $expected = "index \"$indexname\": tid exceeds parent's high key in postingTree leaf on block 4"; |
| 275 | + like($stderr, qr/$expected/); |
| 276 | +} |
| 277 | + |
| 278 | + |
240 | 279 | # Returns the filesystem path for the named relation.
|
241 | 280 | sub relation_filepath
|
242 | 281 | {
|
|
0 commit comments