mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Merge pull request #55419 from evillique/mongo-fix
Fix MongoDB connection issues
This commit is contained in:
commit
e204b1d616
@ -70,7 +70,7 @@ namespace MongoDB
|
|||||||
Document::Ptr queryBuildInfo(Connection & connection) const;
|
Document::Ptr queryBuildInfo(Connection & connection) const;
|
||||||
/// Queries server build info (all wire protocols)
|
/// Queries server build info (all wire protocols)
|
||||||
|
|
||||||
Document::Ptr queryServerHello(Connection & connection) const;
|
Document::Ptr queryServerHello(Connection & connection, bool old = false) const;
|
||||||
/// Queries hello response from server (all wire protocols)
|
/// Queries hello response from server (all wire protocols)
|
||||||
|
|
||||||
Int64 count(Connection & connection, const std::string & collectionName) const;
|
Int64 count(Connection & connection, const std::string & collectionName) const;
|
||||||
|
@ -356,11 +356,19 @@ Document::Ptr Database::queryBuildInfo(Connection& connection) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Document::Ptr Database::queryServerHello(Connection& connection) const
|
Document::Ptr Database::queryServerHello(Connection& connection, bool old) const
|
||||||
{
|
{
|
||||||
// hello can be issued on "config" system database
|
// hello can be issued on "config" system database
|
||||||
Poco::SharedPtr<Poco::MongoDB::QueryRequest> request = createCommand();
|
Poco::SharedPtr<Poco::MongoDB::QueryRequest> request = createCommand();
|
||||||
request->selector().add("hello", 1);
|
|
||||||
|
// 'hello' command was previously called 'isMaster'
|
||||||
|
std::string command_name;
|
||||||
|
if (old)
|
||||||
|
command_name = "isMaster";
|
||||||
|
else
|
||||||
|
command_name = "hello";
|
||||||
|
|
||||||
|
request->selector().add(command_name, 1);
|
||||||
|
|
||||||
Poco::MongoDB::ResponseMessage response;
|
Poco::MongoDB::ResponseMessage response;
|
||||||
connection.sendRequest(*request, response);
|
connection.sendRequest(*request, response);
|
||||||
|
@ -370,11 +370,24 @@ namespace
|
|||||||
bool isMongoDBWireProtocolOld(Poco::MongoDB::Connection & connection_)
|
bool isMongoDBWireProtocolOld(Poco::MongoDB::Connection & connection_)
|
||||||
{
|
{
|
||||||
Poco::MongoDB::Database db("config");
|
Poco::MongoDB::Database db("config");
|
||||||
Poco::MongoDB::Document::Ptr doc = db.queryServerHello(connection_);
|
Poco::MongoDB::Document::Ptr doc = db.queryServerHello(connection_, false);
|
||||||
|
|
||||||
|
if (doc->exists("maxWireVersion"))
|
||||||
|
{
|
||||||
auto wire_version = doc->getInteger("maxWireVersion");
|
auto wire_version = doc->getInteger("maxWireVersion");
|
||||||
return wire_version < Poco::MongoDB::Database::WireVersion::VER_36;
|
return wire_version < Poco::MongoDB::Database::WireVersion::VER_36;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doc = db.queryServerHello(connection_, true);
|
||||||
|
if (doc->exists("maxWireVersion"))
|
||||||
|
{
|
||||||
|
auto wire_version = doc->getInteger("maxWireVersion");
|
||||||
|
return wire_version < Poco::MongoDB::Database::WireVersion::VER_36;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MongoDBCursor::MongoDBCursor(
|
MongoDBCursor::MongoDBCursor(
|
||||||
const std::string & database,
|
const std::string & database,
|
||||||
|
Loading…
Reference in New Issue
Block a user