Merge pull request #11651 from ClickHouse/empty-parameters-url

Skip empty URL parameters
This commit is contained in:
alexey-milovidov 2020-06-14 09:00:52 +03:00 committed by GitHub
commit 56b8d81ef6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 2 deletions

View File

@ -7,6 +7,8 @@
*/
#include <Common/SettingsChanges.h>
#include <Common/FieldVisitors.h>
namespace DB
{
@ -91,7 +93,16 @@ Field SettingsCollection<Derived>::const_reference::getValue() const
template <class Derived>
Field SettingsCollection<Derived>::valueToCorrespondingType(size_t index, const Field & value)
{
try
{
return members()[index].value_to_corresponding_type(value);
}
catch (Exception & e)
{
e.addMessage(fmt::format("in attempt to set the value of setting to {}",
applyVisitor(FieldVisitorToString(), value)));
throw;
}
}

View File

@ -982,7 +982,16 @@ void Context::setSetting(const StringRef & name, const Field & value)
void Context::applySettingChange(const SettingChange & change)
{
try
{
setSetting(change.name, change.value);
}
catch (Exception & e)
{
e.addMessage(fmt::format("in attempt to set the value of setting '{}' to {}",
change.name, applyVisitor(FieldVisitorToString(), change.value)));
throw;
}
}

View File

@ -430,6 +430,10 @@ void HTTPHandler::processQuery(
auto param_could_be_skipped = [&] (const String & name)
{
/// Empty parameter appears when URL like ?&a=b or a=b&&c=d. Just skip them for user's convenience.
if (name.empty())
return true;
if (reserved_param_names.count(name))
return true;

View File

@ -0,0 +1,3 @@
1
1
1

View File

@ -0,0 +1,10 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
set -e
$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL&query=select%201&log_queries=1"
$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL&&query=select%201&log_queries=1"
$CLICKHOUSE_CURL -sS "$CLICKHOUSE_URL&query=select%201&&&log_queries=1"