|
36 | 36 | # statements.
|
37 | 37 | #
|
38 | 38 |
|
39 |
| -my $main_in = ''; |
40 |
| -my $main_out = ''; |
41 |
| -my $main_timer = IPC::Run::timeout($PostgreSQL::Test::Utils::timeout_default); |
42 |
| - |
43 |
| -my $main_h = |
44 |
| - $node->background_psql('postgres', \$main_in, \$main_out, |
45 |
| - $main_timer, on_error_stop => 1); |
46 |
| -$main_in .= q( |
| 39 | +my $main_h = $node->background_psql('postgres'); |
| 40 | + |
| 41 | +$main_h->query_safe(q( |
47 | 42 | BEGIN;
|
48 | 43 | INSERT INTO tbl VALUES(0);
|
49 |
| -\echo syncpoint1 |
50 |
| -); |
51 |
| -pump $main_h until $main_out =~ /syncpoint1/ || $main_timer->is_expired; |
52 |
| - |
53 |
| -my $cic_in = ''; |
54 |
| -my $cic_out = ''; |
55 |
| -my $cic_timer = IPC::Run::timeout($PostgreSQL::Test::Utils::timeout_default); |
56 |
| -my $cic_h = |
57 |
| - $node->background_psql('postgres', \$cic_in, \$cic_out, |
58 |
| - $cic_timer, on_error_stop => 1); |
59 |
| -$cic_in .= q( |
| 44 | +)); |
| 45 | + |
| 46 | +my $cic_h = $node->background_psql('postgres'); |
| 47 | + |
| 48 | +$cic_h->query_until(qr/start/, q( |
60 | 49 | \echo start
|
61 | 50 | CREATE INDEX CONCURRENTLY idx ON tbl(i);
|
62 |
| -); |
63 |
| -pump $cic_h until $cic_out =~ /start/ || $cic_timer->is_expired; |
| 51 | +)); |
64 | 52 |
|
65 |
| -$main_in .= q( |
| 53 | +$main_h->query_safe(q( |
66 | 54 | PREPARE TRANSACTION 'a';
|
67 |
| -); |
| 55 | +)); |
68 | 56 |
|
69 |
| -$main_in .= q( |
| 57 | +$main_h->query_safe(q( |
70 | 58 | BEGIN;
|
71 | 59 | INSERT INTO tbl VALUES(0);
|
72 |
| -\echo syncpoint2 |
73 |
| -); |
74 |
| -pump $main_h until $main_out =~ /syncpoint2/ || $main_timer->is_expired; |
| 60 | +)); |
75 | 61 |
|
76 | 62 | $node->safe_psql('postgres', q(COMMIT PREPARED 'a';));
|
77 | 63 |
|
78 |
| -$main_in .= q( |
| 64 | +$main_h->query_safe(q( |
79 | 65 | PREPARE TRANSACTION 'b';
|
80 | 66 | BEGIN;
|
81 | 67 | INSERT INTO tbl VALUES(0);
|
82 |
| -\echo syncpoint3 |
83 |
| -); |
84 |
| -pump $main_h until $main_out =~ /syncpoint3/ || $main_timer->is_expired; |
| 68 | +)); |
85 | 69 |
|
86 | 70 | $node->safe_psql('postgres', q(COMMIT PREPARED 'b';));
|
87 | 71 |
|
88 |
| -$main_in .= q( |
| 72 | +$main_h->query_safe(q( |
89 | 73 | PREPARE TRANSACTION 'c';
|
90 | 74 | COMMIT PREPARED 'c';
|
91 |
| -); |
92 |
| -$main_h->pump_nb; |
| 75 | +)); |
93 | 76 |
|
94 |
| -$main_h->finish; |
95 |
| -$cic_h->finish; |
| 77 | +$main_h->quit; |
| 78 | +$cic_h->quit; |
96 | 79 |
|
97 | 80 | $result = $node->psql('postgres', q(SELECT bt_index_check('idx',true)));
|
98 | 81 | is($result, '0', 'bt_index_check after overlapping 2PC');
|
|
113 | 96 | ));
|
114 | 97 | $node->restart;
|
115 | 98 |
|
116 |
| -my $reindex_in = ''; |
117 |
| -my $reindex_out = ''; |
118 |
| -my $reindex_timer = |
119 |
| - IPC::Run::timeout($PostgreSQL::Test::Utils::timeout_default); |
120 |
| -my $reindex_h = |
121 |
| - $node->background_psql('postgres', \$reindex_in, \$reindex_out, |
122 |
| - $reindex_timer, on_error_stop => 1); |
123 |
| -$reindex_in .= q( |
| 99 | +my $reindex_h = $node->background_psql('postgres'); |
| 100 | +$reindex_h->query_until(qr/start/, q( |
124 | 101 | \echo start
|
125 | 102 | DROP INDEX CONCURRENTLY idx;
|
126 | 103 | CREATE INDEX CONCURRENTLY idx ON tbl(i);
|
127 |
| -); |
128 |
| -pump $reindex_h until $reindex_out =~ /start/ || $reindex_timer->is_expired; |
| 104 | +)); |
129 | 105 |
|
130 | 106 | $node->safe_psql('postgres', "COMMIT PREPARED 'spans_restart'");
|
131 |
| -$reindex_h->finish; |
| 107 | +$reindex_h->quit; |
132 | 108 | $result = $node->psql('postgres', q(SELECT bt_index_check('idx',true)));
|
133 | 109 | is($result, '0', 'bt_index_check after 2PC and restart');
|
134 | 110 |
|
|
0 commit comments