diff --git a/src/Interpreters/ProcessList.cpp b/src/Interpreters/ProcessList.cpp index 4e336a98787..15bda5d213d 100644 --- a/src/Interpreters/ProcessList.cpp +++ b/src/Interpreters/ProcessList.cpp @@ -455,7 +455,10 @@ QueryStatusInfo QueryStatus::getInfo(bool get_thread_list, bool get_profile_even } if (get_settings && query_context) + { res.query_settings = std::make_shared(query_context->getSettings()); + res.current_database = query_context->getCurrentDatabase(); + } return res; } diff --git a/src/Interpreters/ProcessList.h b/src/Interpreters/ProcessList.h index f6151bb3429..bc93ce7e191 100644 --- a/src/Interpreters/ProcessList.h +++ b/src/Interpreters/ProcessList.h @@ -68,6 +68,7 @@ struct QueryStatusInfo std::vector thread_ids; std::shared_ptr profile_counters; std::shared_ptr query_settings; + std::string current_database; }; /// Query and information about its execution. diff --git a/src/Storages/System/StorageSystemProcesses.cpp b/src/Storages/System/StorageSystemProcesses.cpp index b397d941786..e6266503095 100644 --- a/src/Storages/System/StorageSystemProcesses.cpp +++ b/src/Storages/System/StorageSystemProcesses.cpp @@ -64,6 +64,8 @@ NamesAndTypesList StorageSystemProcesses::getNamesAndTypes() {"ProfileEvents.Values", std::make_shared(std::make_shared())}, {"Settings.Names", std::make_shared(std::make_shared())}, {"Settings.Values", std::make_shared(std::make_shared())}, + + {"current_database", std::make_shared()}, }; } @@ -149,6 +151,8 @@ void StorageSystemProcesses::fillData(MutableColumns & res_columns, const Contex column_settings_values->insertDefault(); } } + + res_columns[i++]->insert(process.current_database); } } diff --git a/tests/queries/0_stateless/00956_sensitive_data_masking.sh b/tests/queries/0_stateless/00956_sensitive_data_masking.sh index 6b9990ee819..7462dfd5585 100755 --- a/tests/queries/0_stateless/00956_sensitive_data_masking.sh +++ b/tests/queries/0_stateless/00956_sensitive_data_masking.sh @@ -65,7 +65,7 @@ echo '5.1' # wait until the query in background will start (max: 10 seconds as sleepEachRow) for _ in {1..100}; do - $CLICKHOUSE_CLIENT --query="SHOW PROCESSLIST" --log_queries=0 >"$tmp_file" 2>&1 + $CLICKHOUSE_CLIENT --query="SELECT * FROM system.processes WHERE current_database = currentDatabase()" --log_queries=0 >"$tmp_file" 2>&1 grep -q -F 'fwerkh_that_magic_string_make_me_unique' "$tmp_file" && break sleep 0.1 done @@ -118,8 +118,8 @@ $CLICKHOUSE_CLIENT --query="SYSTEM FLUSH LOGS" --server_logs_file=/dev/null echo 9 $CLICKHOUSE_CLIENT \ --server_logs_file=/dev/null \ - --query="SELECT if( count() > 0, 'text_log non empty', 'text_log empty') FROM system.text_log WHERE event_time>now() - 60 and message like '%find_me%'; - select * from system.text_log where event_time > now() - 60 and message like '%TOPSECRET=TOPSECRET%';" --ignore-error --multiquery + --query="SELECT if( count() > 0, 'text_log non empty', 'text_log empty') FROM system.text_log WHERE event_date >= yesterday() and message like '%find_me%'; + select * from system.text_log where event_date >= yesterday() and message like '%TOPSECRET=TOPSECRET%';" --ignore-error --multiquery echo 'finish' rm -f "$tmp_file" >/dev/null 2>&1 diff --git a/tests/queries/0_stateless/01567_system_processes_current_database.reference b/tests/queries/0_stateless/01567_system_processes_current_database.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/tests/queries/0_stateless/01567_system_processes_current_database.reference @@ -0,0 +1 @@ +1 diff --git a/tests/queries/0_stateless/01567_system_processes_current_database.sql b/tests/queries/0_stateless/01567_system_processes_current_database.sql new file mode 100644 index 00000000000..406120d742d --- /dev/null +++ b/tests/queries/0_stateless/01567_system_processes_current_database.sql @@ -0,0 +1 @@ +select count(*) from system.processes where current_database = currentDatabase();