Coverage Report

Created: 2026-03-17 00:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/information_schema/schema_helper.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "information_schema/schema_helper.h"
19
20
#include <gen_cpp/FrontendService.h>
21
22
#include "util/client_cache.h"
23
#include "util/thrift_rpc_helper.h"
24
25
namespace doris {
26
class TDescribeTablesParams;
27
class TDescribeTablesResult;
28
class TGetDbsParams;
29
class TGetDbsResult;
30
class TGetTablesParams;
31
class TGetTablesResult;
32
class TListPrivilegesResult;
33
class TListTableStatusResult;
34
class TShowVariableRequest;
35
class TShowVariableResult;
36
class TShowProcessListRequest;
37
class TShowProcessListResult;
38
class TShowUserRequest;
39
class TShowUserResult;
40
41
Status SchemaHelper::get_db_names(const std::string& ip, const int32_t port,
42
0
                                  const TGetDbsParams& request, TGetDbsResult* result) {
43
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
44
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
45
0
                client->getDbNames(*result, request);
46
0
            });
47
0
}
48
49
Status SchemaHelper::get_table_names(const std::string& ip, const int32_t port,
50
0
                                     const TGetTablesParams& request, TGetTablesResult* result) {
51
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
52
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
53
0
                client->getTableNames(*result, request);
54
0
            });
55
0
}
56
57
Status SchemaHelper::list_table_status(const std::string& ip, const int32_t port,
58
                                       const TGetTablesParams& request,
59
0
                                       TListTableStatusResult* result) {
60
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
61
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
62
0
                client->listTableStatus(*result, request);
63
0
            });
64
0
}
65
Status SchemaHelper::list_table_metadata_name_ids(const std::string& ip, const int32_t port,
66
                                                  const doris::TGetTablesParams& request,
67
0
                                                  TListTableMetadataNameIdsResult* result) {
68
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
69
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
70
0
                client->listTableMetadataNameIds(*result, request);
71
0
            });
72
0
}
73
74
Status SchemaHelper::describe_tables(const std::string& ip, const int32_t port,
75
                                     const TDescribeTablesParams& request,
76
0
                                     TDescribeTablesResult* result) {
77
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
78
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
79
0
                client->describeTables(*result, request);
80
0
            });
81
0
}
82
83
Status SchemaHelper::show_variables(const std::string& ip, const int32_t port,
84
                                    const TShowVariableRequest& request,
85
0
                                    TShowVariableResult* result) {
86
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
87
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
88
0
                client->showVariables(*result, request);
89
0
            });
90
0
}
91
92
Status SchemaHelper::list_table_privilege_status(const std::string& ip, const int32_t port,
93
                                                 const TGetTablesParams& request,
94
0
                                                 TListPrivilegesResult* result) {
95
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
96
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
97
0
                client->listTablePrivilegeStatus(*result, request);
98
0
            });
99
0
}
100
101
Status SchemaHelper::list_schema_privilege_status(const std::string& ip, const int32_t port,
102
                                                  const TGetTablesParams& request,
103
0
                                                  TListPrivilegesResult* result) {
104
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
105
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
106
0
                client->listSchemaPrivilegeStatus(*result, request);
107
0
            });
108
0
}
109
110
Status SchemaHelper::list_user_privilege_status(const std::string& ip, const int32_t port,
111
                                                const TGetTablesParams& request,
112
0
                                                TListPrivilegesResult* result) {
113
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
114
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
115
0
                client->listUserPrivilegeStatus(*result, request);
116
0
            });
117
0
}
118
119
0
std::string SchemaHelper::extract_db_name(const std::string& full_name) {
120
0
    auto found = full_name.find(':');
121
0
    if (found == std::string::npos) {
122
0
        return full_name;
123
0
    }
124
0
    found++;
125
0
    return std::string(full_name.c_str() + found, full_name.size() - found);
126
0
}
127
128
Status SchemaHelper::show_process_list(const std::string& ip, const int32_t port,
129
                                       const TShowProcessListRequest& request,
130
0
                                       TShowProcessListResult* result) {
131
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
132
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
133
0
                client->showProcessList(*result, request);
134
0
            });
135
0
}
136
137
Status SchemaHelper::show_user(const std::string& ip, const int32_t port,
138
0
                               const TShowUserRequest& request, TShowUserResult* result) {
139
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
140
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
141
0
                client->showUser(*result, request);
142
0
            });
143
0
}
144
145
Status SchemaHelper::fetch_routine_load_job(const std::string& ip, const int32_t port,
146
                                            const TFetchRoutineLoadJobRequest& request,
147
0
                                            TFetchRoutineLoadJobResult* result) {
148
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
149
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
150
0
                client->fetchRoutineLoadJob(*result, request);
151
0
            });
152
0
}
153
154
Status SchemaHelper::fetch_load_job(const std::string& ip, const int32_t port,
155
                                    const TFetchLoadJobRequest& request,
156
0
                                    TFetchLoadJobResult* result) {
157
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
158
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
159
0
                client->fetchLoadJob(*result, request);
160
0
            });
161
0
}
162
163
Status SchemaHelper::fetch_schema_table_data(const std::string& ip, const int32_t port,
164
                                             const TFetchSchemaTableDataRequest& request,
165
0
                                             TFetchSchemaTableDataResult* result) {
166
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
167
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
168
0
                client->fetchSchemaTableData(*result, request);
169
0
            });
170
0
}
171
172
Status SchemaHelper::get_master_keys(const std::string& ip, const int32_t port,
173
                                     const TGetEncryptionKeysRequest& request,
174
0
                                     TGetEncryptionKeysResult* result) {
175
0
    return ThriftRpcHelper::rpc<FrontendServiceClient>(
176
0
            ip, port, [&request, &result](FrontendServiceConnection& client) {
177
0
                client->getEncryptionKeys(*result, request);
178
0
            });
179
0
}
180
181
} // namespace doris