Skip to content

Commit 382b6b5

Browse files
committed
[sql] recognize postgres keywords
1 parent f43873a commit 382b6b5

24 files changed

Lines changed: 746 additions & 84 deletions

.github/workflows/bins.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ jobs:
308308
NEWS.md
309309
if-no-files-found: error
310310
- name: sign
311+
if: ${{ inputs.upload_url != '' }}
311312
uses: signpath/github-action-submit-signing-request@v1.1
312313
env:
313314
# select release-signing policy for main and release branches
@@ -325,12 +326,14 @@ jobs:
325326
output-artifact-directory: 'lnav-signed'
326327
- name: upload-signed-artifact
327328
id: upload-signed-artifact
329+
if: ${{ inputs.upload_url != '' }}
328330
uses: actions/upload-artifact@v4
329331
with:
330332
name: lnav-signed-windows-${{ matrix.arch }}.zip
331333
path: "lnav-signed"
332334
if-no-files-found: error
333335
- name: "Produce zip"
336+
if: ${{ inputs.upload_url != '' }}
334337
run: |
335338
set -x
336339
cp lnav-signed/bin/* ../lnav-build/${{ env.LNAV_BASENAME }}/bin/

src/cmd.parser.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ parsed::arg_at(int x) const
102102
auto al = attr_line_t(se.se_value);
103103
auto al_x = x - se.se_origin.sf_begin;
104104

105-
annotate_sql_statement(al);
105+
annotate_sql_statement(al, lnav::sql::dialect::sqlite);
106106
for (const auto& attr : al.al_attrs) {
107107
if (al_x < attr.sa_range.lr_start
108108
|| attr.sa_range.lr_end < al_x)

src/column_namer.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ column_namer::existing_name(const string_fragment& in_name) const
5656
case language::SQL: {
5757
auto upped = toupper(in_name.to_string());
5858

59-
if (std::binary_search(
60-
std::begin(sql_keywords), std::end(sql_keywords), upped))
59+
if (std::binary_search(std::begin(sqlite_keywords),
60+
std::end(sqlite_keywords),
61+
upped))
6162
{
6263
return true;
6364
}

src/command_executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ execute_sql(exec_context& ec, const std::string& sql, std::string& alt_msg)
306306
}
307307

308308
auto stmt_al = attr_line_t(stmt_str);
309-
readline_sqlite_highlighter(stmt_al, 0);
309+
readline_sql_highlighter(stmt_al, lnav::sql::dialect::prql, 0);
310310
auto um
311311
= lnav::console::user_message::error(
312312
attr_line_t("unable to compile PRQL: ").append(stmt_al))

src/field_overlay_source.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
400400
this->fos_row_to_field_meta.emplace(
401401
this->fos_lines.size(), row_info{std::nullopt, value_str});
402402
}
403-
readline_sqlite_highlighter_int(al, std::nullopt, hl_range);
403+
readline_sql_highlighter_int(
404+
al, lnav::sql::dialect::sqlite, std::nullopt, hl_range);
404405

405406
al.append(" = ").append(scrub_ws(value_str.c_str()));
406407

@@ -436,7 +437,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
436437
.append(qname.in())
437438
.append(")")
438439
.move();
439-
readline_sqlite_highlighter(key_line, std::nullopt);
440+
readline_sql_highlighter(
441+
key_line, lnav::sql::dialect::sqlite, std::nullopt);
440442
auto key_size = key_line.length();
441443
key_line.append(" = ").append(scrub_ws(extra_pair.second));
442444
this->fos_row_to_field_meta.emplace(this->fos_lines.size(),
@@ -456,7 +458,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
456458
.append(this->fos_log_helper.format_json_getter(
457459
jpairs_map.first, lpc))
458460
.move();
459-
readline_sqlite_highlighter(key_line, std::nullopt);
461+
readline_sql_highlighter(
462+
key_line, lnav::sql::dialect::sqlite, std::nullopt);
460463
auto key_size = key_line.length();
461464
key_line.append(" = ").append(scrub_ws(jpairs[lpc].wt_value));
462465
this->fos_row_to_field_meta.emplace(
@@ -479,7 +482,8 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
479482
this->fos_log_helper.ldh_file->get_format()->get_name().c_str(),
480483
qname.in());
481484
auto key_line = attr_line_t(" ").append(xp_call.in()).move();
482-
readline_sqlite_highlighter(key_line, std::nullopt);
485+
readline_sql_highlighter(
486+
key_line, lnav::sql::dialect::sqlite, std::nullopt);
483487
auto key_size = key_line.length();
484488
key_line.append(" = ").append(scrub_ws(xml_pair.second));
485489
this->fos_row_to_field_meta.emplace(

src/filter_sub_source.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ filter_sub_source::text_value_for_line(textview_curses& tc,
373373
readline_regex_highlighter(content, std::nullopt);
374374
break;
375375
case filter_lang_t::SQL:
376-
readline_sqlite_highlighter(content, std::nullopt);
376+
readline_sql_highlighter(
377+
content, lnav::sql::dialect::sqlite, std::nullopt);
377378
break;
378379
case filter_lang_t::NONE:
379380
break;

src/help_text_formatter.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,8 @@ format_example_text_for_term(const help_text& ht,
644644
case help_context_t::HC_SQL_TABLE_VALUED_FUNCTION:
645645
case help_context_t::HC_PRQL_TRANSFORM:
646646
case help_context_t::HC_PRQL_FUNCTION:
647-
readline_sqlite_highlighter(ex_line, std::nullopt);
647+
readline_sql_highlighter(
648+
ex_line, lnav::sql::dialect::sqlite, std::nullopt);
648649
prompt = ";";
649650
break;
650651
default:

src/lnav.prompt.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ prompt::rl_reformat(textinput_curses& tc)
437437
switch (tc.tc_prefix.al_string.front()) {
438438
case ';': {
439439
auto content = attr_line_t(tc.get_content());
440-
annotate_sql_statement(content);
440+
annotate_sql_statement(content, lnav::sql::dialect::sqlite);
441441
auto format_res = lnav::db::format(content, tc.get_cursor_offset());
442442
tc.set_content(format_res.fr_content);
443443
if (tc.tc_height == 1) {
@@ -493,7 +493,8 @@ prompt::rl_history(textinput_curses& tc)
493493
al.al_attrs.emplace_back(line_range{0, 1}, VC_ICON.value(icon));
494494
break;
495495
case ';':
496-
readline_sqlite_highlighter(al, std::nullopt);
496+
readline_sql_highlighter(
497+
al, lnav::sql::dialect::sqlite, std::nullopt);
497498
al.insert(0, " ");
498499
al.al_attrs.emplace_back(line_range{0, 1}, VC_ICON.value(icon));
499500
break;
@@ -1015,7 +1016,9 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
10151016
if (parent.empty()) {
10161017
parent = ".";
10171018
}
1018-
if (!parent.has_root_name() || !parent.root_directory().empty()) {
1019+
if (!parent.has_root_name()
1020+
|| !parent.root_directory().empty())
1021+
{
10191022
log_trace("completing directory: %s", parent.c_str());
10201023
for (const auto& entry :
10211024
std::filesystem::directory_iterator(parent, ec))
@@ -1025,14 +1028,16 @@ prompt::get_cmd_parameter_completion(textview_curses& tc,
10251028
if (entry.is_directory()) {
10261029
path_str.push_back('/');
10271030
} else if (ht->ht_format
1028-
== help_parameter_format_t::HPF_DIRECTORY)
1031+
== help_parameter_format_t::
1032+
HPF_DIRECTORY)
10291033
{
10301034
continue;
10311035
}
10321036
path_str = str_as_path.to_native(path_str);
10331037
poss_paths.emplace(std::move(path_str));
10341038
}
1035-
if (ht->ht_format == help_parameter_format_t::HPF_DIRECTORY
1039+
if (ht->ht_format
1040+
== help_parameter_format_t::HPF_DIRECTORY
10361041
&& !ec)
10371042
{
10381043
auto path_str = parent.string();

src/lnav_commands.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,8 @@ com_mark_expr(exec_context& ec,
10721072
= attr_line_t(expr)
10731073
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
10741074
.move();
1075-
readline_sqlite_highlighter(expr_al, std::nullopt);
1075+
readline_sql_highlighter(
1076+
expr_al, lnav::sql::dialect::sqlite, std::nullopt);
10761077
auto um = lnav::console::user_message::error(
10771078
attr_line_t("invalid mark expression: ").append(expr_al))
10781079
.with_reason(errmsg)
@@ -1374,7 +1375,8 @@ com_filter_expr(exec_context& ec,
13741375
= attr_line_t(expr)
13751376
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
13761377
.move();
1377-
readline_sqlite_highlighter(expr_al, std::nullopt);
1378+
readline_sql_highlighter(
1379+
expr_al, lnav::sql::dialect::sqlite, std::nullopt);
13781380
auto um = lnav::console::user_message::error(
13791381
attr_line_t("invalid filter expression: ")
13801382
.append(expr_al))

src/log.annotate.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ struct expressions : public lnav_config_listener {
9393
.with_attr_for_all(
9494
VC_ROLE.value(role_t::VCR_QUOTED_CODE))
9595
.move();
96-
readline_sqlite_highlighter(sql_al, std::nullopt);
96+
readline_sql_highlighter(
97+
sql_al, lnav::sql::dialect::sqlite, std::nullopt);
9798
intern_string_t cond_expr_path = intern_string::lookup(
9899
fmt::format(FMT_STRING("/log/annotations/{}/condition"),
99100
pair.first));

0 commit comments

Comments
 (0)