| 1201 | struct ListCollectionsCmd { |
| 1202 | static const char* name; |
| 1203 | ACTOR static Future<Reference<ExtMsgReply>> call(Reference<ExtConnection> ec, |
| 1204 | Reference<ExtMsgQuery> msg, |
| 1205 | Reference<ExtMsgReply> reply) { |
| 1206 | if (msg->query.hasField("cursor")) { |
| 1207 | const auto cursorObj = msg->query.getObjectField("cursor"); |
| 1208 | if (cursorObj.hasField("batchSize") && cursorObj.getIntField("batchSize") != 0) { |
| 1209 | TraceEvent(SevWarn, "unsupportedCmdOption") |
| 1210 | .detail("cmd", "listCollections") |
| 1211 | .detail("option", "cursor.batchSize"); |
| 1212 | throw unsupported_cmd_option(); |
| 1213 | } |
| 1214 | } |
| 1215 | |
| 1216 | state std::string databaseName = msg->getDBName(); |
| 1217 | state Reference<DocTransaction> dtr = ec->getOperationTransaction(); |
| 1218 | state Standalone<VectorRef<StringRef>> names; |
| 1219 | loop { |
| 1220 | try { |
| 1221 | Standalone<VectorRef<StringRef>> _names = |
| 1222 | wait(ec->docLayer->rootDirectory->list(dtr->tr, {StringRef(databaseName)})); |
| 1223 | names = _names; |
| 1224 | break; |
| 1225 | } catch (Error& e) { |
| 1226 | // If directory doesn't exist treat like empty database. |
| 1227 | if (e.code() == error_code_directory_does_not_exist) { |
| 1228 | break; |
| 1229 | } |
| 1230 | if (e.code() != error_code_actor_cancelled) { |
| 1231 | wait(dtr->onError(e)); |
| 1232 | } |
| 1233 | } |
| 1234 | } |
| 1235 | |
| 1236 | bson::BSONArrayBuilder collList; |
nothing calls this directly
no test coverage detected