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