| 1142 | #define path "foo1" |
| 1143 | #define base_extn ".baseB" |
| 1144 | static bool test_foo1() |
| 1145 | { |
| 1146 | Xapian::WritableDatabase db(path, Xapian::DB_CREATE_OR_OVERWRITE); |
| 1147 | Xapian::Document doc; |
| 1148 | // Xapian::Database has full set of baseA, no baseB |
| 1149 | |
| 1150 | db.add_document(doc); |
| 1151 | db.flush(); |
| 1152 | |
| 1153 | // Xapian::Database has full set of baseB, old baseA |
| 1154 | |
| 1155 | db.add_document(doc); |
| 1156 | db.flush(); |
| 1157 | |
| 1158 | // Xapian::Database has full set of baseA, old baseB |
| 1159 | Xapian::Database dbr(path); |
| 1160 | cout << dbr.get_doccount() << endl; |
| 1161 | |
| 1162 | // Simulate a transaction starting, some of the baseB getting removed, |
| 1163 | // but then the transaction fails. |
| 1164 | unlink(string(path) + "/record" + base_extn); |
| 1165 | unlink(string(path) + "/term_list" + base_extn); |
| 1166 | |
| 1167 | // Xapian::Database has full set of baseA, some old baseB |
| 1168 | dbr = Xapian::Database(path); |
| 1169 | cout << dbr.get_doccount() << endl; |
| 1170 | |
| 1171 | db.add_document(doc); |
| 1172 | db.flush(); |
| 1173 | |
| 1174 | // Xapian::Database has full set of baseB, old baseA |
| 1175 | |
| 1176 | dbr = Xapian::Database(path); |
| 1177 | cout << dbr.get_doccount() << endl; |
| 1178 | |
| 1179 | db.add_document(doc); |
| 1180 | db.flush(); |
| 1181 | |
| 1182 | dbr = Xapian::Database(path); |
| 1183 | cout << dbr.get_doccount() << endl; |
| 1184 | |
| 1185 | return true; |
| 1186 | } |
| 1187 | |