• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 17589970077-2502

09 Sep 2025 05:00PM UTC coverage: 65.196% (-5.0%) from 70.225%
17589970077-2502

push

github

tstack
[format] add fields for source file/line

Knowing the source file/line context in a log
message can help find log messages when using
log2src.

56 of 70 new or added lines in 2 files covered. (80.0%)

13954 existing lines in 210 files now uncovered.

45516 of 69814 relevant lines covered (65.2%)

404154.37 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/src/vtab_module.cc
1
/**
2
 * Copyright (c) 2017, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

30
#include "vtab_module.hh"
31

32
#include "config.h"
33
#include "lnav_util.hh"
34
#include "sqlitepp.hh"
35

36
std::string vtab_module_schemas;
37

38
std::map<intern_string_t, std::string> vtab_module_ddls;
39

40
void
41
to_sqlite(sqlite3_context* ctx, const lnav::console::user_message& um)
35✔
42
{
43
    auto errmsg = fmt::format(
44
        FMT_STRING("{}{}"), sqlitepp::ERROR_PREFIX, lnav::to_json(um));
140✔
45

46
    sqlite3_result_error(ctx, errmsg.c_str(), errmsg.size());
35✔
47
}
35✔
48

49
void
50
set_vtable_errmsg(sqlite3_vtab* vtab, const lnav::console::user_message& um)
14✔
51
{
52
    vtab->zErrMsg = sqlite3_mprintf(
14✔
53
        "%s%s", sqlitepp::ERROR_PREFIX, lnav::to_json(um).c_str());
28✔
54
}
14✔
55

56
lnav::console::user_message
57
sqlite3_error_to_user_message(sqlite3* db)
56✔
58
{
59
    const auto* errmsg = sqlite3_errmsg(db);
56✔
60
    if (startswith(errmsg, sqlitepp::ERROR_PREFIX)) {
56✔
61
        auto from_res = lnav::from_json<lnav::console::user_message>(
62
            &errmsg[strlen(sqlitepp::ERROR_PREFIX)]);
32✔
63

64
        if (from_res.isOk()) {
32✔
65
            return from_res.unwrap();
32✔
66
        }
67

UNCOV
68
        log_error("unable to parse error message: %s", errmsg);
×
UNCOV
69
        return lnav::console::user_message::error("internal error")
×
70
            .with_reason(from_res.unwrapErr()[0].um_message.get_string());
×
71
    }
32✔
72

73
    return lnav::console::user_message::error("SQL statement failed")
48✔
74
        .with_reason(errmsg);
24✔
75
}
76

77
void
78
vtab_index_usage::column_used(
133✔
79
    const vtab_index_constraints::const_iterator& iter)
80
{
81
    this->viu_min_column = std::min(iter->iColumn, this->viu_min_column);
133✔
82
    this->viu_max_column = std::max(iter->iColumn, this->viu_max_column);
133✔
83
    this->viu_index_info.idxNum |= (1L << iter.i_index);
133✔
84
    this->viu_used_column_count += 1;
133✔
85
}
133✔
86

87
void
88
vtab_index_usage::allocate_args(int low, int high, int required)
75✔
89
{
90
    int n_arg = 0;
75✔
91

92
    if (this->viu_min_column != low || this->viu_max_column > high
75✔
93
        || this->viu_used_column_count < required)
69✔
94
    {
95
        this->viu_index_info.estimatedCost = 2147483647;
8✔
96
        this->viu_index_info.estimatedRows = 2147483647;
8✔
97
        return;
8✔
98
    }
99

100
    for (int lpc = 0; lpc <= this->viu_max_column; lpc++) {
620✔
101
        for (int cons_index = 0; cons_index < this->viu_index_info.nConstraint;
1,507✔
102
             cons_index++)
103
        {
104
            if (this->viu_index_info.aConstraint[cons_index].iColumn != lpc) {
954✔
105
                continue;
825✔
106
            }
107
            if (!(this->viu_index_info.idxNum & (1L << cons_index))) {
129✔
108
                continue;
2✔
109
            }
110

111
            this->viu_index_info.aConstraintUsage[cons_index].argvIndex
127✔
112
                = ++n_arg;
127✔
113
        }
114
    }
115
    this->viu_index_info.estimatedCost = 1.0;
67✔
116
    this->viu_index_info.estimatedRows = 1;
67✔
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc