mirror of https://github.com/ByConity/ByConity
Merge branch 'tenant_opt_dottedcol' into 'cnch-dev'
fix(clickhousech@m-3010311700): "X.Y.Z" format column query support in multi-tenant enviornment See merge request dp/ClickHouse!19517 # Conflicts: # src/Parsers/formatTenantDatabaseName.cpp
This commit is contained in:
parent
c2e4e8f1ca
commit
09a45ed660
|
@ -136,7 +136,6 @@
|
|||
#include <common/logger_useful.h>
|
||||
#include <common/phdr_cache.h>
|
||||
#include <common/scope_guard.h>
|
||||
#include <Parsers/formatTenantDatabaseName.h>
|
||||
#include <Common/ChineseTokenExtractor.h>
|
||||
|
||||
#include <CloudServices/CnchServerClientPool.h>
|
||||
|
@ -1792,9 +1791,6 @@ int Server::main(const std::vector<std::string> & /*args*/)
|
|||
|
||||
global_context->setEnableSSL(enable_ssl);
|
||||
|
||||
bool enable_tenant_systemdb = config().getBool("enable_tenant_systemdb", true);
|
||||
setEnableTenantSystemDB(enable_tenant_systemdb);
|
||||
|
||||
buildLoggers(config(), logger());
|
||||
|
||||
main_config_reloader->start();
|
||||
|
|
|
@ -218,8 +218,14 @@ bool IdentifierSemantic::doesIdentifierBelongTo(const ASTIdentifier & identifier
|
|||
{
|
||||
size_t num_components = identifier.name_parts.size();
|
||||
if (num_components >= 3)
|
||||
return identifier.name_parts[0] == database &&
|
||||
identifier.name_parts[1] == table;
|
||||
{
|
||||
if (identifier.name_parts[1] == table)
|
||||
{
|
||||
if (identifier.name_parts[0] != database)
|
||||
return formatTenantDatabaseName(identifier.name_parts[0]) == database;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,13 +31,6 @@ static String getTenantId()
|
|||
return CurrentThread::get().getTenantId();
|
||||
}
|
||||
|
||||
static bool enable_tenant_systemdb = true;
|
||||
|
||||
void setEnableTenantSystemDB(bool v)
|
||||
{
|
||||
enable_tenant_systemdb = v;
|
||||
}
|
||||
|
||||
String getCurrentCatalog()
|
||||
{
|
||||
String empty_result;
|
||||
|
@ -64,11 +57,6 @@ static bool isInternalDatabaseName(const String & database_name)
|
|||
if (db == database_name)
|
||||
return true;
|
||||
}
|
||||
if(!enable_tenant_systemdb)
|
||||
{
|
||||
if (DatabaseCatalog::SYSTEM_DATABASE == database_name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@ namespace DB
|
|||
|
||||
class Context;
|
||||
|
||||
void setEnableTenantSystemDB(bool v);
|
||||
|
||||
// database_name -> tenant_id.[catalog$$].database_name
|
||||
String formatTenantDatabaseName(const String & database_name);
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
----- check for X.Y.Z selecting ------
|
||||
2 2 2
|
||||
3 3 3
|
||||
1 1 1
|
||||
4 4 4
|
||||
0 0 0
|
||||
Df Df Df Df
|
||||
|
||||
ABC ABC ABC ABC
|
||||
|
||||
|
||||
----- check for X.Y.Z selecting for multi-table------
|
||||
2 2 2 Df Df Df
|
||||
3 3 3
|
||||
1 1 1 ABC ABC ABC
|
||||
4 4 4
|
||||
0 0 0
|
|
@ -0,0 +1,13 @@
|
|||
DROP DATABASE IF EXISTS test_db;
|
||||
CREATE DATABASE test_db;
|
||||
|
||||
SELECT '----- check for X.Y.Z selecting ------';
|
||||
CREATE TABLE test_db.test_tb (arr Array(String), id UInt32) Engine = CnchMergeTree ORDER BY tuple();
|
||||
insert into test_db.test_tb values (['Abc','Df','Q'], 2), (['Abc','DEFQ'], 3), (['ABC','Q','ERT'], 1), (['Ab','ber'], 4), (['A'], 0);
|
||||
select test_db.test_tb.id, test_tb.id, id from test_db.test_tb;
|
||||
select test_db.test_tb.arr[id], test_tb.arr[id], arr[id], arr[test_db.test_tb.id] from test_db.test_tb;
|
||||
|
||||
SELECT '----- check for X.Y.Z selecting for multi-table------';
|
||||
CREATE TABLE test_db.test_tb1 (arr Array(String), id UInt32) Engine = CnchMergeTree ORDER BY tuple();
|
||||
insert into test_db.test_tb1 values (['Abc','Df','Q'], 0), (['Abc','DEFQ'], 2), (['ABC','Q','ERT'], 1), (['Ab','ber'], 3), (['A'], 4);
|
||||
select test_db.test_tb.id, test_db.test_tb1.id, id, arr[id], arr[test_db.test_tb.id], test_db.test_tb.arr[id] from test_db.test_tb join test_db.test_tb1 on test_db.test_tb.id = test_db.test_tb1.id and test_tb.id = test_db.test_tb1.id;
|
Loading…
Reference in New Issue