diff --git a/src/readline_callbacks.cc b/src/readline_callbacks.cc index e4b2223a9b..2353ef93cd 100644 --- a/src/readline_callbacks.cc +++ b/src/readline_callbacks.cc @@ -760,11 +760,12 @@ rl_sql_change(textinput_curses& rc, bool is_req) if (!is_req && attr_iter->sa_type == &SQL_HEX_LIT_ATTR && attr_iter->sa_range.length() == 2) { - } else if (is_req - || (attr_iter->sa_type != &SQL_NUMBER_ATTR - && attr_iter->sa_type != &SQL_HEX_LIT_ATTR) - || rc.tc_popup_type - == textinput_curses::popup_type_t::completion) + } else if (attr_iter->sa_type != &SQL_GARBAGE_ATTR + && (is_req + || (attr_iter->sa_type != &SQL_NUMBER_ATTR + && attr_iter->sa_type != &SQL_HEX_LIT_ATTR) + || rc.tc_popup_type + == textinput_curses::popup_type_t::completion)) { auto to_complete_sf = anno_line.to_string_fragment(attr_iter); diff --git a/test/test_sql_anno.sh b/test/test_sql_anno.sh index 93244ea470..3d4c25c172 100644 --- a/test/test_sql_anno.sh +++ b/test/test_sql_anno.sh @@ -124,3 +124,8 @@ take 10 run_cap_test ./drive_sql_anno "SELECT * FROM customers LIMIT 1" run_cap_test ./drive_sql_anno "SELECT * FROM customers FULL JOIN all_logs pg_stmt_log ON (pg_stmt_log.log_text LIKE '%STATEMENT:%') LIMIT 1" + +# the trailing ';' must be annotated as garbage so that the SQL completion +# trigger in rl_sql_change() does not offer suggestions at the statement +# terminator (see #1751) +run_cap_test ./drive_sql_anno "SELECT * FROM caddy_log WHERE 1=1;"