From 2545efcf2e00414b2f220fc2283adc6cacff9884 Mon Sep 17 00:00:00 2001 From: Nikita Orlov Date: Sat, 23 May 2020 02:03:02 +0300 Subject: [PATCH] issue-7224 Added tests --- ...led_insert_select_queries_couner.reference | 4 ++ ...81_failed_insert_select_queries_couner.sql | 66 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 tests/queries/0_stateless/01281_failed_insert_select_queries_couner.reference create mode 100644 tests/queries/0_stateless/01281_failed_insert_select_queries_couner.sql diff --git a/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.reference b/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.reference new file mode 100644 index 00000000000..099b7d91c92 --- /dev/null +++ b/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.reference @@ -0,0 +1,4 @@ +1 +2 +1 +2 diff --git a/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.sql b/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.sql new file mode 100644 index 00000000000..a21d9130dae --- /dev/null +++ b/tests/queries/0_stateless/01281_failed_insert_select_queries_couner.sql @@ -0,0 +1,66 @@ +DROP TABLE IF EXISTS current_failed_query_metrics; +DROP TABLE IF EXISTS to_insert; + +CREATE TABLE current_failed_query_metrics (event LowCardinality(String), value UInt64) ENGINE = Memory(); + + +INSERT INTO current_failed_query_metrics +SELECT event, value +FROM system.events +WHERE event in ('FailedQuery', 'FailedInsertQuery', 'FailedSelectQuery'); + +CREATE TABLE to_insert (value UInt64) ENGINE = Memory(); + +-- Failed insert before execution +INSERT INTO table_that_do_not_exists VALUES (42); -- { serverError 60 } + +SELECT current_value - previous_value +FROM ( + SELECT event, value as current_value FROM system.events WHERE event like 'FailedInsertQuery' +) AS previous +ALL JOIN ( + SELECT event, value as previous_value FROM current_failed_query_metrics +) AS current +on previous.event = current.event; + + +-- Failed insert in execution +INSERT INTO to_insert SELECT throwIf(1); -- { serverError 395 } + +SELECT current_value - previous_value +FROM ( + SELECT event, value as current_value FROM system.events WHERE event like 'FailedInsertQuery' +) AS previous +ALL JOIN ( + SELECT event, value as previous_value FROM current_failed_query_metrics +) AS current +on previous.event = current.event; + + +-- Failed select before execution +SELECT * FROM table_that_do_not_exists; -- { serverError 60 } + +SELECT current_value - previous_value +FROM ( + SELECT event, value as current_value FROM system.events WHERE event like 'FailedSelectQuery' +) AS previous +ALL JOIN ( + SELECT event, value as previous_value FROM current_failed_query_metrics +) AS current +on previous.event = current.event; + +-- Failed select in execution +SELECT throwIf(1); -- { serverError 395 } + +SELECT current_value - previous_value +FROM ( + SELECT event, value as current_value FROM system.events WHERE event like 'FailedSelectQuery' +) AS previous +ALL JOIN ( + SELECT event, value as previous_value FROM current_failed_query_metrics +) AS current +on previous.event = current.event; + + +DROP TABLE current_failed_query_metrics; +DROP TABLE to_insert;