Coverage Report

Created: 2026-03-14 20:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/information_schema/schema_files_scanner.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_files_scanner.h"
19
20
#include <gen_cpp/Descriptors_types.h>
21
#include <gen_cpp/FrontendService_types.h>
22
#include <stdint.h>
23
24
#include "core/data_type/define_primitive_type.h"
25
#include "core/string_ref.h"
26
#include "information_schema/schema_helper.h"
27
#include "runtime/runtime_profile.h"
28
29
namespace doris {
30
class RuntimeState;
31
class Block;
32
33
std::vector<SchemaScanner::ColumnDesc> SchemaFilesScanner::_s_tbls_columns = {
34
        //   name,       type,          size,     is_null
35
        {"FILE_ID", TYPE_BIGINT, sizeof(int64_t), true},
36
        {"FILE_NAME", TYPE_STRING, sizeof(StringRef), true},
37
        {"FILE_TYPE", TYPE_VARCHAR, sizeof(StringRef), true},
38
        {"TABLESPACE_NAME", TYPE_VARCHAR, sizeof(StringRef), false},
39
        {"TABLE_CATALOG", TYPE_CHAR, sizeof(StringRef), false},
40
        {"TABLE_SCHEMA", TYPE_STRING, sizeof(StringRef), true},
41
        {"TABLE_NAME", TYPE_STRING, sizeof(StringRef), true},
42
        {"LOGFILE_GROUP_NAME", TYPE_VARCHAR, sizeof(StringRef), true},
43
        {"LOGFILE_GROUP_NUMBER", TYPE_BIGINT, sizeof(int64_t), true},
44
        {"ENGINE", TYPE_VARCHAR, sizeof(StringRef), false},
45
        {"FULLTEXT_KEYS", TYPE_STRING, sizeof(StringRef), true},
46
        {"DELETED_ROWS", TYPE_STRING, sizeof(StringRef), true},
47
        {"UPDATE_COUNT", TYPE_STRING, sizeof(StringRef), true},
48
        {"FREE_EXTENTS", TYPE_BIGINT, sizeof(int64_t), true},
49
        {"TOTAL_EXTENTS", TYPE_BIGINT, sizeof(int64_t), true},
50
        {"EXTENT_SIZE", TYPE_BIGINT, sizeof(int64_t), true},
51
        {"INITIAL_SIZE", TYPE_BIGINT, sizeof(int64_t), true},
52
        {"MAXIMUM_SIZE", TYPE_BIGINT, sizeof(int64_t), true},
53
        {"AUTOEXTEND_SIZE", TYPE_BIGINT, sizeof(int64_t), true},
54
        {"CREATION_TIME", TYPE_STRING, sizeof(StringRef), true},
55
        {"LAST_UPDATE_TIME", TYPE_STRING, sizeof(StringRef), true},
56
        {"LAST_ACCESS_TIME", TYPE_STRING, sizeof(StringRef), true},
57
        {"RECOVER_TIME", TYPE_STRING, sizeof(StringRef), true},
58
        {"TRANSACTION_COUNTER", TYPE_STRING, sizeof(StringRef), true},
59
        {"VERSION", TYPE_BIGINT, sizeof(int64_t), true},
60
        {"ROW_FORMAT", TYPE_VARCHAR, sizeof(StringRef), true},
61
        {"TABLE_ROWS", TYPE_STRING, sizeof(StringRef), true},
62
        {"AVG_ROW_LENGTH", TYPE_STRING, sizeof(StringRef), true},
63
        {"DATA_LENGTH", TYPE_STRING, sizeof(StringRef), true},
64
        {"MAX_DATA_LENGTH", TYPE_STRING, sizeof(StringRef), true},
65
        {"INDEX_LENGTH", TYPE_STRING, sizeof(StringRef), true},
66
        {"DATA_FREE", TYPE_BIGINT, sizeof(int64_t), true},
67
        {"CREATE_TIME", TYPE_STRING, sizeof(StringRef), true},
68
        {"UPDATE_TIME", TYPE_STRING, sizeof(StringRef), true},
69
        {"CHECK_TIME", TYPE_STRING, sizeof(StringRef), true},
70
        {"CHECKSUM", TYPE_STRING, sizeof(StringRef), true},
71
        {"STATUS", TYPE_VARCHAR, sizeof(StringRef), true},
72
        {"EXTRA", TYPE_VARCHAR, sizeof(StringRef), true},
73
};
74
75
SchemaFilesScanner::SchemaFilesScanner()
76
0
        : SchemaScanner(_s_tbls_columns, TSchemaTableType::SCH_FILES),
77
0
          _db_index(0),
78
0
          _table_index(0) {}
79
80
0
SchemaFilesScanner::~SchemaFilesScanner() {}
81
82
0
Status SchemaFilesScanner::start(RuntimeState* state) {
83
0
    if (!_is_init) {
84
0
        return Status::InternalError("used before initialized.");
85
0
    }
86
0
    SCOPED_TIMER(_get_db_timer);
87
0
    TGetDbsParams db_params;
88
0
    if (nullptr != _param->common_param->db) {
89
0
        db_params.__set_pattern(*(_param->common_param->db));
90
0
    }
91
0
    if (nullptr != _param->common_param->catalog) {
92
0
        db_params.__set_catalog(*(_param->common_param->catalog));
93
0
    }
94
0
    if (nullptr != _param->common_param->current_user_ident) {
95
0
        db_params.__set_current_user_ident(*(_param->common_param->current_user_ident));
96
0
    } else {
97
0
        if (nullptr != _param->common_param->user) {
98
0
            db_params.__set_user(*(_param->common_param->user));
99
0
        }
100
0
        if (nullptr != _param->common_param->user_ip) {
101
0
            db_params.__set_user_ip(*(_param->common_param->user_ip));
102
0
        }
103
0
    }
104
105
0
    if (nullptr != _param->common_param->ip && 0 != _param->common_param->port) {
106
0
        RETURN_IF_ERROR(SchemaHelper::get_db_names(
107
0
                *(_param->common_param->ip), _param->common_param->port, db_params, &_db_result));
108
0
    } else {
109
0
        return Status::InternalError("IP or port doesn't exists");
110
0
    }
111
0
    return Status::OK();
112
0
}
113
114
0
Status SchemaFilesScanner::get_next_block_internal(Block* block, bool* eos) {
115
0
    if (!_is_init) {
116
0
        return Status::InternalError("Used before initialized.");
117
0
    }
118
0
    if (nullptr == block || nullptr == eos) {
119
0
        return Status::InternalError("input pointer is nullptr.");
120
0
    }
121
0
    *eos = true;
122
0
    return Status::OK();
123
0
}
124
125
} // namespace doris