mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-11 17:02:25 +00:00
Assume unversioned server has version=0 and use tryParse() instead of from_chars()
This commit is contained in:
parent
e0d5020a92
commit
810221baf2
@ -19,7 +19,6 @@
|
||||
#include <QueryPipeline/Pipe.h>
|
||||
#include <Server/HTTP/HTMLForm.h>
|
||||
#include <IO/ReadBufferFromString.h>
|
||||
#include <charconv>
|
||||
|
||||
|
||||
namespace DB
|
||||
@ -92,27 +91,25 @@ void ExternalDictionaryLibraryBridgeRequestHandler::handleRequest(HTTPServerRequ
|
||||
LOG_TRACE(log, "Request URI: {}", request.getURI());
|
||||
HTMLForm params(getContext()->getSettingsRef(), request);
|
||||
|
||||
size_t version;
|
||||
|
||||
if (!params.has("version"))
|
||||
{
|
||||
processError(response, "No 'version' in request URL");
|
||||
return;
|
||||
}
|
||||
version = 0; /// assumed version for too old servers which do not send a version
|
||||
else
|
||||
{
|
||||
String version_str = params.get("version");
|
||||
size_t version;
|
||||
auto [_, ec] = std::from_chars(version_str.data(), version_str.data() + version_str.size(), version);
|
||||
if (ec != std::errc())
|
||||
if (!tryParse(version, version_str))
|
||||
{
|
||||
processError(response, "Unable to parse 'version' string in request URL: '" + version_str + "' Check if the server and library-bridge have the same version.");
|
||||
return;
|
||||
}
|
||||
if (version != LIBRARY_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
// backwards compatibility is for now deemed unnecessary, just let the user upgrade the server and bridge to the same version
|
||||
processError(response, "Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != LIBRARY_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
/// backwards compatibility is considered unnecessary for now, just let the user know that the server and the bridge must be upgraded together
|
||||
processError(response, "Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!params.has("method"))
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <DataTypes/DataTypeNullable.h>
|
||||
#include <Server/HTTP/WriteBufferFromHTTPServerResponse.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Parsers/ParserQueryWithOutput.h>
|
||||
#include <Parsers/parseQuery.h>
|
||||
@ -23,8 +24,6 @@
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
|
||||
#include <charconv>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -83,27 +82,25 @@ void ODBCColumnsInfoHandler::handleRequest(HTTPServerRequest & request, HTTPServ
|
||||
LOG_WARNING(log, fmt::runtime(message));
|
||||
};
|
||||
|
||||
size_t version;
|
||||
|
||||
if (!params.has("version"))
|
||||
{
|
||||
process_error("No 'version' in request URL");
|
||||
return;
|
||||
}
|
||||
version = 0; /// assumed version for too old servers which do not send a version
|
||||
else
|
||||
{
|
||||
String version_str = params.get("version");
|
||||
size_t version;
|
||||
auto [_, ec] = std::from_chars(version_str.data(), version_str.data() + version_str.size(), version);
|
||||
if (ec != std::errc())
|
||||
if (!tryParse(version, version_str))
|
||||
{
|
||||
process_error("Unable to parse 'version' string in request URL: '" + version_str + "' Check if the server and library-bridge have the same version.");
|
||||
return;
|
||||
}
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
// backwards compatibility is for now deemed unnecessary, just let the user upgrade the server and bridge to the same version
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
/// backwards compatibility is considered unnecessary for now, just let the user know that the server and the bridge must be upgraded together
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!params.has("table"))
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <DataTypes/DataTypeFactory.h>
|
||||
#include <Server/HTTP/HTMLForm.h>
|
||||
#include <Server/HTTP/WriteBufferFromHTTPServerResponse.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Parsers/ParserQueryWithOutput.h>
|
||||
#include <Parsers/parseQuery.h>
|
||||
@ -17,8 +18,6 @@
|
||||
#include "validateODBCConnectionString.h"
|
||||
#include "ODBCPooledConnectionFactory.h"
|
||||
|
||||
#include <charconv>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -35,27 +34,25 @@ void IdentifierQuoteHandler::handleRequest(HTTPServerRequest & request, HTTPServ
|
||||
LOG_WARNING(log, fmt::runtime(message));
|
||||
};
|
||||
|
||||
size_t version;
|
||||
|
||||
if (!params.has("version"))
|
||||
{
|
||||
process_error("No 'version' in request URL");
|
||||
return;
|
||||
}
|
||||
version = 0; /// assumed version for too old servers which do not send a version
|
||||
else
|
||||
{
|
||||
String version_str = params.get("version");
|
||||
size_t version;
|
||||
auto [_, ec] = std::from_chars(version_str.data(), version_str.data() + version_str.size(), version);
|
||||
if (ec != std::errc())
|
||||
if (!tryParse(version, version_str))
|
||||
{
|
||||
process_error("Unable to parse 'version' string in request URL: '" + version_str + "' Check if the server and library-bridge have the same version.");
|
||||
return;
|
||||
}
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
// backwards compatibility is for now deemed unnecessary, just let the user upgrade the server and bridge to the same version
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
/// backwards compatibility is considered unnecessary for now, just let the user know that the server and the bridge must be upgraded together
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!params.has("connection_string"))
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <Server/HTTP/HTMLForm.h>
|
||||
#include <Common/config.h>
|
||||
|
||||
#include <charconv>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
@ -57,29 +56,28 @@ void ODBCHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse
|
||||
HTMLForm params(getContext()->getSettingsRef(), request);
|
||||
LOG_TRACE(log, "Request URI: {}", request.getURI());
|
||||
|
||||
size_t version;
|
||||
|
||||
if (!params.has("version"))
|
||||
{
|
||||
processError(response, "No 'version' in request URL");
|
||||
return;
|
||||
}
|
||||
version = 0; /// assumed version for too old servers which do not send a version
|
||||
else
|
||||
{
|
||||
String version_str = params.get("version");
|
||||
size_t version;
|
||||
auto [_, ec] = std::from_chars(version_str.data(), version_str.data() + version_str.size(), version);
|
||||
if (ec != std::errc())
|
||||
if (!tryParse(version, version_str))
|
||||
{
|
||||
processError(response, "Unable to parse 'version' string in request URL: '" + version_str + "' Check if the server and library-bridge have the same version.");
|
||||
return;
|
||||
}
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
// backwards compatibility is for now deemed unnecessary, just let the user upgrade the server and bridge to the same version
|
||||
processError(response, "Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
/// backwards compatibility is considered unnecessary for now, just let the user know that the server and the bridge must be upgraded together
|
||||
processError(response, "Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (mode == "read")
|
||||
params.read(request.getStream());
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <Server/HTTP/HTMLForm.h>
|
||||
#include <Server/HTTP/WriteBufferFromHTTPServerResponse.h>
|
||||
#include <IO/ReadHelpers.h>
|
||||
#include <IO/WriteHelpers.h>
|
||||
#include <Poco/Net/HTTPServerRequest.h>
|
||||
#include <Poco/Net/HTTPServerResponse.h>
|
||||
@ -14,8 +15,6 @@
|
||||
#include <sql.h>
|
||||
#include <sqlext.h>
|
||||
|
||||
#include <charconv>
|
||||
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -43,29 +42,28 @@ void SchemaAllowedHandler::handleRequest(HTTPServerRequest & request, HTTPServer
|
||||
LOG_WARNING(log, fmt::runtime(message));
|
||||
};
|
||||
|
||||
size_t version;
|
||||
|
||||
if (!params.has("version"))
|
||||
{
|
||||
process_error("No 'version' in request URL");
|
||||
return;
|
||||
}
|
||||
version = 0; /// assumed version for too old servers which do not send a version
|
||||
else
|
||||
{
|
||||
String version_str = params.get("version");
|
||||
size_t version;
|
||||
auto [_, ec] = std::from_chars(version_str.data(), version_str.data() + version_str.size(), version);
|
||||
if (ec != std::errc())
|
||||
if (!tryParse(version, version_str))
|
||||
{
|
||||
process_error("Unable to parse 'version' string in request URL: '" + version_str + "' Check if the server and library-bridge have the same version.");
|
||||
return;
|
||||
}
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
// backwards compatibility is for now deemed unnecessary, just let the user upgrade the server and bridge to the same version
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (version != XDBC_BRIDGE_PROTOCOL_VERSION)
|
||||
{
|
||||
/// backwards compatibility is considered unnecessary for now, just let the user know that the server and the bridge must be upgraded together
|
||||
process_error("Server and library-bridge have different versions: '" + std::to_string(version) + "' vs. '" + std::to_string(LIBRARY_BRIDGE_PROTOCOL_VERSION) + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!params.has("connection_string"))
|
||||
{
|
||||
process_error("No 'connection_string' in request URL");
|
||||
|
Loading…
Reference in New Issue
Block a user