mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 23:52:03 +00:00
Add setting throw_if_no_data_to_insert
This commit is contained in:
parent
93229133e2
commit
72b0aa18e7
@ -1058,7 +1058,13 @@ void ClientBase::processInsertQuery(const String & query_to_execute, ASTPtr pars
|
||||
/// Process the query that requires transferring data blocks to the server.
|
||||
const auto parsed_insert_query = parsed_query->as<ASTInsertQuery &>();
|
||||
if ((!parsed_insert_query.data && !parsed_insert_query.infile) && (is_interactive || (!stdin_is_a_tty && std_in.eof())))
|
||||
throw Exception("No data to insert", ErrorCodes::NO_DATA_TO_INSERT);
|
||||
{
|
||||
const auto & settings = global_context->getSettingsRef();
|
||||
if (settings.throw_if_no_data_to_insert)
|
||||
throw Exception("No data to insert", ErrorCodes::NO_DATA_TO_INSERT);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
||||
connection->sendQuery(
|
||||
connection_parameters.timeouts,
|
||||
|
@ -582,6 +582,7 @@ class IColumn;
|
||||
M(Bool, allow_experimental_object_type, false, "Allow Object and JSON data types", 0) \
|
||||
M(String, insert_deduplication_token, "", "If not empty, used for duplicate detection instead of data digest", 0) \
|
||||
M(Bool, throw_on_unsupported_query_inside_transaction, true, "Throw exception if unsupported query is used inside transaction", 0) \
|
||||
M(Bool, throw_if_no_data_to_insert, true, "Enables or disables empty INSERTs, disable by default", 0) \
|
||||
// End of COMMON_SETTINGS
|
||||
// Please add settings related to formats into the FORMAT_FACTORY_SETTINGS and move obsolete settings to OBSOLETE_SETTINGS.
|
||||
|
||||
|
11
tests/queries/0_stateless/02267_insert_empty_data.sql
Normal file
11
tests/queries/0_stateless/02267_insert_empty_data.sql
Normal file
@ -0,0 +1,11 @@
|
||||
DROP TABLE IF EXISTS t;
|
||||
|
||||
CREATE TABLE t (n UInt32) ENGINE=Memory;
|
||||
|
||||
INSERT INTO t VALUES; -- { clientError 108 }
|
||||
|
||||
set throw_if_no_data_to_insert = 0;
|
||||
|
||||
INSERT INTO t VALUES;
|
||||
|
||||
DROP TABLE t;
|
Loading…
Reference in New Issue
Block a user